Skip to content

Commit

Permalink
Add some tests to assert an exact set of resource parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
willaerk committed Feb 11, 2013
1 parent a086d05 commit f22e412
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions spec/classes/sysctl_common_spec.rb
Expand Up @@ -38,3 +38,33 @@
it { should create_class("sysctl::common")\
.with_test_param("yes") }
end

describe 'sysctl::common' do
it { should contain_exec('sysctl/reload').only_with(
:command => '/sbin/sysctl -p /etc/sysctl.conf',
:refreshonly => true,
:returns => [0, 2]
)}
it { should contain_exec('sysctl/reload') \
.only_with_command('/sbin/sysctl -p /etc/sysctl.conf') \
.only_with_refreshonly(true) \
.only_with_returns([0, 2])
}
it 'should fail if not enough parameters are contained in the resource' do
expect do
subject.should contain_exec('sysctl/reload').only_with(
:command => '/sbin/sysctl -p /etc/sysctl.conf',
:returns => [0, 2]
)
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
end
it 'should fail if different parameters are contained in the resource' do
expect do
subject.should contain_exec('sysctl/reload').only_with(
:command => '/sbin/sysctl -p /etc/sysctl.conf',
:refreshonly => true,
:creates => '/tmp/bla'
)
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
end
end

0 comments on commit f22e412

Please sign in to comment.