From 359d3619d95a771fdc3b3f7070b5b4cb3196155c Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 24 Sep 2014 11:21:48 -0700 Subject: [PATCH 01/15] lower constraints on rspec version --- Gemfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 297797f4f..3bba54017 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,10 @@ 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']}" : ['>= 2.9 ', '< 3.0.0'] gem 'rake' -gem 'rspec', rspecversion +# gem 'rspec', rspecversion +gem 'rspec' gem 'puppet', puppetversion gem 'pry', :group => :development From e97e03e2527b61f9809ae50d1c053c4364bce978 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 24 Sep 2014 11:21:48 -0700 Subject: [PATCH 02/15] lower constraints on rspec version --- Gemfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 297797f4f..3bba54017 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,10 @@ 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']}" : ['>= 2.9 ', '< 3.0.0'] gem 'rake' -gem 'rspec', rspecversion +# gem 'rspec', rspecversion +gem 'rspec' gem 'puppet', puppetversion gem 'pry', :group => :development From 4a6d93d4827d66ca9db834f198170e58ee3e63fd Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 24 Sep 2014 11:47:41 -0700 Subject: [PATCH 03/15] lower constraints in gemspec file too --- rspec-puppet.gemspec | 2 -- 1 file changed, 2 deletions(-) diff --git a/rspec-puppet.gemspec b/rspec-puppet.gemspec index 030a456b3..a383e98ab 100644 --- a/rspec-puppet.gemspec +++ b/rspec-puppet.gemspec @@ -10,8 +10,6 @@ Gem::Specification.new do |s| s.files = Dir['LICENSE.md', 'README.md', 'lib/**/*', 'bin/**/*'] - s.add_dependency 'rspec', '< 3.0.0' - s.authors = ['Tim Sharpe'] s.email = 'tim@sharpe.id.au' end From a8e99d825fb6286e0edb1cb0587601238baf3e68 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 24 Sep 2014 12:56:47 -0700 Subject: [PATCH 04/15] readd rspec dependency without version --- rspec-puppet.gemspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rspec-puppet.gemspec b/rspec-puppet.gemspec index a383e98ab..2462ab9c0 100644 --- a/rspec-puppet.gemspec +++ b/rspec-puppet.gemspec @@ -10,6 +10,8 @@ Gem::Specification.new do |s| s.files = Dir['LICENSE.md', 'README.md', 'lib/**/*', 'bin/**/*'] + s.add_dependency 'rspec' + s.authors = ['Tim Sharpe'] s.email = 'tim@sharpe.id.au' end From 7d337da60a6024c73846fb542412901f9e015924 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 24 Sep 2014 13:16:15 -0700 Subject: [PATCH 05/15] Fix deprecation warning on :example_group --- lib/rspec-puppet/example.rb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/rspec-puppet/example.rb b/lib/rspec-puppet/example.rb index 55f89a2b9..faada26a8 100644 --- a/lib/rspec-puppet/example.rb +++ b/lib/rspec-puppet/example.rb @@ -9,19 +9,11 @@ def c.escaped_path(*parts) Regexp.compile(parts.join('[\\\/]')) end - c.include RSpec::Puppet::DefineExampleGroup, :type => :define, :example_group => { - :file_path => c.escaped_path(%w[spec defines]) - } + c.include RSpec::Puppet::DefineExampleGroup, :type => :define, :file_path => c.escaped_path(%w[spec defines]) - c.include RSpec::Puppet::ClassExampleGroup, :type => :class, :example_group => { - :file_path => c.escaped_path(%w[spec classes]) - } + 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 => { - :file_path => c.escaped_path(%w[spec functions]) - } + 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 => { - :file_path => c.escaped_path(%w[spec hosts]) - } + c.include RSpec::Puppet::HostExampleGroup, :type => :host, :file_path => c.escaped_path(%w[spec hosts]) end From 5b3d10325902d5e6dbd8fed9888986568c1671f9 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 24 Sep 2014 13:28:04 -0700 Subject: [PATCH 06/15] fix failure_message deprecation warnings --- lib/rspec-puppet/matchers/compile.rb | 8 ++++++-- lib/rspec-puppet/matchers/count_generic.rb | 8 ++++++-- lib/rspec-puppet/matchers/create_generic.rb | 8 ++++++-- lib/rspec-puppet/matchers/include_class.rb | 2 +- lib/rspec-puppet/matchers/run.rb | 8 ++++++-- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/rspec-puppet/matchers/compile.rb b/lib/rspec-puppet/matchers/compile.rb index 527e3929e..0733fb250 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,10 +63,14 @@ 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 + # RSpec 2 compatibility: + alias_method :failure_message_for_should, :failure_message + alias_method :failure_message_for_should_not, :failure_message_when_negated + private def missing_dependencies? retval = false diff --git a/lib/rspec-puppet/matchers/count_generic.rb b/lib/rspec-puppet/matchers/count_generic.rb index c9ef18563..9f3f9d4d6 100644 --- a/lib/rspec-puppet/matchers/count_generic.rb +++ b/lib/rspec-puppet/matchers/count_generic.rb @@ -49,14 +49,18 @@ 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 + # RSpec 2 compatibility: + alias_method :failure_message_for_should, :failure_message + alias_method :failure_message_for_should_not, :failure_message_when_negated + private def referenced_type(type) diff --git a/lib/rspec-puppet/matchers/create_generic.rb b/lib/rspec-puppet/matchers/create_generic.rb index c38c12918..9a025a636 100644 --- a/lib/rspec-puppet/matchers/create_generic.rb +++ b/lib/rspec-puppet/matchers/create_generic.rb @@ -105,14 +105,18 @@ 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 + # RSpec 2 compatibility: + alias_method :failure_message_for_should, :failure_message + alias_method :failure_message_for_should_not, :failure_message_when_negated + def description values = [] value_str_prefix = "with" 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..a91103ffb 100644 --- a/lib/rspec-puppet/matchers/run.rb +++ b/lib/rspec-puppet/matchers/run.rb @@ -81,14 +81,18 @@ 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 + # RSpec 2 compatibility: + alias_method :failure_message_for_should, :failure_message + alias_method :failure_message_for_should_not, :failure_message_when_negated + def description "run #{func_name}(#{func_params}) and #{@desc}" end From 30897a8f2324788da14c1567c6fb8918fd4484e7 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 24 Sep 2014 13:44:04 -0700 Subject: [PATCH 07/15] limit RSpec 2 compatibility to Version 2 only --- lib/rspec-puppet/matchers/run.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/rspec-puppet/matchers/run.rb b/lib/rspec-puppet/matchers/run.rb index a91103ffb..b00c8cc61 100644 --- a/lib/rspec-puppet/matchers/run.rb +++ b/lib/rspec-puppet/matchers/run.rb @@ -89,9 +89,11 @@ def failure_message_when_negated failure_message_generic(:should_not, @func_obj) end - # RSpec 2 compatibility: - alias_method :failure_message_for_should, :failure_message - alias_method :failure_message_for_should_not, :failure_message_when_negated + if RSpec::Version::STRING < 3 + # RSpec 2 compatibility: + alias_method :failure_message_for_should, :failure_message + alias_method :failure_message_for_should_not, :failure_message_when_negated + end def description "run #{func_name}(#{func_params}) and #{@desc}" From 77d4ba87f588625ad049badacaa756474fd706d2 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 24 Sep 2014 13:44:04 -0700 Subject: [PATCH 08/15] limit RSpec 2 compatibility to Version 2 only --- lib/rspec-puppet/matchers/run.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/rspec-puppet/matchers/run.rb b/lib/rspec-puppet/matchers/run.rb index a91103ffb..aea267866 100644 --- a/lib/rspec-puppet/matchers/run.rb +++ b/lib/rspec-puppet/matchers/run.rb @@ -89,9 +89,11 @@ def failure_message_when_negated failure_message_generic(:should_not, @func_obj) end - # RSpec 2 compatibility: - alias_method :failure_message_for_should, :failure_message - alias_method :failure_message_for_should_not, :failure_message_when_negated + if RSpec::Version::STRING < '3' + # RSpec 2 compatibility: + alias_method :failure_message_for_should, :failure_message + alias_method :failure_message_for_should_not, :failure_message_when_negated + end def description "run #{func_name}(#{func_params}) and #{@desc}" From 353730838f7d4e90175df313fba61693b3916b00 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 24 Sep 2014 13:55:52 -0700 Subject: [PATCH 09/15] example_groups - enable rspec 2 and 3 --- lib/rspec-puppet/example.rb | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/rspec-puppet/example.rb b/lib/rspec-puppet/example.rb index faada26a8..0dd0c579f 100644 --- a/lib/rspec-puppet/example.rb +++ b/lib/rspec-puppet/example.rb @@ -9,11 +9,23 @@ def c.escaped_path(*parts) Regexp.compile(parts.join('[\\\/]')) end - c.include RSpec::Puppet::DefineExampleGroup, :type => :define, :file_path => c.escaped_path(%w[spec defines]) - - c.include RSpec::Puppet::ClassExampleGroup, :type => :class, :file_path => c.escaped_path(%w[spec classes]) - - c.include RSpec::Puppet::FunctionExampleGroup, :type => :puppet_function, :file_path => c.escaped_path(%w[spec functions]) - - c.include RSpec::Puppet::HostExampleGroup, :type => :host, :file_path => c.escaped_path(%w[spec hosts]) + if RSpec::Version::STRING < '3' + c.include RSpec::Puppet::DefineExampleGroup, :type => :define, :example_group => { + :file_path => c.escaped_path(%w[spec defines]) + } + c.include RSpec::Puppet::ClassExampleGroup, :type => :class, :example_group => { + :file_path => c.escaped_path(%w[spec classes]) + } + c.include RSpec::Puppet::FunctionExampleGroup, :type => :puppet_function, :example_group => { + :file_path => c.escaped_path(%w[spec functions]) + } + c.include RSpec::Puppet::HostExampleGroup, :type => :host, :example_group => { + :file_path => c.escaped_path(%w[spec hosts]) + } + else + c.include RSpec::Puppet::DefineExampleGroup, :type => :define, :file_path => c.escaped_path(%w[spec defines]) + c.include RSpec::Puppet::ClassExampleGroup, :type => :class, :file_path => c.escaped_path(%w[spec classes]) + c.include RSpec::Puppet::FunctionExampleGroup, :type => :puppet_function, :file_path => c.escaped_path(%w[spec functions]) + c.include RSpec::Puppet::HostExampleGroup, :type => :host, :file_path => c.escaped_path(%w[spec hosts]) + end end From 3beae4ddaa20df77f22eedcb70d192297a2e5ad6 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 24 Sep 2014 15:32:57 -0700 Subject: [PATCH 10/15] Keep env rspec_version in place to allow rspec version switch --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 83670e0cc..921479218 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,9 @@ source 'https://rubygems.org' puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7'] +rspecversion = ENV.key?('RSPEC_VERSION') ? "= #{ENV['RSPEC_VERSION']}" : ['>= 2.9'] gem 'rake' -gem 'rspec' +gem 'rspec', rspecversion gem 'puppet', puppetversion gem 'pry', :group => :development From dd8273dda8bb955af314a6971c24bbac82fbefad Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 24 Sep 2014 15:53:08 -0700 Subject: [PATCH 11/15] allow usage of older rspec versions also for deprecated matchers --- lib/rspec-puppet/matchers/include_class.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/rspec-puppet/matchers/include_class.rb b/lib/rspec-puppet/matchers/include_class.rb index 6b3c32a7f..0390e70c5 100644 --- a/lib/rspec-puppet/matchers/include_class.rb +++ b/lib/rspec-puppet/matchers/include_class.rb @@ -12,9 +12,17 @@ module ManifestMatchers "include Class[#{expected_class}]" end - failure_message do |actual| - "expected that the catalogue would include Class[#{expected_class}]" + if RSpec::Version::STRING < '3' + failure_message_for_should do |actual| + "expected that the catalogue would include Class[#{expected_class}]" + end + else + failure_message do |actual| + "expected that the catalogue would include Class[#{expected_class}]" + end end + end + end end From fe0b3446a1607db0184639e881c8e513a98c2c2c Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Thu, 25 Sep 2014 09:48:37 -0700 Subject: [PATCH 12/15] code deduplication move the rspec2 catcher to support.rb --- lib/rspec-puppet/matchers/compile.rb | 6 ------ lib/rspec-puppet/matchers/count_generic.rb | 6 ------ lib/rspec-puppet/matchers/create_generic.rb | 6 ------ lib/rspec-puppet/matchers/run.rb | 6 ------ lib/rspec-puppet/support.rb | 8 ++++++++ 5 files changed, 8 insertions(+), 24 deletions(-) diff --git a/lib/rspec-puppet/matchers/compile.rb b/lib/rspec-puppet/matchers/compile.rb index c5242229d..d1de54549 100644 --- a/lib/rspec-puppet/matchers/compile.rb +++ b/lib/rspec-puppet/matchers/compile.rb @@ -67,12 +67,6 @@ def failure_message_when_negated "expected that the catalogue would not compile but it does" end - if RSpec::Version::STRING < '3' - # RSpec 2 compatibility: - alias_method :failure_message_for_should, :failure_message - alias_method :failure_message_for_should_not, :failure_message_when_negated - end - private def missing_dependencies? retval = false diff --git a/lib/rspec-puppet/matchers/count_generic.rb b/lib/rspec-puppet/matchers/count_generic.rb index d4fd1f8f3..2d4e32776 100644 --- a/lib/rspec-puppet/matchers/count_generic.rb +++ b/lib/rspec-puppet/matchers/count_generic.rb @@ -57,12 +57,6 @@ def failure_message_when_negated "expected that the catalogue would not " + description + " but it does" end - if RSpec::Version::STRING < '3' - # RSpec 2 compatibility: - alias_method :failure_message_for_should, :failure_message - alias_method :failure_message_for_should_not, :failure_message_when_negated - end - private def referenced_type(type) diff --git a/lib/rspec-puppet/matchers/create_generic.rb b/lib/rspec-puppet/matchers/create_generic.rb index 37880f23e..af93426ed 100644 --- a/lib/rspec-puppet/matchers/create_generic.rb +++ b/lib/rspec-puppet/matchers/create_generic.rb @@ -113,12 +113,6 @@ def failure_message_when_negated "expected that the catalogue would not contain #{@referenced_type}[#{@title}]#{errors}" end - if RSpec::Version::STRING < '3' - # RSpec 2 compatibility: - alias_method :failure_message_for_should, :failure_message - alias_method :failure_message_for_should_not, :failure_message_when_negated - end - def description values = [] value_str_prefix = "with" diff --git a/lib/rspec-puppet/matchers/run.rb b/lib/rspec-puppet/matchers/run.rb index aea267866..8eb78ec0b 100644 --- a/lib/rspec-puppet/matchers/run.rb +++ b/lib/rspec-puppet/matchers/run.rb @@ -89,12 +89,6 @@ def failure_message_when_negated failure_message_generic(:should_not, @func_obj) end - if RSpec::Version::STRING < '3' - # RSpec 2 compatibility: - alias_method :failure_message_for_should, :failure_message - alias_method :failure_message_for_should_not, :failure_message_when_negated - end - def description "run #{func_name}(#{func_params}) and #{@desc}" end diff --git a/lib/rspec-puppet/support.rb b/lib/rspec-puppet/support.rb index 4eba9d88b..f5332fe62 100644 --- a/lib/rspec-puppet/support.rb +++ b/lib/rspec-puppet/support.rb @@ -198,5 +198,13 @@ def build_node(name, opts = {}) opts.merge!({:environment => node_environment}) Puppet::Node.new(name, opts) end + + def rspec_compatibility + if RSpec::Version::STRING < '3' + # RSpec 2 compatibility: + alias_method :failure_message_for_should, :failure_message + alias_method :failure_message_for_should_not, :failure_message_when_negated + end + end end end From 091d06fcc0fc5eda2421fe92b441c7173d6ab59f Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Sat, 27 Sep 2014 13:17:07 +0200 Subject: [PATCH 13/15] travis improvements - add newer ruby version - add new puppet version - add rspec2 - exclude new puppet on old ruby --- .travis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.travis.yml b/.travis.yml index 36eefe977..ffe2303ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ rvm: - 1.9.2 - 1.9.3 - 2.0.0 + - 2.1.2 notifications: email: - tim@github.com @@ -14,6 +15,8 @@ env: - PUPPET_VERSION=3.2.4 - PUPPET_VERSION=3.3.2 - PUPPET_VERSION=3.4.1 + - PUPPET_VERSION=3.5.1 + - RSPEC_VERSION=2.14 matrix: exclude: - rvm: 1.9.2 @@ -28,3 +31,15 @@ matrix: env: PUPPET_VERSION=3.0.2 - rvm: 2.0.0 env: PUPPET_VERSION=3.1.1 + - rvm: 2.1.2 + env: PUPPET_VERSION=2.6.18 + - rvm: 2.1.2 + env: PUPPET_VERSION=2.7.23 + - rvm: 2.1.2 + env: PUPPET_VERSION=3.0.2 + - rvm: 2.1.2 + env: PUPPET_VERSION=3.1.1 + - rvm: 2.1.2 + env: PUPPET_VERSION=3.2.4 + - rvm: 2.1.2 + env: PUPPET_VERSION=3.3.2 From 4ef6377d3af8be4c6604d96a19be1d715ad179dc Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Sat, 27 Sep 2014 13:26:39 +0200 Subject: [PATCH 14/15] travis: use latest puppet 3.4 version (3.4.3 instead of 3.4.1) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ffe2303ce..5117f8cbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ 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 - RSPEC_VERSION=2.14 matrix: From 65735faa38e730136603e69e56361612b3081908 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Sat, 27 Sep 2014 13:50:02 +0200 Subject: [PATCH 15/15] remove rspec deprecation warnings from spec tests --- spec/classes/sysctl_common_spec.rb | 18 +++++++++--------- spec/classes/test_classes_used_spec.rb | 4 ++-- spec/functions/catalogue_spec.rb | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/spec/classes/sysctl_common_spec.rb b/spec/classes/sysctl_common_spec.rb index 64941c596..682aaa517 100644 --- a/spec/classes/sysctl_common_spec.rb +++ b/spec/classes/sysctl_common_spec.rb @@ -7,11 +7,11 @@ 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 @@ -65,7 +65,7 @@ } 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_classes_used_spec.rb b/spec/classes/test_classes_used_spec.rb index c04f7243b..057511654 100644 --- a/spec/classes/test_classes_used_spec.rb +++ b/spec/classes/test_classes_used_spec.rb @@ -2,11 +2,11 @@ describe 'test::classes_used' do it { - RSpec.should receive(:deprecate).with(:include_class, :contain_class) + expect(RSpec).to receive(:deprecate).with(:include_class, :contain_class) should include_class('test::bare_class') } it { - RSpec.should receive(:deprecate).with(:include_class, :contain_class) + expect(RSpec).to receive(:deprecate).with(:include_class, :contain_class) should include_class('test::parameterised_class') } diff --git a/spec/functions/catalogue_spec.rb b/spec/functions/catalogue_spec.rb index 6ba6071dd..533d6018c 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']) post_id = catalogue.object_id - pre_id.should eq post_id + expect(pre_id).to eq post_id end end end