Skip to content

Commit

Permalink
Update tests for rspec-puppet 2.0
Browse files Browse the repository at this point in the history
This patch:
 - changes the raise_error matcher and the resource inspection to use
   `catalogue` instead of `subject` since `subject` since `subject` is
   not evaluated the way it used to be
 - changes `should compile` to `catalogue` in other raise_error
   matchers to be consistent
 - changes the resource count to use an rspec-puppet method instead of
   inspecting the subject and adjusting for meta resources
 - unpins rspec-puppet
  • Loading branch information
Colleen Murphy committed Mar 24, 2015
1 parent 7dde9fc commit 6314dec
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 18 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org"
group :development, :unit_tests do
gem 'rake', :require => false
gem 'rspec-core', '3.1.7', :require => false
gem 'rspec-puppet', '~> 1.0', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', :require => false
gem 'simplecov', :require => false
Expand Down
6 changes: 3 additions & 3 deletions spec/classes/apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
let :params do
{ :mpm_module => 'breakme' }
end
it { expect { subject }.to raise_error Puppet::Error, /does not match/ }
it { expect { catalogue }.to raise_error Puppet::Error, /does not match/ }
end
end

Expand Down Expand Up @@ -561,7 +561,7 @@
end
it "should fail" do
expect do
subject
catalogue
end.to raise_error(Puppet::Error, /"foo" does not match/)
end
end
Expand Down Expand Up @@ -794,7 +794,7 @@

it do
expect {
should compile
catalogue
}.to raise_error(Puppet::Error, /Unsupported osfamily/)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/mod/fcgid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
} end

it 'should contain the correct config' do
content = subject.resource('file', 'fcgid.conf').send(:parameters)[:content]
content = catalogue.resource('file', 'fcgid.conf').send(:parameters)[:content]
expect(content.split("\n").reject { |c| c =~ /(^#|^$)/ }).to eq([
'<IfModule mod_fcgid.c>',
' AddHandler fcgid-script .fcgi',
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/mod/peruser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
end
it do
expect {
should compile
catalogue
}.to raise_error(Puppet::Error, /Unsupported osfamily FreeBSD/)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/mod/ssl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:is_pe => false,
}
end
it { expect { subject }.to raise_error(Puppet::Error, /Unsupported osfamily:/) }
it { expect { catalogue }.to raise_error(Puppet::Error, /Unsupported osfamily:/) }
end

context 'on a RedHat OS' do
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/mod/wsgi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@
:mod_path => '/foo/bar/baz',
}
end
it { expect { subject }.to raise_error Puppet::Error, /apache::mod::wsgi - both package_name and mod_path must be specified!/ }
it { expect { catalogue }.to raise_error Puppet::Error, /apache::mod::wsgi - both package_name and mod_path must be specified!/ }
end
describe "with mod_path but no package_name" do
let :params do
{
:package_name => '/foo/bar/baz',
}
end
it { expect { subject }.to raise_error Puppet::Error, /apache::mod::wsgi - both package_name and mod_path must be specified!/ }
it { expect { catalogue }.to raise_error Puppet::Error, /apache::mod::wsgi - both package_name and mod_path must be specified!/ }
end
end
context "on a FreeBSD OS" do
Expand Down
5 changes: 1 addition & 4 deletions spec/classes/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
end
it { is_expected.to contain_apache__params }

# There are 4 resources in this class currently
# there should not be any more resources because it is a params class
# The resources are class[apache::version], class[apache::params], class[main], class[settings], stage[main]
it "Should not contain any resources" do
expect(subject.resources.size).to eq(5)
should have_resource_count(0)
end
end
end
4 changes: 2 additions & 2 deletions spec/classes/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@
let (:params) {{ :service_enable => 'not-a-boolean' }}

it 'should fail' do
expect { subject }.to raise_error(Puppet::Error, /is not a boolean/)
expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/)
end
end

context "$service_manage must be a bool" do
let (:params) {{ :service_manage => 'not-a-boolean' }}

it 'should fail' do
expect { subject }.to raise_error(Puppet::Error, /is not a boolean/)
expect { catalogue }.to raise_error(Puppet::Error, /is not a boolean/)
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/defines/custom_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@
end
it do
expect {
should compile
catalogue
}.to raise_error(Puppet::Error, /Only one of \$content and \$source can be specified\./)
end
end
context 'neither content nor source' do
it do
expect {
should compile
catalogue
}.to raise_error(Puppet::Error, /One of \$content and \$source must be specified\./)
end
end
Expand All @@ -130,7 +130,7 @@
end
it do
expect {
should compile
catalogue
}.to raise_error(Puppet::Error, /is not supported for ensure/)
end
end
Expand Down

0 comments on commit 6314dec

Please sign in to comment.