From 51f1d574d92cf686ac79e57e69d8aff31caf2925 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Tue, 28 Oct 2014 15:27:24 -0700 Subject: Fix testcases for Future Parser and resolve issue with values_at in assuming that it was dealing with a string --- spec/acceptance/abs_spec.rb | 4 ++-- spec/acceptance/any2array_spec.rb | 4 ++-- spec/acceptance/bool2num_spec.rb | 12 ++++++------ spec/acceptance/count_spec.rb | 4 ++-- spec/acceptance/ensure_packages_spec.rb | 2 +- spec/acceptance/merge_spec.rb | 4 ++-- spec/acceptance/type_spec.rb | 2 +- spec/acceptance/validate_cmd_spec.rb | 2 +- spec/acceptance/values_spec.rb | 6 +++++- spec/acceptance/zip_spec.rb | 28 ++++++++++++++++++++-------- 10 files changed, 42 insertions(+), 26 deletions(-) (limited to 'spec/acceptance') diff --git a/spec/acceptance/abs_spec.rb b/spec/acceptance/abs_spec.rb index 8e05642..6e41e2f 100755 --- a/spec/acceptance/abs_spec.rb +++ b/spec/acceptance/abs_spec.rb @@ -7,7 +7,7 @@ describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati pp = <<-EOS $input = '-34.56' $output = abs($input) - notify { $output: } + notify { "$output": } EOS apply_manifest(pp, :catch_failures => true) do |r| @@ -19,7 +19,7 @@ describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati pp = <<-EOS $input = -34.56 $output = abs($input) - notify { $output: } + notify { "$output": } EOS apply_manifest(pp, :catch_failures => true) do |r| diff --git a/spec/acceptance/any2array_spec.rb b/spec/acceptance/any2array_spec.rb index 467d6af..18ea4cd 100755 --- a/spec/acceptance/any2array_spec.rb +++ b/spec/acceptance/any2array_spec.rb @@ -25,7 +25,7 @@ describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o EOS apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: Output: testarray/) + expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/) end end @@ -42,7 +42,7 @@ describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o EOS apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Notice: Output: testarray/) + expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/) end end end diff --git a/spec/acceptance/bool2num_spec.rb b/spec/acceptance/bool2num_spec.rb index 7a70311..52ff75b 100755 --- a/spec/acceptance/bool2num_spec.rb +++ b/spec/acceptance/bool2num_spec.rb @@ -4,11 +4,11 @@ require 'spec_helper_acceptance' describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do describe 'success' do ['false', 'f', '0', 'n', 'no'].each do |bool| - it 'should convert a given boolean, #{bool}, to 0' do + it "should convert a given boolean, #{bool}, to 0" do pp = <<-EOS - $input = #{bool} + $input = "#{bool}" $output = bool2num($input) - notify { $output: } + notify { "$output": } EOS apply_manifest(pp, :catch_failures => true) do |r| @@ -18,11 +18,11 @@ describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('op end ['true', 't', '1', 'y', 'yes'].each do |bool| - it 'should convert a given boolean, #{bool}, to 1' do + it "should convert a given boolean, #{bool}, to 1" do pp = <<-EOS - $input = #{bool} + $input = "#{bool}" $output = bool2num($input) - notify { $output: } + notify { "$output": } EOS apply_manifest(pp, :catch_failures => true) do |r| diff --git a/spec/acceptance/count_spec.rb b/spec/acceptance/count_spec.rb index 51a40ba..fe7ca9d 100755 --- a/spec/acceptance/count_spec.rb +++ b/spec/acceptance/count_spec.rb @@ -7,7 +7,7 @@ describe 'count function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('opera pp = <<-EOS $input = [1,2,3,4] $output = count($input) - notify { $output: } + notify { "$output": } EOS apply_manifest(pp, :catch_failures => true) do |r| @@ -19,7 +19,7 @@ describe 'count function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('opera pp = <<-EOS $input = [1,1,1,2] $output = count($input, 1) - notify { $output: } + notify { "$output": } EOS apply_manifest(pp, :catch_failures => true) do |r| diff --git a/spec/acceptance/ensure_packages_spec.rb b/spec/acceptance/ensure_packages_spec.rb index 12da0cd..53c1035 100755 --- a/spec/acceptance/ensure_packages_spec.rb +++ b/spec/acceptance/ensure_packages_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'ensure_packages function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'ensure_packages function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || fact('operatingsystem') != 'windows') do describe 'success' do it 'ensure_packages a package' do apply_manifest('package { "rake": ensure => absent, provider => "gem", }') diff --git a/spec/acceptance/merge_spec.rb b/spec/acceptance/merge_spec.rb index a60e784..227b994 100755 --- a/spec/acceptance/merge_spec.rb +++ b/spec/acceptance/merge_spec.rb @@ -14,9 +14,9 @@ describe 'merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('opera EOS apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/merge\[one\] is "1"/) + expect(r.stdout).to match(/merge\[one\] is ("1"|1)/) expect(r.stdout).to match(/merge\[two\] is "dos"/) - expect(r.stdout).to match(/merge\[three\] is {"five"=>"5"}/) + expect(r.stdout).to match(/merge\[three\] is {"five"=>("5"|5)}/) end end end diff --git a/spec/acceptance/type_spec.rb b/spec/acceptance/type_spec.rb index 0043aad..15fa217 100755 --- a/spec/acceptance/type_spec.rb +++ b/spec/acceptance/type_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'type function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'type function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || !(is_future_parser_enabled?)) do describe 'success' do it 'types arrays' do pp = <<-EOS diff --git a/spec/acceptance/validate_cmd_spec.rb b/spec/acceptance/validate_cmd_spec.rb index 385676d..a899a1d 100755 --- a/spec/acceptance/validate_cmd_spec.rb +++ b/spec/acceptance/validate_cmd_spec.rb @@ -37,7 +37,7 @@ describe 'validate_cmd function', :unless => UNSUPPORTED_PLATFORMS.include?(fact } else { $two = '/bin/aoeu' } - validate_cmd($one,$two,"aoeu is dvorak) + validate_cmd($one,$two,"aoeu is dvorak") EOS expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/aoeu is dvorak/) diff --git a/spec/acceptance/values_spec.rb b/spec/acceptance/values_spec.rb index 7ef956e..a2eff32 100755 --- a/spec/acceptance/values_spec.rb +++ b/spec/acceptance/values_spec.rb @@ -13,8 +13,12 @@ describe 'values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('oper $output = values($arg) notice(inline_template('<%= @output.sort.inspect %>')) EOS + if is_future_parser_enabled? + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/) + else + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/) + end - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/) end end describe 'failure' do diff --git a/spec/acceptance/zip_spec.rb b/spec/acceptance/zip_spec.rb index 0e924e8..139079e 100755 --- a/spec/acceptance/zip_spec.rb +++ b/spec/acceptance/zip_spec.rb @@ -11,8 +11,11 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) EOS - - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\], \["3", "7"\], \["4", "8"\]\]/) + if is_future_parser_enabled? + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]/) + else + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\], \["3", "7"\], \["4", "8"\]\]/) + end end it 'zips two arrays of numbers & bools together' do pp = <<-EOS @@ -21,8 +24,11 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) EOS - - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", true\], \["2", true\], \["three", false\], \["4", false\]\]/) + if is_future_parser_enabled? + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]/) + else + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", true\], \["2", true\], \["three", false\], \["4", false\]\]/) + end end it 'zips two arrays of numbers together and flattens them' do # XXX This only tests the argument `true`, even though the following are valid: @@ -35,8 +41,11 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two,true) notice(inline_template('<%= @output.inspect %>')) EOS - - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "5", "2", "6", "3", "7", "4", "8"\]/) + if is_future_parser_enabled? + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 5, 2, 6, 3, 7, 4, 8\]/) + else + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "5", "2", "6", "3", "7", "4", "8"\]/) + end end it 'handles unmatched length' do # XXX Is this expected behavior? @@ -46,8 +55,11 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) EOS - - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\]\]/) + if is_future_parser_enabled? + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\]\]/) + else + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\]\]/) + end end end describe 'failure' do -- cgit v1.2.3