From 75a35675cad0bc2fef03c74a5a3bcc28fff9f9d0 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Mon, 3 Oct 2016 14:11:44 +0100 Subject: Acceptance test cleanup --- spec/acceptance/validate_array_spec.rb | 16 ++++++++-------- spec/acceptance/validate_bool_spec.rb | 16 ++++++++-------- spec/acceptance/validate_hash_spec.rb | 16 ++++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) (limited to 'spec') diff --git a/spec/acceptance/validate_array_spec.rb b/spec/acceptance/validate_array_spec.rb index b53e98c..2f549d5 100755 --- a/spec/acceptance/validate_array_spec.rb +++ b/spec/acceptance/validate_array_spec.rb @@ -20,14 +20,14 @@ describe 'validate_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fa apply_manifest(pp, :catch_failures => true) end - it 'validates a non-array' do - { - %{validate_array({'a' => 'hash' })} => "Hash", - %{validate_array('string')} => "String", - %{validate_array(false)} => "FalseClass", - %{validate_array(undef)} => "String" - }.each do |pp,type| - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) + [ + %{validate_array({'a' => 'hash' })}, + %{validate_array('string')}, + %{validate_array(false)}, + %{validate_array(undef)} + ].each do |pp| + it "rejects #{pp.inspect}" do + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/is not an Array\. It looks to be a/) end end end diff --git a/spec/acceptance/validate_bool_spec.rb b/spec/acceptance/validate_bool_spec.rb index c837f08..5c52d0f 100755 --- a/spec/acceptance/validate_bool_spec.rb +++ b/spec/acceptance/validate_bool_spec.rb @@ -20,14 +20,14 @@ describe 'validate_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fac apply_manifest(pp, :catch_failures => true) end - it 'validates a non-bool' do - { - %{validate_bool('true')} => "String", - %{validate_bool('false')} => "String", - %{validate_bool([true])} => "Array", - %{validate_bool(undef)} => "String", - }.each do |pp,type| - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) + [ + %{validate_bool('true')}, + %{validate_bool('false')}, + %{validate_bool([true])}, + %{validate_bool(undef)} + ].each do |pp| + it "rejects #{pp.inspect}" do + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/is not a boolean\. It looks to be a/) end end end diff --git a/spec/acceptance/validate_hash_spec.rb b/spec/acceptance/validate_hash_spec.rb index 52fb615..637df0a 100755 --- a/spec/acceptance/validate_hash_spec.rb +++ b/spec/acceptance/validate_hash_spec.rb @@ -20,14 +20,14 @@ describe 'validate_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fac apply_manifest(pp, :catch_failures => true) end - it 'validates a non-hash' do - { - %{validate_hash('{ "not" => "hash" }')} => "String", - %{validate_hash('string')} => "String", - %{validate_hash(["array"])} => "Array", - %{validate_hash(undef)} => "String", - }.each do |pp,type| - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) + [ + %{validate_hash('{ "not" => "hash" }')}, + %{validate_hash('string')}, + %{validate_hash(["array"])}, + %{validate_hash(undef)} + ].each do |pp| + it "rejects #{pp.inspect}" do + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(//) end end end -- cgit v1.2.3 From 8a8ebc4850abe4996056a2700a6a50ac7666a922 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Mon, 3 Oct 2016 14:12:32 +0100 Subject: Replace :context with :all in spec tests --- spec/functions/deprecation_spec.rb | 2 +- spec/functions/is_array_spec.rb | 2 +- spec/functions/is_bool_spec.rb | 2 +- spec/functions/is_float_spec.rb | 2 +- spec/functions/is_integer_spec.rb | 2 +- spec/functions/is_ip_address_spec.rb | 2 +- spec/functions/is_ipv4_address_spec.rb | 2 +- spec/functions/is_ipv6_address_spec.rb | 2 +- spec/functions/is_numeric_spec.rb | 2 +- spec/functions/is_string_spec.rb | 2 +- spec/functions/validate_absolute_path_spec.rb | 2 +- spec/functions/validate_array_spec.rb | 2 +- spec/functions/validate_bool_spec.rb | 2 +- spec/functions/validate_hash_spec.rb | 2 +- spec/functions/validate_integer_spec.rb | 2 +- spec/functions/validate_ip_address_spec.rb | 2 +- spec/functions/validate_ipv4_address_spec.rb | 2 +- spec/functions/validate_ipv6_address_spec.rb | 2 +- spec/functions/validate_numeric_spec.rb | 2 +- spec/functions/validate_re_spec.rb | 2 +- spec/functions/validate_slength_spec.rb | 2 +- spec/functions/validate_string_spec.rb | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) (limited to 'spec') diff --git a/spec/functions/deprecation_spec.rb b/spec/functions/deprecation_spec.rb index 4321c3d..9859833 100644 --- a/spec/functions/deprecation_spec.rb +++ b/spec/functions/deprecation_spec.rb @@ -42,7 +42,7 @@ if Puppet.version.to_f >= 4.0 end else describe 'deprecation' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end ENV['STDLIB_LOG_DEPRECATIONS'] = "true" diff --git a/spec/functions/is_array_spec.rb b/spec/functions/is_array_spec.rb index 2350b7f..e89f54b 100755 --- a/spec/functions/is_array_spec.rb +++ b/spec/functions/is_array_spec.rb @@ -18,7 +18,7 @@ describe 'is_array' do it { is_expected.to run.with_params(1).and_return(false) } it { is_expected.to run.with_params({}).and_return(false) } context 'Checking for deprecation warning' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning, which should only be provoked when the env variable for it is set. diff --git a/spec/functions/is_bool_spec.rb b/spec/functions/is_bool_spec.rb index 7b2173e..d21345c 100755 --- a/spec/functions/is_bool_spec.rb +++ b/spec/functions/is_bool_spec.rb @@ -14,7 +14,7 @@ describe 'is_bool' do it { is_expected.to run.with_params('true').and_return(false) } it { is_expected.to run.with_params('false').and_return(false) } context 'Checking for deprecation warning' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning, which should only be provoked when the env variable for it is set. diff --git a/spec/functions/is_float_spec.rb b/spec/functions/is_float_spec.rb index 44bdc48..af3322e 100755 --- a/spec/functions/is_float_spec.rb +++ b/spec/functions/is_float_spec.rb @@ -23,7 +23,7 @@ describe 'is_float' do end context 'Checking for deprecation warning' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning, which should only be provoked when the env variable for it is set. diff --git a/spec/functions/is_integer_spec.rb b/spec/functions/is_integer_spec.rb index 4b5dd21..b296830 100755 --- a/spec/functions/is_integer_spec.rb +++ b/spec/functions/is_integer_spec.rb @@ -26,7 +26,7 @@ describe 'is_integer' do it { is_expected.to run.with_params('0001234').and_return(false) } context 'Checking for deprecation warning' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning, which should only be provoked when the env variable for it is set. diff --git a/spec/functions/is_ip_address_spec.rb b/spec/functions/is_ip_address_spec.rb index fc8af60..39525d7 100755 --- a/spec/functions/is_ip_address_spec.rb +++ b/spec/functions/is_ip_address_spec.rb @@ -33,7 +33,7 @@ describe 'is_ip_address' do scope.expects(:warning).with(includes('This method is deprecated')).never is_expected.to run.with_params('1.2.3.4').and_return(true) end - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end end diff --git a/spec/functions/is_ipv4_address_spec.rb b/spec/functions/is_ipv4_address_spec.rb index 9d53a9d..e39d93b 100644 --- a/spec/functions/is_ipv4_address_spec.rb +++ b/spec/functions/is_ipv4_address_spec.rb @@ -12,7 +12,7 @@ describe 'is_ipv4_address' do it { is_expected.to run.with_params('one').and_return(false) } context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning, which should only be provoked when the env variable for it is set. diff --git a/spec/functions/is_ipv6_address_spec.rb b/spec/functions/is_ipv6_address_spec.rb index 4449fea..acd6a87 100644 --- a/spec/functions/is_ipv6_address_spec.rb +++ b/spec/functions/is_ipv6_address_spec.rb @@ -12,7 +12,7 @@ describe 'is_ipv6_address' do it { is_expected.to run.with_params('one').and_return(false) } context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning, which should only be provoked when the env variable for it is set. diff --git a/spec/functions/is_numeric_spec.rb b/spec/functions/is_numeric_spec.rb index ccfb9d8..5962d8a 100755 --- a/spec/functions/is_numeric_spec.rb +++ b/spec/functions/is_numeric_spec.rb @@ -29,7 +29,7 @@ describe 'is_numeric' do it { is_expected.to run.with_params(' - 1234').and_return(false) } context 'Checking for deprecation warning' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning, which should only be provoked when the env variable for it is set. diff --git a/spec/functions/is_string_spec.rb b/spec/functions/is_string_spec.rb index 460d6e0..e92f85c 100755 --- a/spec/functions/is_string_spec.rb +++ b/spec/functions/is_string_spec.rb @@ -28,7 +28,7 @@ describe 'is_string' do it { is_expected.to run.with_params('0001234').and_return(true) } context 'Checking for deprecation warning' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning, which should only be provoked when the env variable for it is set. diff --git a/spec/functions/validate_absolute_path_spec.rb b/spec/functions/validate_absolute_path_spec.rb index bdb55f0..9397da5 100755 --- a/spec/functions/validate_absolute_path_spec.rb +++ b/spec/functions/validate_absolute_path_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'validate_absolute_path' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/validate_array_spec.rb b/spec/functions/validate_array_spec.rb index f395d16..409b3dc 100755 --- a/spec/functions/validate_array_spec.rb +++ b/spec/functions/validate_array_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'validate_array' do describe 'signature validation' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end it { is_expected.not_to eq(nil) } diff --git a/spec/functions/validate_bool_spec.rb b/spec/functions/validate_bool_spec.rb index 8b7e438..3074d88 100755 --- a/spec/functions/validate_bool_spec.rb +++ b/spec/functions/validate_bool_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'validate_bool' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/validate_hash_spec.rb b/spec/functions/validate_hash_spec.rb index 7b118e2..7533abe 100755 --- a/spec/functions/validate_hash_spec.rb +++ b/spec/functions/validate_hash_spec.rb @@ -6,7 +6,7 @@ describe 'validate_hash' do it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } describe 'check for deprecation warning' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning diff --git a/spec/functions/validate_integer_spec.rb b/spec/functions/validate_integer_spec.rb index ffc59f8..6558d00 100755 --- a/spec/functions/validate_integer_spec.rb +++ b/spec/functions/validate_integer_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'validate_integer' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/validate_ip_address_spec.rb b/spec/functions/validate_ip_address_spec.rb index 7040a8d..0414f5e 100644 --- a/spec/functions/validate_ip_address_spec.rb +++ b/spec/functions/validate_ip_address_spec.rb @@ -22,7 +22,7 @@ describe 'validate_ip_address' do it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') } context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning, which should only be provoked when the env variable for it is set. diff --git a/spec/functions/validate_ipv4_address_spec.rb b/spec/functions/validate_ipv4_address_spec.rb index b60dc8e..d221793 100755 --- a/spec/functions/validate_ipv4_address_spec.rb +++ b/spec/functions/validate_ipv4_address_spec.rb @@ -8,7 +8,7 @@ describe 'validate_ipv4_address' do end context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning, which should only be provoked when the env variable for it is set. diff --git a/spec/functions/validate_ipv6_address_spec.rb b/spec/functions/validate_ipv6_address_spec.rb index 87b535e..78810d4 100755 --- a/spec/functions/validate_ipv6_address_spec.rb +++ b/spec/functions/validate_ipv6_address_spec.rb @@ -8,7 +8,7 @@ describe 'validate_ipv6_address' do end context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end # Checking for deprecation warning, which should only be provoked when the env variable for it is set. diff --git a/spec/functions/validate_numeric_spec.rb b/spec/functions/validate_numeric_spec.rb index 4a65649..4c0e24d 100755 --- a/spec/functions/validate_numeric_spec.rb +++ b/spec/functions/validate_numeric_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'validate_numeric' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/validate_re_spec.rb b/spec/functions/validate_re_spec.rb index 2fa9ddd..3531182 100755 --- a/spec/functions/validate_re_spec.rb +++ b/spec/functions/validate_re_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'validate_re' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/validate_slength_spec.rb b/spec/functions/validate_slength_spec.rb index 2ea253c..e4162de 100755 --- a/spec/functions/validate_slength_spec.rb +++ b/spec/functions/validate_slength_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'validate_slength' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/validate_string_spec.rb b/spec/functions/validate_string_spec.rb index 45d6ffc..b5ce763 100755 --- a/spec/functions/validate_string_spec.rb +++ b/spec/functions/validate_string_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'validate_string' do - after(:context) do + after(:all) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end -- cgit v1.2.3