spec/darwin/command_spec.rb in serverspec-0.6.16 vs spec/darwin/command_spec.rb in serverspec-0.6.17

- old
+ new

@@ -1,13 +1,48 @@ require 'spec_helper' include Serverspec::Helper::Darwin -describe 'Serverspec command matchers of Darwin family' do - it_behaves_like 'support command return_stdout matcher', 'cat /etc/resolv.conf', 'localhost' - it_behaves_like 'support command return_stdout matcher with regexp', 'cat /etc/resolv.conf', /localhost/ +describe command('cat /etc/resolv.conf') do + let(:stdout) { "nameserver 127.0.0.1\r\n" } + it { should return_stdout("nameserver 127.0.0.1") } + its(:command) { should eq 'cat /etc/resolv.conf' } +end - it_behaves_like 'support command return_stderr matcher', 'cat /foo', 'cat: /foo: No such file or directory' - it_behaves_like 'support command return_stderr matcher with regexp', 'cat /foo', /No such file or directory/ +describe 'complete matching of stdout' do + context command('cat /etc/resolv.conf') do + let(:stdout) { "foocontent-should-be-includedbar\r\n" } + it { should_not return_stdout('content-should-be-included') } + end +end - it_behaves_like 'support command return_exit_status matcher', 'ls /tmp', 0 +describe 'regexp matching of stdout' do + context command('cat /etc/resolv.conf') do + let(:stdout) { "nameserver 127.0.0.1\r\n" } + it { should return_stdout(/127\.0\.0\.1/) } + end +end + +describe command('cat /etc/resolv.conf') do + let(:stdout) { "No such file or directory\r\n" } + it { should return_stderr("No such file or directory") } + its(:command) { should eq 'cat /etc/resolv.conf' } +end + +describe 'complete matching of stderr' do + context command('cat /etc/resolv.conf') do + let(:stdout) { "No such file or directory\r\n" } + it { should_not return_stdout('file') } + end +end + +describe 'regexp matching of stderr' do + context command('cat /etc/resolv.conf') do + let(:stdout) { "No such file or directory\r\n" } + it { should return_stderr(/file/) } + end +end + +describe command('cat /etc/resolv.conf') do + it { should return_exit_status 0 } + its(:command) { should eq 'cat /etc/resolv.conf' } end