diff options
Diffstat (limited to 'spec/acceptance')
-rw-r--r-- | spec/acceptance/deprecation_spec.rb | 58 | ||||
-rwxr-xr-x | spec/acceptance/is_string_spec.rb | 11 | ||||
-rw-r--r-- | spec/acceptance/nodesets/centos-7-x64.yml | 2 | ||||
-rwxr-xr-x | spec/acceptance/validate_array_spec.rb | 16 | ||||
-rwxr-xr-x | spec/acceptance/validate_bool_spec.rb | 16 | ||||
-rwxr-xr-x | spec/acceptance/validate_hash_spec.rb | 16 | ||||
-rwxr-xr-x | spec/acceptance/validate_string_spec.rb | 7 |
7 files changed, 77 insertions, 49 deletions
diff --git a/spec/acceptance/deprecation_spec.rb b/spec/acceptance/deprecation_spec.rb index d0d7fed..ea13700 100644 --- a/spec/acceptance/deprecation_spec.rb +++ b/spec/acceptance/deprecation_spec.rb @@ -1,19 +1,29 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -require 'shellwords' describe 'deprecation function' do - before :each do - FileUtils.rm_rf '/tmp/deprecation' + + if fact('operatingsystem') == 'windows' + test_file = 'C:/deprecation' + else + test_file = "/tmp/deprecation" + end + + # It seems that Windows needs everything to be on one line when using puppet apply -e, otherwise the manifests would be in an easier format + add_file_manifest = "\"deprecation('key', 'message') file { '#{test_file}': ensure => present, content => 'test', }\"" + remove_file_manifest = "file { '#{test_file}': ensure => absent }" + + before :all do + apply_manifest(remove_file_manifest) end context 'with --strict=error', if: get_puppet_version =~ /^4/ do before :all do - pp = <<-EOS - deprecation('key', 'message') - file { '/tmp/deprecation': ensure => present } - EOS - @result = on(default, puppet('apply', '--strict=error', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256)) + @result = on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), acceptable_exit_codes: (0...256)) + end + + after :all do + apply_manifest(remove_file_manifest) end it "should return an error" do @@ -24,18 +34,18 @@ describe 'deprecation function' do expect(@result.stderr).to match(/deprecation. key. message/) end - describe file('/tmp/deprecation') do - it { is_expected.not_to exist } + describe file("#{test_file}") do + it { is_expected.not_to be_file } end end context 'with --strict=warning', if: get_puppet_version =~ /^4/ do before :all do - pp = <<-EOS - deprecation('key', 'message') - file { '/tmp/deprecation': ensure => present } - EOS - @result = on(default, puppet('apply', '--strict=warning', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256)) + @result = on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), acceptable_exit_codes: (0...256)) + end + + after :all do + apply_manifest(remove_file_manifest) end it "should not return an error" do @@ -46,18 +56,18 @@ describe 'deprecation function' do expect(@result.stderr).to match(/Warning: message/) end - describe file('/tmp/deprecation') do - it { is_expected.to exist } + describe file("#{test_file}") do + it { is_expected.to be_file } end end context 'with --strict=off', if: get_puppet_version =~ /^4/ do before :all do - pp = <<-EOS - deprecation('key', 'message') - file { '/tmp/deprecation': ensure => present } - EOS - @result = on(default, puppet('apply', '--strict=off', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256)) + @result = on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), acceptable_exit_codes: (0...256)) + end + + after :all do + apply_manifest(remove_file_manifest) end it "should not return an error" do @@ -68,8 +78,8 @@ describe 'deprecation function' do expect(@result.stderr).not_to match(/Warning: message/) end - describe file('/tmp/deprecation') do - it { is_expected.to exist } + describe file("#{test_file}") do + it { is_expected.to be_file } end end end diff --git a/spec/acceptance/is_string_spec.rb b/spec/acceptance/is_string_spec.rb index 94d8e96..f526888 100755 --- a/spec/acceptance/is_string_spec.rb +++ b/spec/acceptance/is_string_spec.rb @@ -95,6 +95,17 @@ describe 'is_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o expect(r.stdout).to match(/Notice: output correct/) end end + it 'is_strings undef' do + pp = <<-EOS + $a = undef + $o = is_string($a) + notice(inline_template('is_string is <%= @o.inspect %>')) + EOS + + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/is_string is true/) + end + end end describe 'failure' do it 'handles improper argument counts' diff --git a/spec/acceptance/nodesets/centos-7-x64.yml b/spec/acceptance/nodesets/centos-7-x64.yml index 1a40c89..5eebdef 100644 --- a/spec/acceptance/nodesets/centos-7-x64.yml +++ b/spec/acceptance/nodesets/centos-7-x64.yml @@ -3,7 +3,7 @@ HOSTS: roles: - agent - default - platform: redhat-7-x86_64 + platform: el-7-x86_64 hypervisor: vagrant box: puppetlabs/centos-7.2-64-nocm CONFIG: 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 diff --git a/spec/acceptance/validate_string_spec.rb b/spec/acceptance/validate_string_spec.rb index 8956f48..ae3468f 100755 --- a/spec/acceptance/validate_string_spec.rb +++ b/spec/acceptance/validate_string_spec.rb @@ -20,6 +20,13 @@ describe 'validate_string function', :unless => UNSUPPORTED_PLATFORMS.include?(f apply_manifest(pp, :catch_failures => true) end + it 'validates undef' do + pp = <<-EOS + validate_string(undef) + EOS + + apply_manifest(pp, :catch_failures => true) + end it 'validates a non-string' do { %{validate_string({ 'a' => 'hash' })} => "Hash", |