我使用serverspec來執行服務器的遠程測試。是否可以在serverspec中包含通用測試?
我有一些不同的測試,這是所有工作的優良:
`-- spec
|-- builder.example.org.uk
\ host_spec.rb
|-- chat.example.org.uk
\ host_spec.rb
|-- docker.example.org.uk
\ host_spec.rb
\-- git.example.org.uk
\ host_spec.rb
但是每個主機測試有很多重複的,因爲我想確保每個主機有sshd
運行,例如。
我試過幾種不同的方式創建spec/common_tests.rb
但每次都失敗。在spec/chat.example.org.uk/host_spec.rb
describe command("lsb_release -d") do
its(:stdout) { should match /wheezy/ }
end
然後:例如添加spec/common.rb
require 'common'
然而,這似乎一下子要連接到不同的主機,但失敗了:
shelob ~ $ bundle exec rake spec:ssh.example.org.uk
/usr/bin/ruby1.9.1 -S rspec spec/ssh.example.org.uk/host_spec.rb
F.....................
Failures:
1) Command "lsb_release -d" stdout
On host `ssh.example.org.uk`
Failure/Error: Unable to find matching line from backtrace
SocketError: getaddrinfo: Name or service not known
所以我的問題是雙重:
- 是否可以包含來自外部文件的常見測試?
- 如果是這樣,我該如何做到這一點?
如何symlinking規格到主機目錄? – 2014-09-03 14:32:22
可悲的是,這是行不通的。 – 2014-09-03 14:44:25
目前我已經使用'cpp'將hack文件包含在規範中,並編寫了'Makefile'來完成必要的工作。不愉快,但它確實有效。 – 2014-09-04 01:32:52