From c953fc4a9b95fab16856bbd0dad512b2030e7718 Mon Sep 17 00:00:00 2001 From: Guillaume Virlet Date: Wed, 4 Jun 2014 18:58:23 +0200 Subject: [PATCH 1/6] Convert specs to RSpec 2.99.0 syntax with Transpec This conversion is done by Transpec 2.2.1 with the following command: transpec * 58 conversions from: it { should ... } to: it { is_expected.to ... } * 21 conversions from: obj.should to: expect(obj).to * 11 conversions from: be_false to: be_falsey * 6 conversions from: be_true to: be_truthy * 6 conversions from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions --- spec/classes/array_spec.rb | 8 +++--- spec/classes/boolean_regexp_spec.rb | 6 ++-- spec/classes/boolean_spec.rb | 2 +- spec/classes/cycle_bad_spec.rb | 2 +- spec/classes/cycle_good_spec.rb | 2 +- spec/classes/escape_spec.rb | 2 +- spec/classes/hash_spec.rb | 8 +++--- spec/classes/relationship__before_spec.rb | 20 ++++++------- spec/classes/relationship__notify_spec.rb | 20 ++++++------- spec/classes/sysctl_common_spec.rb | 34 +++++++++++------------ spec/classes/test_api.rb | 6 ++-- spec/classes/test_classes_used_spec.rb | 12 ++++---- spec/classes/test_compile_error_spec.rb | 2 +- spec/classes/test_fail_spec.rb | 2 +- spec/defines/escape_def_spec.rb | 2 +- spec/defines/sysctl_before_spec.rb | 6 ++-- spec/defines/sysctl_spec.rb | 6 ++-- spec/defines/test_api.rb | 4 +-- spec/functions/catalogue_spec.rb | 8 +++--- spec/functions/regsubst_spec.rb | 8 +++--- spec/functions/split_spec.rb | 10 +++---- spec/hosts/array_spec.rb | 2 +- spec/hosts/bad_dep_host_spec.rb | 2 +- spec/hosts/foo_spec.rb | 4 +-- spec/hosts/good_dep_host_spec.rb | 2 +- spec/hosts/test_api.rb | 4 +-- spec/hosts/testhost_spec.rb | 6 ++-- 27 files changed, 95 insertions(+), 95 deletions(-) diff --git a/spec/classes/array_spec.rb b/spec/classes/array_spec.rb index adfcd4be7..0babe2d6d 100644 --- a/spec/classes/array_spec.rb +++ b/spec/classes/array_spec.rb @@ -7,7 +7,7 @@ end it { - should contain_structured_data__def('thing').with( + is_expected.to contain_structured_data__def('thing').with( { 'data' => ['foo', 'bar', 'baz', 'quux'] } ) } @@ -19,7 +19,7 @@ end it { - should contain_structured_data__def('thing').with( + is_expected.to contain_structured_data__def('thing').with( { 'data' => ['first', 1, 'second', 2] } ) } @@ -42,7 +42,7 @@ # we're still handling numeric values correctly. describe 'on Puppet 2.6', :if => Puppet.version =~ /^2\.6/ do it { - should contain_structured_data__def('thing').with( + is_expected.to contain_structured_data__def('thing').with( { 'data' => [ 'first', 'second', @@ -58,7 +58,7 @@ describe 'on Puppet 2.7 and later', :unless => Puppet.version =~ /^2\.6/ do it { - should contain_structured_data__def('thing').with( + is_expected.to contain_structured_data__def('thing').with( { 'data' => [ 'first', 'second', diff --git a/spec/classes/boolean_regexp_spec.rb b/spec/classes/boolean_regexp_spec.rb index 667882bc7..9ca3351af 100644 --- a/spec/classes/boolean_regexp_spec.rb +++ b/spec/classes/boolean_regexp_spec.rb @@ -5,9 +5,9 @@ let(:params) { { :bool => false } } let(:message_re) { /bool is false/ } - it { should create_notify("bool testing").with_message(message_re) } + it { is_expected.to create_notify("bool testing").with_message(message_re) } # `should_not with_messsage` == `should without_message` - it { should_not create_notify("bool testing").with_message(/true/) } - it { should create_notify("bool testing").without_message(/true/) } + it { is_expected.not_to create_notify("bool testing").with_message(/true/) } + it { is_expected.to create_notify("bool testing").without_message(/true/) } end diff --git a/spec/classes/boolean_spec.rb b/spec/classes/boolean_spec.rb index 62ce23946..f99196121 100644 --- a/spec/classes/boolean_spec.rb +++ b/spec/classes/boolean_spec.rb @@ -5,7 +5,7 @@ let(:title) { 'bool.testing' } let(:params) { { :bool => false } } - it { should create_notify("bool testing")\ + it { is_expected.to create_notify("bool testing")\ .with_message("This will print when \$bool is false.") } end end diff --git a/spec/classes/cycle_bad_spec.rb b/spec/classes/cycle_bad_spec.rb index 451c267e4..573def451 100644 --- a/spec/classes/cycle_bad_spec.rb +++ b/spec/classes/cycle_bad_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' describe 'cycle::bad' do - it { should_not compile } + it { is_expected.not_to compile } end diff --git a/spec/classes/cycle_good_spec.rb b/spec/classes/cycle_good_spec.rb index 375cdfd2b..a7e96b091 100644 --- a/spec/classes/cycle_good_spec.rb +++ b/spec/classes/cycle_good_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' describe 'cycle::good' do - it { should compile } + it { is_expected.to compile } end diff --git a/spec/classes/escape_spec.rb b/spec/classes/escape_spec.rb index 37398b724..593aa70b2 100644 --- a/spec/classes/escape_spec.rb +++ b/spec/classes/escape_spec.rb @@ -3,5 +3,5 @@ describe 'escape' do let(:params) { { :content => '$MSG foo' } } - it { should contain_file('/tmp/escape').with_content(/\$MSG foo/) } + it { is_expected.to contain_file('/tmp/escape').with_content(/\$MSG foo/) } end diff --git a/spec/classes/hash_spec.rb b/spec/classes/hash_spec.rb index 2aca720ca..599ec3645 100644 --- a/spec/classes/hash_spec.rb +++ b/spec/classes/hash_spec.rb @@ -7,7 +7,7 @@ end it { - should contain_structured_data__def('thing').with( + is_expected.to contain_structured_data__def('thing').with( {'data' => {'foo' => 'bar', 'baz' => 'quux'}} ) } @@ -19,7 +19,7 @@ end it { - should contain_structured_data__def('thing').with( + is_expected.to contain_structured_data__def('thing').with( { 'data' => {1 => 'uno', 2 => 'dos'}} ) } @@ -31,7 +31,7 @@ end it { - should contain_structured_data__def('thing').with( + is_expected.to contain_structured_data__def('thing').with( { 'data' => {'first' => 1, 'second' => 2}} ) } @@ -51,7 +51,7 @@ end it { - should contain_structured_data__def('thing').with( + is_expected.to contain_structured_data__def('thing').with( { 'data' => { 'first' => 1, 'second' => 2, diff --git a/spec/classes/relationship__before_spec.rb b/spec/classes/relationship__before_spec.rb index 2357f6f88..11c316808 100644 --- a/spec/classes/relationship__before_spec.rb +++ b/spec/classes/relationship__before_spec.rb @@ -1,17 +1,17 @@ require 'spec_helper' describe 'relationships::before' do - it { should contain_notify('foo').that_comes_before('Notify[bar]') } - it { should contain_notify('foo').that_comes_before('Notify[baz]') } - it { should contain_notify('bar').that_comes_before('Notify[baz]') } + it { is_expected.to contain_notify('foo').that_comes_before('Notify[bar]') } + it { is_expected.to contain_notify('foo').that_comes_before('Notify[baz]') } + it { is_expected.to contain_notify('bar').that_comes_before('Notify[baz]') } - it { should contain_notify('bar').that_requires('Notify[foo]') } - it { should contain_notify('baz').that_requires('Notify[foo]') } - it { should contain_notify('baz').that_requires('Notify[bar]') } + it { is_expected.to contain_notify('bar').that_requires('Notify[foo]') } + it { is_expected.to contain_notify('baz').that_requires('Notify[foo]') } + it { is_expected.to contain_notify('baz').that_requires('Notify[bar]') } - it { should contain_notify('foo').that_comes_before(['Notify[bar]','Notify[baz]']) } - it { should contain_notify('bar').that_comes_before(['Notify[baz]']) } + it { is_expected.to contain_notify('foo').that_comes_before(['Notify[bar]','Notify[baz]']) } + it { is_expected.to contain_notify('bar').that_comes_before(['Notify[baz]']) } - it { should contain_notify('bar').that_requires(['Notify[foo]']) } - it { should contain_notify('baz').that_requires(['Notify[foo]','Notify[bar]']) } + it { is_expected.to contain_notify('bar').that_requires(['Notify[foo]']) } + it { is_expected.to contain_notify('baz').that_requires(['Notify[foo]','Notify[bar]']) } end diff --git a/spec/classes/relationship__notify_spec.rb b/spec/classes/relationship__notify_spec.rb index ad100bf75..97f9af6a6 100644 --- a/spec/classes/relationship__notify_spec.rb +++ b/spec/classes/relationship__notify_spec.rb @@ -1,17 +1,17 @@ require 'spec_helper' describe 'relationships::notify' do - it { should contain_notify('foo').that_notifies('Notify[bar]') } - it { should contain_notify('baz').that_notifies('Notify[bar]') } - it { should contain_notify('baz').that_notifies('Notify[gronk]') } + it { is_expected.to contain_notify('foo').that_notifies('Notify[bar]') } + it { is_expected.to contain_notify('baz').that_notifies('Notify[bar]') } + it { is_expected.to contain_notify('baz').that_notifies('Notify[gronk]') } - it { should contain_notify('gronk').that_subscribes_to('Notify[baz]') } - it { should contain_notify('bar').that_subscribes_to('Notify[baz]') } - it { should contain_notify('bar').that_subscribes_to('Notify[foo]') } + it { is_expected.to contain_notify('gronk').that_subscribes_to('Notify[baz]') } + it { is_expected.to contain_notify('bar').that_subscribes_to('Notify[baz]') } + it { is_expected.to contain_notify('bar').that_subscribes_to('Notify[foo]') } - it { should contain_notify('foo').that_notifies(['Notify[bar]']) } - it { should contain_notify('baz').that_notifies(['Notify[bar]','Notify[gronk]']) } + it { is_expected.to contain_notify('foo').that_notifies(['Notify[bar]']) } + it { is_expected.to contain_notify('baz').that_notifies(['Notify[bar]','Notify[gronk]']) } - it { should contain_notify('gronk').that_subscribes_to(['Notify[baz]']) } - it { should contain_notify('bar').that_subscribes_to(['Notify[baz]','Notify[foo]']) } + it { is_expected.to contain_notify('gronk').that_subscribes_to(['Notify[baz]']) } + it { is_expected.to contain_notify('bar').that_subscribes_to(['Notify[baz]','Notify[foo]']) } end diff --git a/spec/classes/sysctl_common_spec.rb b/spec/classes/sysctl_common_spec.rb index 64941c596..31cf26104 100644 --- a/spec/classes/sysctl_common_spec.rb +++ b/spec/classes/sysctl_common_spec.rb @@ -1,17 +1,17 @@ require 'spec_helper' describe 'sysctl::common' do - it { should contain_exec('sysctl/reload') \ + it { is_expected.to contain_exec('sysctl/reload') \ .with_command('/sbin/sysctl -p /etc/sysctl.conf').with_returns([0, 2]) } - it { should_not create_augeas('foo') } + it { is_expected.not_to create_augeas('foo') } describe 'when using with to specify a hash of parameters' do it 'should fail if the parameter is not contained in the resource' do expect do - subject.should contain_exec('sysctl/reload').with('foo' => 'bar') + expect(subject).to contain_exec('sysctl/reload').with('foo' => 'bar') end.to raise_error(RSpec::Expectations::ExpectationNotMetError) end it 'should pass if the parameters are contained in the resource' do - subject.should contain_exec('sysctl/reload').with( + expect(subject).to contain_exec('sysctl/reload').with( 'refreshonly' => 'true', 'returns' => [0, 2] ) @@ -19,24 +19,24 @@ end describe 'when using without to specify parameter name(s)' do it 'should pass if the parameter name is not contained in the resource' do - subject.should contain_exec('sysctl/reload').without('foo') + expect(subject).to contain_exec('sysctl/reload').without('foo') end it 'should pass if the parameter names are not contained in the resource' do - subject.should contain_exec('sysctl/reload').without(['foo', 'bar']) + expect(subject).to contain_exec('sysctl/reload').without(['foo', 'bar']) end it 'should fail if any of the parameter names are contained in the resource' do expect do - subject.should contain_exec('sysctl/reload').without(['foo', 'returns']) + expect(subject).to contain_exec('sysctl/reload').without(['foo', 'returns']) end.to raise_error(RSpec::Expectations::ExpectationNotMetError) end end describe 'when using without to specify parameter value(s)' do it 'should pass if the parameter value is not contained in the resource' do - subject.should contain_exec('sysctl/reload').without_refreshonly('false') + expect(subject).to contain_exec('sysctl/reload').without_refreshonly('false') end it 'should fail if the parameter value is contained in the resource' do expect do - subject.should contain_exec('sysctl/reload').without_refreshonly('true') + expect(subject).to contain_exec('sysctl/reload').without_refreshonly('true') end.to raise_error(RSpec::Expectations::ExpectationNotMetError) end end @@ -45,27 +45,27 @@ describe 'sysctl::common' do let(:params) { { :test_param => "yes" } } - it { should create_class("sysctl::common")\ + it { is_expected.to create_class("sysctl::common")\ .with_test_param("yes") } - it { should have_class_count(1) } - it { should have_exec_resource_count(1) } - it { should have_resource_count(2) } + it { is_expected.to have_class_count(1) } + it { is_expected.to have_exec_resource_count(1) } + it { is_expected.to have_resource_count(2) } end describe 'sysctl::common' do - it { should contain_exec('sysctl/reload').only_with( + it { is_expected.to contain_exec('sysctl/reload').only_with( :command => '/sbin/sysctl -p /etc/sysctl.conf', :refreshonly => true, :returns => [0, 2] )} - it { should contain_exec('sysctl/reload') \ + it { is_expected.to 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( + expect(subject).to contain_exec('sysctl/reload').only_with( :command => '/sbin/sysctl -p /etc/sysctl.conf', :returns => [0, 2] ) @@ -73,7 +73,7 @@ end it 'should fail if different parameters are contained in the resource' do expect do - subject.should contain_exec('sysctl/reload').only_with( + expect(subject).to contain_exec('sysctl/reload').only_with( :command => '/sbin/sysctl -p /etc/sysctl.conf', :refreshonly => true, :creates => '/tmp/bla' diff --git a/spec/classes/test_api.rb b/spec/classes/test_api.rb index 47a94f672..9de58b494 100644 --- a/spec/classes/test_api.rb +++ b/spec/classes/test_api.rb @@ -3,18 +3,18 @@ describe 'test::bare_class' do describe 'rspec group' do it 'should have a catalogue method' do - catalogue.should be_a(Puppet::Resource::Catalog) + expect(catalogue).to be_a(Puppet::Resource::Catalog) end it 'subject should return a catalogue' do - subject.should be_a(Puppet::Resource::Catalog) + expect(subject).to be_a(Puppet::Resource::Catalog) end describe 'derivative group' do subject { catalogue.resource('Notify', 'foo') } it 'can redefine subject' do - subject.should be_a(Puppet::Resource) + expect(subject).to be_a(Puppet::Resource) end end end diff --git a/spec/classes/test_classes_used_spec.rb b/spec/classes/test_classes_used_spec.rb index c04f7243b..880165f9e 100644 --- a/spec/classes/test_classes_used_spec.rb +++ b/spec/classes/test_classes_used_spec.rb @@ -2,14 +2,14 @@ describe 'test::classes_used' do it { - RSpec.should receive(:deprecate).with(:include_class, :contain_class) - should include_class('test::bare_class') + expect(RSpec).to receive(:deprecate).with(:include_class, :contain_class) + is_expected.to include_class('test::bare_class') } it { - RSpec.should receive(:deprecate).with(:include_class, :contain_class) - should include_class('test::parameterised_class') + expect(RSpec).to receive(:deprecate).with(:include_class, :contain_class) + is_expected.to include_class('test::parameterised_class') } - it { should contain_class('test::parameterised_class').with_text('bar') } - it { should contain_class('test::bare_class') } + it { is_expected.to contain_class('test::parameterised_class').with_text('bar') } + it { is_expected.to contain_class('test::bare_class') } end diff --git a/spec/classes/test_compile_error_spec.rb b/spec/classes/test_compile_error_spec.rb index 39166392e..7ae88e85b 100644 --- a/spec/classes/test_compile_error_spec.rb +++ b/spec/classes/test_compile_error_spec.rb @@ -2,6 +2,6 @@ describe 'test::compile_error' do it 'should provide a useful message when compilation fails' do - should compile.with_all_deps.and_raise_error(/Parameter managehome failed/) + is_expected.to compile.with_all_deps.and_raise_error(/Parameter managehome failed/) end end diff --git a/spec/classes/test_fail_spec.rb b/spec/classes/test_fail_spec.rb index c3cbd69c3..0da71f7bd 100644 --- a/spec/classes/test_fail_spec.rb +++ b/spec/classes/test_fail_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' describe 'test::fail' do - it { should compile.and_raise_error(/test/) } + it { is_expected.to compile.and_raise_error(/test/) } end diff --git a/spec/defines/escape_def_spec.rb b/spec/defines/escape_def_spec.rb index 389d5ccfd..cfd966be0 100644 --- a/spec/defines/escape_def_spec.rb +++ b/spec/defines/escape_def_spec.rb @@ -4,5 +4,5 @@ let(:title) { '/tmp/bla' } let(:params) { {:content => 'bar $BLA'} } - it { should contain_file('/tmp/bla').with_content(/bar \$BLA/) } + it { is_expected.to contain_file('/tmp/bla').with_content(/bar \$BLA/) } end diff --git a/spec/defines/sysctl_before_spec.rb b/spec/defines/sysctl_before_spec.rb index cdc4cf62f..6e8917850 100644 --- a/spec/defines/sysctl_before_spec.rb +++ b/spec/defines/sysctl_before_spec.rb @@ -5,7 +5,7 @@ let(:params) { { :value => "title" } } it "Should raise an error about needing the sysctl::common class" do - expect { should create_notify("message-title")\ + expect { is_expected.to create_notify("message-title")\ .with_message("This should print if the class is here first.") }\ .to raise_error(Puppet::Error, /Could not find resource 'Class\[Sysctl::Common\]/) end @@ -18,8 +18,8 @@ 'class {"sysctl::common":}' ] } let(:params) { { :value => "title" } } - it { should create_sysctl__before('test define').with_value("title") } + it { is_expected.to create_sysctl__before('test define').with_value("title") } - it { should contain_class("sysctl::common") } + it { is_expected.to contain_class("sysctl::common") } end diff --git a/spec/defines/sysctl_spec.rb b/spec/defines/sysctl_spec.rb index 922b97ea2..be2d42637 100644 --- a/spec/defines/sysctl_spec.rb +++ b/spec/defines/sysctl_spec.rb @@ -9,13 +9,13 @@ let(:params) { {:value => '60'} } let(:pre_condition) { } - it { should contain_class('sysctl::common') } - it { should create_augeas('sysctl/vm.swappiness') \ + it { is_expected.to contain_class('sysctl::common') } + it { is_expected.to create_augeas('sysctl/vm.swappiness') \ .with_context('/files/etc/sysctl.conf') \ .with_changes("set vm.swappiness '60'") \ .with_changes(nodoublequotes) \ .with_onlyif("match vm.swappiness[.='60'] size == 0") \ .with_notify('Exec[sysctl/reload]')\ .without_foo } - it { should have_sysctl_resource_count(1) } + it { is_expected.to have_sysctl_resource_count(1) } end diff --git a/spec/defines/test_api.rb b/spec/defines/test_api.rb index 3448749e4..ac48cc416 100644 --- a/spec/defines/test_api.rb +++ b/spec/defines/test_api.rb @@ -6,11 +6,11 @@ describe 'rspec group' do it 'should have a catalogue method' do - catalogue.should be_a(Puppet::Resource::Catalog) + expect(catalogue).to be_a(Puppet::Resource::Catalog) end it 'subject should return a catalogue' do - subject.should be_a(Puppet::Resource::Catalog) + expect(subject).to be_a(Puppet::Resource::Catalog) end end end diff --git a/spec/functions/catalogue_spec.rb b/spec/functions/catalogue_spec.rb index 6ba6071dd..79aa6ac6f 100644 --- a/spec/functions/catalogue_spec.rb +++ b/spec/functions/catalogue_spec.rb @@ -3,18 +3,18 @@ describe 'split' do describe 'rspec group' do it 'should have a catalogue method' do - catalogue.should be_a(Puppet::Resource::Catalog) + expect(catalogue).to be_a(Puppet::Resource::Catalog) end it 'catalogue should not change after subject is called' do - catalogue.should be_a(Puppet::Resource::Catalog) + expect(catalogue).to be_a(Puppet::Resource::Catalog) pre_id = catalogue.object_id - should run.with_params('aoeu', 'o').and_return(['a', 'eu']) + is_expected.to run.with_params('aoeu', 'o').and_return(['a', 'eu']) post_id = catalogue.object_id - pre_id.should eq post_id + expect(pre_id).to eq post_id end end end diff --git a/spec/functions/regsubst_spec.rb b/spec/functions/regsubst_spec.rb index 55387055e..d97a3b1c6 100644 --- a/spec/functions/regsubst_spec.rb +++ b/spec/functions/regsubst_spec.rb @@ -2,8 +2,8 @@ describe 'regsubst' do # used to test the fact that expected result can be a regexp - it { should run.with_params('thisisatest', '^192', '254').and_return(/sat/) } - it { should run.with_params('thisisatest', 'sat', 'xyz').and_return(/ixyze/) } - it { should run.with_params('thisisatest', 'sat', 'xyz').and_return('thisixyzest') } - it { should run.with_params('thisisatest', 'sat', 'xyz').and_return(/^thisixyzest$/) } + it { is_expected.to run.with_params('thisisatest', '^192', '254').and_return(/sat/) } + it { is_expected.to run.with_params('thisisatest', 'sat', 'xyz').and_return(/ixyze/) } + it { is_expected.to run.with_params('thisisatest', 'sat', 'xyz').and_return('thisixyzest') } + it { is_expected.to run.with_params('thisisatest', 'sat', 'xyz').and_return(/^thisixyzest$/) } end diff --git a/spec/functions/split_spec.rb b/spec/functions/split_spec.rb index c7d149fd5..388ff7dd0 100644 --- a/spec/functions/split_spec.rb +++ b/spec/functions/split_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' describe 'split' do - it { should run.with_params('aoeu', 'o').and_return(['a', 'eu']) } - it { should_not run.with_params('foo').and_raise_error(Puppet::DevError) } + it { is_expected.to run.with_params('aoeu', 'o').and_return(['a', 'eu']) } + it { is_expected.not_to run.with_params('foo').and_raise_error(Puppet::DevError) } if (Puppet.version.split('.').map { |s| s.to_i } <=> [3, 1]) >= 0 expected_error = ArgumentError @@ -10,11 +10,11 @@ expected_error = Puppet::ParseError end - it { should run.with_params('foo').and_raise_error(expected_error) } + it { is_expected.to run.with_params('foo').and_raise_error(expected_error) } - it { should run.with_params('foo').and_raise_error(expected_error, /number of arguments/) } + it { is_expected.to run.with_params('foo').and_raise_error(expected_error, /number of arguments/) } - it { should run.with_params('foo').and_raise_error(/number of arguments/) } + it { is_expected.to run.with_params('foo').and_raise_error(/number of arguments/) } it 'should fail with one argument - match exception type' do expect { subject.call(['foo']) }.to raise_error(expected_error) diff --git a/spec/hosts/array_spec.rb b/spec/hosts/array_spec.rb index 9af7da0ac..f630a86a1 100644 --- a/spec/hosts/array_spec.rb +++ b/spec/hosts/array_spec.rb @@ -11,5 +11,5 @@ EOF } - it { should contain_foo('bar').with_param(['baz']) } + it { is_expected.to contain_foo('bar').with_param(['baz']) } end diff --git a/spec/hosts/bad_dep_host_spec.rb b/spec/hosts/bad_dep_host_spec.rb index f37f03c12..188993020 100644 --- a/spec/hosts/bad_dep_host_spec.rb +++ b/spec/hosts/bad_dep_host_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' describe 'bad_dep_host' do - it { should_not compile.with_all_deps } + it { is_expected.not_to compile.with_all_deps } end diff --git a/spec/hosts/foo_spec.rb b/spec/hosts/foo_spec.rb index 8ef3fda06..3d25338da 100644 --- a/spec/hosts/foo_spec.rb +++ b/spec/hosts/foo_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'foo.example.com' do - it { should_not contain_class('sysctl::common') } - it { should contain_notify('test') } + it { is_expected.not_to contain_class('sysctl::common') } + it { is_expected.to contain_notify('test') } end diff --git a/spec/hosts/good_dep_host_spec.rb b/spec/hosts/good_dep_host_spec.rb index a1743b999..bf3a767cd 100644 --- a/spec/hosts/good_dep_host_spec.rb +++ b/spec/hosts/good_dep_host_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' describe 'good_dep_host' do - it { should compile.with_all_deps } + it { is_expected.to compile.with_all_deps } end diff --git a/spec/hosts/test_api.rb b/spec/hosts/test_api.rb index fed12e516..6476b890e 100644 --- a/spec/hosts/test_api.rb +++ b/spec/hosts/test_api.rb @@ -3,11 +3,11 @@ describe 'foo.example.com' do describe 'rspec group' do it 'should have a catalogue method' do - catalogue.should be_a(Puppet::Resource::Catalog) + expect(catalogue).to be_a(Puppet::Resource::Catalog) end it 'subject should return a catalogue' do - subject.should be_a(Puppet::Resource::Catalog) + expect(subject).to be_a(Puppet::Resource::Catalog) end end end diff --git a/spec/hosts/testhost_spec.rb b/spec/hosts/testhost_spec.rb index 06f58e35a..4ec1e8c5e 100644 --- a/spec/hosts/testhost_spec.rb +++ b/spec/hosts/testhost_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' describe 'testhost' do - it { should contain_class('sysctl::common') } + it { is_expected.to contain_class('sysctl::common') } describe 'testhost_a' do let(:node) { 'testhost_a' } - it { should_not contain_class('sysctl::common') } - it { should contain_file('/tmp/a') } + it { is_expected.to_not contain_class('sysctl::common') } + it { is_expected.to contain_file('/tmp/a') } end end From 484d94bc542840b870046623780f915dee7b7926 Mon Sep 17 00:00:00 2001 From: Guillaume Virlet Date: Wed, 4 Jun 2014 21:30:58 +0200 Subject: [PATCH 2/6] migrate failure_message deprecation --- lib/rspec-puppet/matchers/compile.rb | 4 ++-- lib/rspec-puppet/matchers/count_generic.rb | 4 ++-- lib/rspec-puppet/matchers/create_generic.rb | 4 ++-- lib/rspec-puppet/matchers/include_class.rb | 2 +- lib/rspec-puppet/matchers/run.rb | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/rspec-puppet/matchers/compile.rb b/lib/rspec-puppet/matchers/compile.rb index 527e3929e..d1de54549 100644 --- a/lib/rspec-puppet/matchers/compile.rb +++ b/lib/rspec-puppet/matchers/compile.rb @@ -51,7 +51,7 @@ def description end end - def failure_message_for_should + def failure_message unless @cycles.empty? "dependency cycles found: #{@cycles.join('; ')}" else @@ -63,7 +63,7 @@ def failure_message_for_should end end - def failure_message_for_should_not + def failure_message_when_negated "expected that the catalogue would not compile but it does" end diff --git a/lib/rspec-puppet/matchers/count_generic.rb b/lib/rspec-puppet/matchers/count_generic.rb index c9ef18563..2d4e32776 100644 --- a/lib/rspec-puppet/matchers/count_generic.rb +++ b/lib/rspec-puppet/matchers/count_generic.rb @@ -49,11 +49,11 @@ def description desc.join(" ") end - def failure_message_for_should + def failure_message "expected that the catalogue would " + description + " but it contains #{@actual_number}" end - def failure_message_for_should_not + def failure_message_when_negated "expected that the catalogue would not " + description + " but it does" end diff --git a/lib/rspec-puppet/matchers/create_generic.rb b/lib/rspec-puppet/matchers/create_generic.rb index c38c12918..af93426ed 100644 --- a/lib/rspec-puppet/matchers/create_generic.rb +++ b/lib/rspec-puppet/matchers/create_generic.rb @@ -105,11 +105,11 @@ def matches?(catalogue) end end - def failure_message_for_should + def failure_message "expected that the catalogue would contain #{@referenced_type}[#{@title}]#{errors}" end - def failure_message_for_should_not + def failure_message_when_negated "expected that the catalogue would not contain #{@referenced_type}[#{@title}]#{errors}" end diff --git a/lib/rspec-puppet/matchers/include_class.rb b/lib/rspec-puppet/matchers/include_class.rb index 8c9a82246..6b3c32a7f 100644 --- a/lib/rspec-puppet/matchers/include_class.rb +++ b/lib/rspec-puppet/matchers/include_class.rb @@ -12,7 +12,7 @@ module ManifestMatchers "include Class[#{expected_class}]" end - failure_message_for_should do |actual| + failure_message do |actual| "expected that the catalogue would include Class[#{expected_class}]" end end diff --git a/lib/rspec-puppet/matchers/run.rb b/lib/rspec-puppet/matchers/run.rb index ed9cede58..8eb78ec0b 100644 --- a/lib/rspec-puppet/matchers/run.rb +++ b/lib/rspec-puppet/matchers/run.rb @@ -81,11 +81,11 @@ def and_raise_error(error_or_message, message=nil) self end - def failure_message_for_should + def failure_message failure_message_generic(:should, @func_obj) end - def failure_message_for_should_not + def failure_message_when_negated failure_message_generic(:should_not, @func_obj) end From dca78f54fc9d0f123569fd7d836dd0a853f8c4b6 Mon Sep 17 00:00:00 2001 From: Guillaume Virlet Date: Wed, 4 Jun 2014 21:45:42 +0200 Subject: [PATCH 3/6] migrate example_group key in and example metadata hash --- lib/rspec-puppet/example.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rspec-puppet/example.rb b/lib/rspec-puppet/example.rb index 55f89a2b9..c69cb17cb 100644 --- a/lib/rspec-puppet/example.rb +++ b/lib/rspec-puppet/example.rb @@ -9,19 +9,19 @@ def c.escaped_path(*parts) Regexp.compile(parts.join('[\\\/]')) end - c.include RSpec::Puppet::DefineExampleGroup, :type => :define, :example_group => { + c.include RSpec::Puppet::DefineExampleGroup, { :type => :define, :file_path => c.escaped_path(%w[spec defines]) } - c.include RSpec::Puppet::ClassExampleGroup, :type => :class, :example_group => { + c.include RSpec::Puppet::ClassExampleGroup, { :type => :class, :file_path => c.escaped_path(%w[spec classes]) } - c.include RSpec::Puppet::FunctionExampleGroup, :type => :puppet_function, :example_group => { + c.include RSpec::Puppet::FunctionExampleGroup, { :type => :puppet_function, :file_path => c.escaped_path(%w[spec functions]) } - c.include RSpec::Puppet::HostExampleGroup, :type => :host, :example_group => { + c.include RSpec::Puppet::HostExampleGroup, { :type => :host, :file_path => c.escaped_path(%w[spec hosts]) } end From 6b29485a72a4b89bd08355a3f7157dce78a6bcc3 Mon Sep 17 00:00:00 2001 From: Guillaume Virlet Date: Wed, 4 Jun 2014 23:11:02 +0200 Subject: [PATCH 4/6] add new travis test: ruby 2.1.1 + new version of puppet 3.5 and 3.6 (exclude unsupported combination) --- .travis.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 36eefe977..a2eeed134 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ rvm: - 1.9.2 - 1.9.3 - 2.0.0 + - 2.1.1 notifications: email: - tim@github.com @@ -13,7 +14,9 @@ env: - PUPPET_VERSION=3.1.1 - PUPPET_VERSION=3.2.4 - PUPPET_VERSION=3.3.2 - - PUPPET_VERSION=3.4.1 + - PUPPET_VERSION=3.4.3 + - PUPPET_VERSION=3.5.1 + - PUPPET_VERSION=3.6.1 matrix: exclude: - rvm: 1.9.2 @@ -28,3 +31,17 @@ matrix: env: PUPPET_VERSION=3.0.2 - rvm: 2.0.0 env: PUPPET_VERSION=3.1.1 + - rvm: 2.1.1 + env: PUPPET_VERSION=2.6.18 + - rvm: 2.1.1 + env: PUPPET_VERSION=2.7.23 + - rvm: 2.1.1 + env: PUPPET_VERSION=3.0.2 + - rvm: 2.1.1 + env: PUPPET_VERSION=3.1.1 + - rvm: 2.1.1 + env: PUPPET_VERSION=3.2.4 + - rvm: 2.1.1 + env: PUPPET_VERSION=3.3.2 + - rvm: 2.1.1 + env: PUPPET_VERSION=3.4.3 From cc5640a38a482a0aab4f89f5a3d23a2c7aea7cb2 Mon Sep 17 00:00:00 2001 From: Guillaume Virlet Date: Wed, 4 Jun 2014 23:22:17 +0200 Subject: [PATCH 5/6] update Gemfile to reflect new dependancy on rspec3 [skip ci] --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 297797f4f..57ea8e2b5 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7'] -rspecversion = ENV.key?('RSPEC_VERSION') ? "= #{ENV['RSPEC_VERSION']}" : ['>= 2.9 ', '< 3.0.0'] +rspecversion = ENV.key?('RSPEC_VERSION') ? "= #{ENV['RSPEC_VERSION']}" : ['>= 3.0'] gem 'rake' gem 'rspec', rspecversion From 858fb038d805f1b6354c3aa74983d925cbc95200 Mon Sep 17 00:00:00 2001 From: Guillaume Virlet Date: Mon, 9 Jun 2014 22:04:10 +0200 Subject: [PATCH 6/6] move from ruby 2.1.1 to ruby 2.1.2 for tests --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index a2eeed134..edf46bd5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ rvm: - 1.9.2 - 1.9.3 - 2.0.0 - - 2.1.1 + - 2.1.2 notifications: email: - tim@github.com @@ -31,17 +31,17 @@ matrix: env: PUPPET_VERSION=3.0.2 - rvm: 2.0.0 env: PUPPET_VERSION=3.1.1 - - rvm: 2.1.1 + - rvm: 2.1.2 env: PUPPET_VERSION=2.6.18 - - rvm: 2.1.1 + - rvm: 2.1.2 env: PUPPET_VERSION=2.7.23 - - rvm: 2.1.1 + - rvm: 2.1.2 env: PUPPET_VERSION=3.0.2 - - rvm: 2.1.1 + - rvm: 2.1.2 env: PUPPET_VERSION=3.1.1 - - rvm: 2.1.1 + - rvm: 2.1.2 env: PUPPET_VERSION=3.2.4 - - rvm: 2.1.1 + - rvm: 2.1.2 env: PUPPET_VERSION=3.3.2 - - rvm: 2.1.1 + - rvm: 2.1.2 env: PUPPET_VERSION=3.4.3