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/common.rb
ます。
describe command("lsb_release -d") do
its(:stdout) { should match /wheezy/ }
end
次にspec/chat.example.org.uk/host_spec.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
だから私の質問は2つあります:
- 外部ファイルから共通テストを含めることは可能ですか?
- もしそうなら、どうすればこれを達成できますか?