Skip to content

Instantly share code, notes, and snippets.

@bastelfreak
Forked from danzilio/bad_foo_spec.rb
Created October 21, 2015 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bastelfreak/be20dc516224aeac8100 to your computer and use it in GitHub Desktop.
Save bastelfreak/be20dc516224aeac8100 to your computer and use it in GitHub Desktop.
Good vs Bad Tests
# This basically tests that Puppet works.
describe 'foo' do
let(:params) { :param => 'somevalue' }
it do
should contain_file('bar').with({
:ensure => present,
:owner => root,
:group => root,
:mode => 0644,
:content => 'somevalue'
})
end
end
# Better test
describe 'foo' do
let(:params) { :param => 'somevalue' }
it 'should contain the expected resources' do
should contain_file('bar').with_content(/^somevalue$/)
end
end
class foo (
$param = value,
) {
file { 'bar':
ensure => present,
owner => root,
group => root,
mode => 0644,
content => $param,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment