Skip to content

Commit

Permalink
Update tests to work with rspec-puppet 2.x
Browse files Browse the repository at this point in the history
Also enable future parser testing. Need to allow failures with future
parser for now since none of the published gems have the fix for
PUP-4379
  • Loading branch information
Morgan Haskel committed Apr 22, 2015
1 parent 6816f99 commit fff7022
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 52 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,16 @@ matrix:
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 4.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 4.0"
allow_failures:
- env: PUPPET_GEM_VERSION="~> 4.0"
- env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
notifications:
email: false
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
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 'rspec-puppet', '~> 2.0', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', :require => false
gem 'simplecov', :require => false
Expand Down
18 changes: 9 additions & 9 deletions spec/classes/apt_backports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/)
end
end
Expand All @@ -156,7 +156,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/)
end
end
Expand All @@ -170,7 +170,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/)
end
end
Expand All @@ -184,7 +184,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/)
end
end
Expand All @@ -205,7 +205,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /is not a string/)
end
end
Expand All @@ -217,7 +217,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /is not a string/)
end
end
Expand All @@ -229,7 +229,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /is not a string/)
end
end
Expand All @@ -241,7 +241,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /is not a string/)
end
end
Expand All @@ -253,7 +253,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /pin must be either a string, number or hash/)
end
end
Expand Down
14 changes: 7 additions & 7 deletions spec/classes/apt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
}
end

it { is_expected.to contain_file('sources.list').without({
:content => "# Repos managed by puppet.\n",
it { is_expected.to contain_file('sources.list').with({
:content => nil,
})}

it { is_expected.to contain_file('sources.list.d').with({
Expand Down Expand Up @@ -230,7 +230,7 @@
let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error)
end
end
Expand All @@ -239,7 +239,7 @@
let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } }
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error)
end
end
Expand All @@ -248,7 +248,7 @@
let(:params) { { :purge => { 'preferences' => 'banana' }, } }
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error)
end
end
Expand All @@ -257,7 +257,7 @@
let(:params) { { :purge => { 'preferences.d' => 'banana' }, } }
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error)
end
end
Expand All @@ -269,7 +269,7 @@

it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/classes/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
# there should not be any more resources because it is a params class
# The resources are class[apt::params], class[main], class[settings], stage[main]
it "Should not contain any resources" do
expect(subject.resources.size).to eq(4)
expect(subject.call.resources.size).to eq(4)
end

describe "With lsb-release not installed" do
let(:facts) { { :lsbdistid => '', :osfamily => 'Debian' } }
let(:facts) { { :osfamily => 'Debian' } }
let (:title) { 'my_package' }

it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /Unable to determine lsbdistid, is lsb-release installed/)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/conf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
end

it 'fails' do
expect { subject } .to raise_error(/pass in content/)
expect { subject.call } .to raise_error(/pass in content/)
end
end

Expand Down
32 changes: 16 additions & 16 deletions spec/defines/key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
:server => '-pgp.mit.edu',
} end
it 'fails' do
expect { subject } .to raise_error(/does not match/)
expect { subject.call } .to raise_error(/does not match/)
end
end

Expand All @@ -152,7 +152,7 @@
:server => '.pgp.mit.edu',
} end
it 'fails' do
expect { subject } .to raise_error(/does not match/)
expect { subject.call } .to raise_error(/does not match/)
end
end

Expand All @@ -161,7 +161,7 @@
:server => "pgp.mit.edu.",
} end
it 'fails' do
expect { subject } .to raise_error(/does not match/)
expect { subject.call } .to raise_error(/does not match/)
end
end
context "exceed character url" do
Expand All @@ -171,7 +171,7 @@
}
end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
expect { subject.call }.to raise_error(/does not match/)
end
end
context "incorrect port number url" do
Expand All @@ -181,7 +181,7 @@
}
end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
expect { subject.call }.to raise_error(/does not match/)
end
end
context "incorrect protocol for url" do
Expand All @@ -191,7 +191,7 @@
}
end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
expect { subject.call }.to raise_error(/does not match/)
end
end
context "missing port number url" do
Expand All @@ -201,7 +201,7 @@
}
end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
expect { subject.call }.to raise_error(/does not match/)
end
end
context "url ending with a dot" do
Expand All @@ -211,23 +211,23 @@
}
end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
expect { subject.call }.to raise_error(/does not match/)
end
end
context "url begin with a dash" do
let(:params) do{
:server => "hkp://-pgp.mit.edu",
} end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
expect { subject.call }.to raise_error(/does not match/)
end
end
context 'invalid key' do
let :title do
'Out of rum. Why? Why are we out of rum?'
end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
expect { subject.call }.to raise_error(/does not match/)
end
end

Expand All @@ -236,7 +236,7 @@
:source => 'afp://puppetlabs.com/key.gpg',
} end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
expect { subject.call }.to raise_error(/does not match/)
end
end

Expand All @@ -245,7 +245,7 @@
:content => [],
} end
it 'fails' do
expect { subject }.to raise_error(/is not a string/)
expect { subject.call }.to raise_error(/is not a string/)
end
end

Expand All @@ -254,7 +254,7 @@
:server => 'two bottles of rum',
} end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
expect { subject.call }.to raise_error(/does not match/)
end
end

Expand All @@ -263,7 +263,7 @@
:options => {},
} end
it 'fails' do
expect { subject }.to raise_error(/is not a string/)
expect { subject.call }.to raise_error(/is not a string/)
end
end

Expand All @@ -274,7 +274,7 @@
}
end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
expect { subject.call }.to raise_error(/does not match/)
end
end

Expand Down Expand Up @@ -315,7 +315,7 @@
apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
end
it 'informs the user of the impossibility' do
expect { subject }.to raise_error(/already ensured as absent/)
expect { subject.call }.to raise_error(/already ensured as absent/)
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/defines/pin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /Only integers are allowed/)
end
end
Expand All @@ -93,7 +93,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
end
end
Expand All @@ -107,7 +107,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
end
end
Expand All @@ -122,7 +122,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
end
end
Expand All @@ -137,7 +137,7 @@
end
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/ppa_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
let(:title) { 'ppa:foo' }
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
end
end
Expand All @@ -297,7 +297,7 @@
let(:title) { 'ppa:foo' }
it do
expect {
is_expected.to compile
subject.call
}.to raise_error(Puppet::Error, /not currently supported on Debian/)
end
end
Expand Down
Loading

0 comments on commit fff7022

Please sign in to comment.