LoginSignup
0
1

More than 5 years have passed since last update.

Serverspecでnginxのバージョンをテストする

Last updated at Posted at 2016-06-18

nginx -vでの出力はstderrを指定すれば、テストが通るというメモを記す。

nginx -vで、nginxのバージョンを確認する。

出力結果:
nginx version: nginx/1.4.6 (Ubuntu)

"stdout"では失敗する。

nginx_spec.rb
# Check installed package version
describe command('nginx -v') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match /1.4.6/ }
end

テスト結果:

1) Command "nginx -v" stdout should match /1.4.6/
On host `melody'
Failure/Error: its(:stdout) { should match /1.4.6/ }
expected "" to match /1.4.6/

"stderr"にすると成功する。

nginx_spec.rb
# Check installed package version
describe command('nginx -v') do
  its(:exit_status) { should eq 0 }
  its(:stderr) { should match /1.4.6/ }
end

テスト結果:

Command "nginx -v"
exit_status
should eq 0
stderr
should match /1.4.6/
Finished in * seconds (files took * seconds to load)
2 examples, 0 failures

どうやらnginxの仕様らしい。
Why write nginx version on stderr?
gccやjavaも同じ類のようである。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1