diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/acceptance/tests/create_spec.rb | 4 | ||||
-rw-r--r-- | spec/acceptance/tests/modify_spec.rb | 4 | ||||
-rw-r--r-- | spec/shared_behaviours/all_parsedfile_providers.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 20 | ||||
-rw-r--r-- | spec/unit/type/host_spec.rb | 8 |
5 files changed, 28 insertions, 10 deletions
diff --git a/spec/acceptance/tests/create_spec.rb b/spec/acceptance/tests/create_spec.rb index 40267fd..f79452d 100644 --- a/spec/acceptance/tests/create_spec.rb +++ b/spec/acceptance/tests/create_spec.rb @@ -13,7 +13,7 @@ RSpec.context 'when creating host files' do on(agent, puppet_resource('host', 'test', 'ensure=present', 'ip=127.0.0.1', "target=#{target}")) on(agent, "cat #{target}") do |result| - fail_test 'record was not present' if result.stdout !~ %r{^127\.0\.0\.1[[:space:]]+test} + fail_test 'record was not present' unless %r{^127\.0\.0\.1[[:space:]]+test}.match?(result.stdout) end end @@ -23,7 +23,7 @@ RSpec.context 'when creating host files' do on(agent, "cat #{target}") do |result| fail_test 'alias was missing' unless - result.stdout =~ %r{^127\.0\.0\.7[[:space:]]+test[[:space:]]alias} + %r{^127\.0\.0\.7[[:space:]]+test[[:space:]]alias}.match?(result.stdout) end end diff --git a/spec/acceptance/tests/modify_spec.rb b/spec/acceptance/tests/modify_spec.rb index 6498ee0..d07bb23 100644 --- a/spec/acceptance/tests/modify_spec.rb +++ b/spec/acceptance/tests/modify_spec.rb @@ -16,7 +16,7 @@ RSpec.context 'when modifying host files' do on(agent, "cat #{target}") do |result| fail_test 'the address was not updated' unless - result.stdout =~ %r{^127\.0\.0\.10[[:space:]]+test[[:space:]]+alias[[:space:]]*$} + %r{^127\.0\.0\.10[[:space:]]+test[[:space:]]+alias[[:space:]]*$}.match?(result.stdout) end end @@ -27,7 +27,7 @@ RSpec.context 'when modifying host files' do on(agent, "cat #{target}") do |result| fail_test 'the alias was not updated' unless - result.stdout =~ %r{^127\.0\.0\.8[[:space:]]+test[[:space:]]+banzai[[:space:]]*$} + %r{^127\.0\.0\.8[[:space:]]+test[[:space:]]+banzai[[:space:]]*$}.match?(result.stdout) end end end diff --git a/spec/shared_behaviours/all_parsedfile_providers.rb b/spec/shared_behaviours/all_parsedfile_providers.rb index 1701fe3..321cd86 100644 --- a/spec/shared_behaviours/all_parsedfile_providers.rb +++ b/spec/shared_behaviours/all_parsedfile_providers.rb @@ -4,7 +4,7 @@ shared_examples_for 'all parsedfile providers' do |provider, *files| end files.flatten.each do |file| - it "should rewrite #{file} reasonably unchanged" do + it "rewrites #{file} reasonably unchanged" do allow(provider).to receive(:default_target).and_return(file) provider.prefetch diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 29615cd..9b1fa6f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,9 @@ +# frozen_string_literal: true + +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' @@ -31,16 +37,28 @@ default_facts.each do |fact, value| end RSpec.configure do |c| - c.mock_with :rspec c.default_facts = default_facts c.before :each do # set to strictest setting for testing # by default Puppet runs at warning level Puppet.settings[:strict] = :warning + Puppet.settings[:strict_variables] = true end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do end + + # Filter backtrace noise + backtrace_exclusion_patterns = [ + %r{spec_helper}, + %r{gems}, + ] + + if c.respond_to?(:backtrace_exclusion_patterns) + c.backtrace_exclusion_patterns = backtrace_exclusion_patterns + elsif c.respond_to?(:backtrace_clean_patterns) + c.backtrace_clean_patterns = backtrace_exclusion_patterns + end end # Ensures that a module is defined diff --git a/spec/unit/type/host_spec.rb b/spec/unit/type/host_spec.rb index 54d9b75..3fa5985 100644 --- a/spec/unit/type/host_spec.rb +++ b/spec/unit/type/host_spec.rb @@ -12,13 +12,13 @@ describe Puppet::Type.type(:host) do describe 'when validating attributes' do [:name, :provider].each do |param| - it "should have a #{param} parameter" do + it "has a #{param} parameter" do expect(described_class.attrtype(param)).to eq(:param) end end [:ip, :target, :host_aliases, :comment, :ensure].each do |property| - it "should have a #{property} property" do + it "has a #{property} property" do expect(described_class.attrtype(property)).to eq(:property) end end @@ -256,7 +256,7 @@ describe Puppet::Type.type(:host) do '0:a:b:c:d:e:f::', '::0:a:b:c:d:e:f', # syntactically correct, but bad form (::0:... could be combined) 'a:b:c:d:e:f:0::'].each do |ip| - it "should accept #{ip.inspect} as an IPv6 address" do + it "accepts #{ip.inspect} as an IPv6 address" do expect { described_class.new(name: 'foo', ip: ip) }.not_to raise_error end end @@ -587,7 +587,7 @@ describe Puppet::Type.type(:host) do '1111::3333:4444:5555:6666:7777:8888:', '::3333:4444:5555:6666:7777:8888:', '::2222:3333:4444:5555:6666:7777:8888:'].each do |ip| - it "should reject #{ip.inspect} as an IPv6 address" do + it "rejects #{ip.inspect} as an IPv6 address" do expect { described_class.new(name: 'foo', ip: ip) }.to raise_error(Puppet::ResourceError, %r{Parameter ip failed}) end end |