From 128d6fe56855ba37698f67314b991a2bfdb7af37 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Thu, 12 Jan 2017 15:35:35 +0000 Subject: Addition of compat hash type for deprecation --- spec/aliases/hash_spec.rb | 32 ++++++++++++++++++++++++++++++++ spec/fixtures/test/manifests/hash.pp | 8 ++++++++ 2 files changed, 40 insertions(+) create mode 100644 spec/aliases/hash_spec.rb create mode 100644 spec/fixtures/test/manifests/hash.pp (limited to 'spec') diff --git a/spec/aliases/hash_spec.rb b/spec/aliases/hash_spec.rb new file mode 100644 index 0000000..e10a04b --- /dev/null +++ b/spec/aliases/hash_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +if Puppet.version.to_f >= 4.5 + describe 'test::hash', type: :class do + describe 'accepts hashes' do + [ + {}, + {'one' => "two"}, + {'wan' => 3}, + {'001' => "helly"}, + ].each do |value| + describe value.inspect do + let(:params) {{ value: value }} + it { is_expected.to compile } + end + end + end + describe 'rejects other values' do + [ + '', + 'one', + '1', + [], + ].each do |value| + describe value.inspect do + let(:params) {{ value: value }} + it { is_expected.to compile.and_raise_error(/parameter 'value' expects a Stdlib::Compat::Hash/) } + end + end + end + end +end diff --git a/spec/fixtures/test/manifests/hash.pp b/spec/fixtures/test/manifests/hash.pp new file mode 100644 index 0000000..c243570 --- /dev/null +++ b/spec/fixtures/test/manifests/hash.pp @@ -0,0 +1,8 @@ +# Class to test the Stdlib::Compat::Hash type alias +class test::hash( + Stdlib::Compat::Hash $value, + ) { + + notice("Success") + +} -- cgit v1.2.3 From 08481d1e5bb24ce95ea0243deea3f41c6d1b1b67 Mon Sep 17 00:00:00 2001 From: Wilson McCoubrey Date: Thu, 19 Jan 2017 15:51:07 +0000 Subject: Implement beaker-module_install_helper --- spec/spec_helper_acceptance.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'spec') diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 8a1907f..89e64d4 100755 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,15 +1,16 @@ #! /usr/bin/env ruby -S rspec require 'beaker-rspec' require 'beaker/puppet_install_helper' +require 'beaker/module_install_helper' UNSUPPORTED_PLATFORMS = [] run_puppet_install_helper +install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ /pe/i +install_module_on(hosts) +install_module_dependencies_on(hosts) RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - # Readable test descriptions c.formatter = :documentation @@ -19,8 +20,6 @@ RSpec.configure do |c| default[:default_apply_opts] ||= {} default[:default_apply_opts].merge!({:parser => 'future'}) end - - copy_root_module_to(default, :source => proj_root, :module_name => 'stdlib') end end -- cgit v1.2.3 From 1229d5a831995ddc2c9814f5104ea2a2c9df65a9 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 19 Jan 2017 16:17:47 -0800 Subject: (MODULES-4098) Sync the rest of the files --- spec/functions/deprecation_spec.rb | 4 ++-- spec/functions/load_module_metadata_spec.rb | 37 +++++++++++++++++++---------- spec/functions/loadjson_spec.rb | 31 +++++++++++++++++------- spec/functions/validate_cmd_spec.rb | 2 +- spec/functions/validate_legacy_spec.rb | 2 +- spec/unit/puppet/type/file_line_spec.rb | 36 +++++++++++++++++++--------- 6 files changed, 77 insertions(+), 35 deletions(-) (limited to 'spec') diff --git a/spec/functions/deprecation_spec.rb b/spec/functions/deprecation_spec.rb index cee4f1c..8a65b69 100644 --- a/spec/functions/deprecation_spec.rb +++ b/spec/functions/deprecation_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.0 +if Puppet.version.to_f >= 4.5 describe 'deprecation' do before(:each) { # this is to reset the strict variable to default @@ -40,7 +40,7 @@ if Puppet.version.to_f >= 4.0 Puppet.settings[:strict] = :warning } end -else +elsif Puppet.version.to_f < 4.0 # Puppet version < 4 will use these tests. describe 'deprecation' do after(:all) do diff --git a/spec/functions/load_module_metadata_spec.rb b/spec/functions/load_module_metadata_spec.rb index 1a61e2c..2ba41a5 100755 --- a/spec/functions/load_module_metadata_spec.rb +++ b/spec/functions/load_module_metadata_spec.rb @@ -7,30 +7,43 @@ describe 'load_module_metadata' do describe "when calling with valid arguments" do before :each do - if RSpec.configuration.puppet_future - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') - else - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') - end + allow(File).to receive(:read).with(/\/stdlib\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') + allow(File).to receive(:read).with(/\/stdlib\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') end it "should json parse the file" do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') - allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(true) - allow(File).to receive(:read).with('/path/to/module/metadata.json').and_return('{"name": "spencer-science"}') + if Puppet::Util::Platform.windows? + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/') + allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(true) + allow(File).to receive(:read).with('C:/path/to/module/metadata.json').and_return('{"name": "spencer-science"}') + else + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') + allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(true) + allow(File).to receive(:read).with('/path/to/module/metadata.json').and_return('{"name": "spencer-science"}') + end result = subject.call(['science']) expect(result['name']).to eq('spencer-science') end it "should fail by default if there is no metadata.json" do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') - allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) + if Puppet::Util::Platform.windows? + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/') + allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(false) + else + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') + allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) + end expect {subject.call(['science'])}.to raise_error(Puppet::ParseError) end it "should return nil if user allows empty metadata.json" do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') - allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) + if Puppet::Util::Platform.windows? + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/') + allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(false) + else + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') + allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) + end result = subject.call(['science', true]) expect(result).to eq({}) end diff --git a/spec/functions/loadjson_spec.rb b/spec/functions/loadjson_spec.rb index a00dff9..9d26e93 100644 --- a/spec/functions/loadjson_spec.rb +++ b/spec/functions/loadjson_spec.rb @@ -6,15 +6,18 @@ describe 'loadjson' do describe "when calling with valid arguments" do before :each do - if RSpec.configuration.puppet_future - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') - else - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') - end + allow(File).to receive(:read).with(/\/stdlib\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') + allow(File).to receive(:read).with(/\/stdlib\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') end context 'when a non-existing file is specified' do - let(:filename) { '/tmp/doesnotexist' } + let(:filename) { + if Puppet::Util::Platform.windows? + 'C:/tmp/doesnotexist' + else + '/tmp/doesnotexist' + end + } before { allow(File).to receive(:exists?).with(filename).and_return(false).once allow(PSON).to receive(:load).never @@ -23,7 +26,13 @@ describe 'loadjson' do end context 'when an existing file is specified' do - let(:filename) { '/tmp/doesexist' } + let(:filename) { + if Puppet::Util::Platform.windows? + 'C:/tmp/doesexist' + else + '/tmp/doesexist' + end + } let(:data) { { 'key' => 'value' } } let(:json) { '{"key":"value"}' } before { @@ -36,7 +45,13 @@ describe 'loadjson' do end context 'when the file could not be parsed' do - let(:filename) { '/tmp/doesexist' } + let(:filename) { + if Puppet::Util::Platform.windows? + 'C:/tmp/doesexist' + else + '/tmp/doesexist' + end + } let(:json) { '{"key":"value"}' } before { allow(File).to receive(:exists?).with(filename).and_return(true).once diff --git a/spec/functions/validate_cmd_spec.rb b/spec/functions/validate_cmd_spec.rb index ab0cbc9..c6559e8 100755 --- a/spec/functions/validate_cmd_spec.rb +++ b/spec/functions/validate_cmd_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'validate_cmd' do +describe 'validate_cmd', :unless => Puppet::Util::Platform.windows? do let(:touch) { File.exists?('/usr/bin/touch') ? '/usr/bin/touch' : '/bin/touch' } describe 'signature validation' do diff --git a/spec/functions/validate_legacy_spec.rb b/spec/functions/validate_legacy_spec.rb index 50cb317..10b2aee 100644 --- a/spec/functions/validate_legacy_spec.rb +++ b/spec/functions/validate_legacy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.0 +if Puppet.version.to_f >= 4.4 describe 'validate_legacy' do it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params.and_raise_error(ArgumentError) } diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index 48e2670..c559e44 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -2,14 +2,28 @@ require 'spec_helper' require 'tempfile' describe Puppet::Type.type(:file_line) do + let :tmp_path do + if Puppet::Util::Platform.windows? + 'C:\tmp\path' + else + '/tmp/path' + end + end + let :my_path do + if Puppet::Util::Platform.windows? + 'C:\my\path' + else + '/my/path' + end + end let :file_line do - Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => '/tmp/path') + Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => tmp_path) end it 'should accept a line and path' do file_line[:line] = 'my_line' expect(file_line[:line]).to eq('my_line') - file_line[:path] = '/my/path' - expect(file_line[:path]).to eq('/my/path') + file_line[:path] = my_path + expect(file_line[:path]).to eq(my_path) end it 'should accept a match regex' do file_line[:match] = '^foo.*$' @@ -19,7 +33,7 @@ describe Puppet::Type.type(:file_line) do expect { Puppet::Type.type(:file_line).new( :name => 'foo', - :path => '/my/path', + :path => my_path, :line => 'foo=bar', :match => '^bar=blah$' )}.not_to raise_error @@ -28,23 +42,23 @@ describe Puppet::Type.type(:file_line) do expect { Puppet::Type.type(:file_line).new( :name => 'foo', - :path => '/my/path', + :path => my_path, :line => 'foo=bar', :match => '^\s*foo=.*$' )}.not_to raise_error end it 'should accept posix filenames' do - file_line[:path] = '/tmp/path' - expect(file_line[:path]).to eq('/tmp/path') + file_line[:path] = tmp_path + expect(file_line[:path]).to eq(tmp_path) end it 'should not accept unqualified path' do expect { file_line[:path] = 'file' }.to raise_error(Puppet::Error, /File paths must be fully qualified/) end it 'should require that a line is specified' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file') }.to raise_error(Puppet::Error, /line is a required attribute/) + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path) }.to raise_error(Puppet::Error, /line is a required attribute/) end it 'should not require that a line is specified when matching for absence' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file', :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error end it 'should require that a file is specified' do expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, /path is a required attribute/) @@ -58,12 +72,12 @@ describe Puppet::Type.type(:file_line) do it "should autorequire the file it manages" do catalog = Puppet::Resource::Catalog.new - file = Puppet::Type.type(:file).new(:name => "/tmp/path") + file = Puppet::Type.type(:file).new(:name => tmp_path) catalog.add_resource file catalog.add_resource file_line relationship = file_line.autorequire.find do |rel| - (rel.source.to_s == "File[/tmp/path]") and (rel.target.to_s == file_line.to_s) + (rel.source.to_s == "File[#{tmp_path}]") and (rel.target.to_s == file_line.to_s) end expect(relationship).to be_a Puppet::Relationship end -- cgit v1.2.3 From 20855b9d24de7a8b02b7f5beb70a16139a6c3d74 Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Wed, 1 Feb 2017 11:47:09 +0000 Subject: (FM-6019) - [WIP] - i18N tests for Spike --- spec/functions/any2array_spec.rb | 6 ++++++ spec/functions/ensure_resource_spec.rb | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'spec') diff --git a/spec/functions/any2array_spec.rb b/spec/functions/any2array_spec.rb index 70121f1..631657f 100755 --- a/spec/functions/any2array_spec.rb +++ b/spec/functions/any2array_spec.rb @@ -12,4 +12,10 @@ describe "any2array" do it { is_expected.to run.with_params({}).and_return([]) } it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) } it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) } + + it { is_expected.to run.with_params('‰').and_return(['‰']) } + it { is_expected.to run.with_params('竹').and_return(['竹']) } + it { is_expected.to run.with_params('Ü').and_return(['Ü']) } + it { is_expected.to run.with_params('∇').and_return(['∇']) } + it { is_expected.to run.with_params('€', '万', 'Ö', '♥', '割').and_return(['€', '万', 'Ö', '♥', '割']) } end diff --git a/spec/functions/ensure_resource_spec.rb b/spec/functions/ensure_resource_spec.rb index d552f4e..fddc4c4 100755 --- a/spec/functions/ensure_resource_spec.rb +++ b/spec/functions/ensure_resource_spec.rb @@ -38,7 +38,31 @@ describe 'ensure_resource' do it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') } it { expect(lambda { catalogue }).to contain_user('username1').without_gid } end + end + + context 'given a catalog with UTF8 chars' do + describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", {})' do + before { subject.call(['User', 'Şắოрŀễ Ţëם', {}]) } + + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure } + end + + describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { gid => undef })' do + before { subject.call(['User', 'Şắოрŀễ Ţëם', { 'gid' => :undef }]) } + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure } + it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid } + end + + describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { ensure => present, gid => undef })' do + before { subject.call(['User', 'Şắოрŀễ Ţëם', { 'ensure' => 'present', 'gid' => :undef }]) } + + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').with_ensure('present') } + it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid } + end end context 'given a catalog with "user { username1: ensure => present }"' do -- cgit v1.2.3 From 530d2ef184d19b965a4c9db2c415c26b80f9d31b Mon Sep 17 00:00:00 2001 From: Emerson Prado Date: Fri, 3 Feb 2017 17:05:52 -0200 Subject: Add spec test for present + installed convergence --- spec/functions/ensure_packages_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec') diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 5d97684..357a6e1 100755 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -41,4 +41,16 @@ describe 'ensure_packages' do it { expect(lambda { catalogue }).to contain_package('foo').with({'provider' => 'rpm', 'ensure' => 'present'}) } it { expect(lambda { catalogue }).to contain_package('bar').with({'provider' => 'gem', 'ensure' => 'present'}) } end + + context 'given a catalog with "package { puppet: ensure => present }"' do + let(:pre_condition) { 'package { puppet: ensure => present }' } + + describe 'after running ensure_package("puppet", { "ensure" => "installed" })' do + before { subject.call(['puppet', { "ensure" => "installed" }]) } + + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_package('puppet').with_ensure('present') } + end + end + end -- cgit v1.2.3 From 89a36c67d8efe22a16c2ce8ab2a40fc69ce589b2 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Fri, 3 Feb 2017 12:37:27 +0000 Subject: Fix unsupported data type error with rspec-puppet master The symbol used in the value of the facts hash is not a valid type of value for facts, and results in the following error since rspec-puppet@d50acf0e. Puppet::Error: Unsupported data type: 'Symbol' # puppet/lib/puppet/parser/scope.rb:788:in `deep_freeze' # puppet/lib/puppet/parser/scope.rb:781:in `block in deep_freeze' # puppet/lib/puppet/parser/scope.rb:781:in `each' # puppet/lib/puppet/parser/scope.rb:781:in `deep_freeze' # puppet/lib/puppet/parser/scope.rb:764:in `set_facts' # puppet/lib/puppet/parser/compiler.rb:850:in `set_node_parameters' # puppet/lib/puppet/parser/compiler.rb:166:in `block (2 levels) in compile' # puppet/lib/puppet/util/profiler/around_profiler.rb:58:in `profile' # puppet/lib/puppet/util/profiler.rb:51:in `profile' # puppet/lib/puppet/parser/compiler.rb:166:in `block in compile' # puppet/lib/puppet/context.rb:65:in `override' # puppet/lib/puppet.rb:293:in `override' # puppet/lib/puppet/parser/compiler.rb:162:in `compile' # rspec-puppet/lib/rspec-puppet/example/function_example_group.rb:161:in `build_compiler' The fact's presence doesn't change the behaviour, so remove it. --- spec/functions/has_ip_network_spec.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'spec') diff --git a/spec/functions/has_ip_network_spec.rb b/spec/functions/has_ip_network_spec.rb index 7b5fe66..57cf613 100755 --- a/spec/functions/has_ip_network_spec.rb +++ b/spec/functions/has_ip_network_spec.rb @@ -9,7 +9,6 @@ describe 'has_ip_network' do let(:facts) do { :interfaces => 'eth0,lo', - :network => :undefined, :network_lo => '127.0.0.0', :network_eth0 => '10.0.0.0', } -- cgit v1.2.3 From c2a41352b0a0338fcbdc54c5d3e722beb65c4dce Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Sat, 4 Feb 2017 16:45:03 +0100 Subject: Allow test module metadata.json to be read Since puppetlabs/puppet@f2e8e66, the test module's metadata.json is also read causing expectation failures. Like 5c51463, permit it to be read by Puppet. --- spec/functions/load_module_metadata_spec.rb | 4 ++-- spec/functions/loadjson_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/functions/load_module_metadata_spec.rb b/spec/functions/load_module_metadata_spec.rb index 2ba41a5..841cd7d 100755 --- a/spec/functions/load_module_metadata_spec.rb +++ b/spec/functions/load_module_metadata_spec.rb @@ -7,8 +7,8 @@ describe 'load_module_metadata' do describe "when calling with valid arguments" do before :each do - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') end it "should json parse the file" do if Puppet::Util::Platform.windows? diff --git a/spec/functions/loadjson_spec.rb b/spec/functions/loadjson_spec.rb index 9d26e93..26125bc 100644 --- a/spec/functions/loadjson_spec.rb +++ b/spec/functions/loadjson_spec.rb @@ -6,8 +6,8 @@ describe 'loadjson' do describe "when calling with valid arguments" do before :each do - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') end context 'when a non-existing file is specified' do -- cgit v1.2.3 From 6092ede8d86746038df4a367191d232003652c55 Mon Sep 17 00:00:00 2001 From: Sascha Spreitzer Date: Sat, 4 Feb 2017 13:30:59 +0100 Subject: Add glob function --- spec/functions/glob_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 spec/functions/glob_spec.rb (limited to 'spec') diff --git a/spec/functions/glob_spec.rb b/spec/functions/glob_spec.rb new file mode 100755 index 0000000..06439da --- /dev/null +++ b/spec/functions/glob_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe 'glob' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params('').and_return([]) } + it { is_expected.to run.with_params(['']).and_return([]) } + it { is_expected.to run.with_params(['', '']).and_return([]) } + it { is_expected.to run.with_params(['/etc/xyzxyzxyz', '/etcxyzxyzxyz']).and_return([]) } +end -- cgit v1.2.3 From 2c6c2ff62db3cb9ee3b8bf755f66da4918783d28 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Mon, 20 Feb 2017 10:46:50 +0000 Subject: Fix acceptance test failure "Hiera is not a class" Due to [BKR-969](https://tickets.puppetlabs.com/browse/BKR-969) the global `Hiera` symbol is corrupted. Loading puppet before beaker fixes that. --- spec/acceptance/zip_spec.rb | 1 - spec/spec_helper_acceptance.rb | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/acceptance/zip_spec.rb b/spec/acceptance/zip_spec.rb index 139079e..7e586e2 100755 --- a/spec/acceptance/zip_spec.rb +++ b/spec/acceptance/zip_spec.rb @@ -1,6 +1,5 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -require 'puppet' describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do describe 'success' do diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 89e64d4..27edff8 100755 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,4 +1,5 @@ #! /usr/bin/env ruby -S rspec +require 'puppet' require 'beaker-rspec' require 'beaker/puppet_install_helper' require 'beaker/module_install_helper' -- cgit v1.2.3 From 2cc0d66c76895583f5b0c7c38b88d2bc6af8b4f9 Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Tue, 21 Feb 2017 15:39:46 +0000 Subject: Adding unit test for i18n concat function --- spec/functions/concat_spec.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'spec') diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb index eb76233..0e67a60 100755 --- a/spec/functions/concat_spec.rb +++ b/spec/functions/concat_spec.rb @@ -12,6 +12,7 @@ describe 'concat' do it { is_expected.to run.with_params(['1','2'],['3','4'],['5','6']).and_return(['1','2','3','4','5','6']) } it { is_expected.to run.with_params(['1','2'],'3','4',['5','6']).and_return(['1','2','3','4','5','6']) } it { is_expected.to run.with_params([{"a" => "b"}], {"c" => "d", "e" => "f"}).and_return([{"a" => "b"}, {"c" => "d", "e" => "f"}]) } + it { is_expected.to run.with_params(['ấ','β','c'],['đ','ể','ƒ']).and_return(['ấ','β','c','đ','ể','ƒ']) } it "should leave the original array intact" do argument1 = ['1','2','3'] -- cgit v1.2.3 From 68fa8d32511e770498118b9c1ccc1dfd1e89c860 Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Tue, 21 Feb 2017 15:40:04 +0000 Subject: Adding unit test for i18n count function --- spec/functions/count_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'spec') diff --git a/spec/functions/count_spec.rb b/spec/functions/count_spec.rb index c8d1960..3854cb8 100755 --- a/spec/functions/count_spec.rb +++ b/spec/functions/count_spec.rb @@ -15,4 +15,9 @@ describe 'count' do it { is_expected.to run.with_params(["one", nil, "two"]).and_return(2) } it { is_expected.to run.with_params(["one", "", "two"]).and_return(2) } it { is_expected.to run.with_params(["one", :undef, "two"]).and_return(2) } + + it { is_expected.to run.with_params(["ổņ℮", "ŧщộ", "three"]).and_return(3) } + it { is_expected.to run.with_params(["ổņ℮", "ŧщộ", "ŧщộ"], "ŧщộ").and_return(2) } + it { is_expected.to run.with_params(["ổņ℮", nil, "ŧщộ"]).and_return(2) } + it { is_expected.to run.with_params(["ổņ℮", :undef, "ŧщộ"]).and_return(2) } end -- cgit v1.2.3 From 83d68fef749869dc917539f7f05592dc2f2ce642 Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Tue, 21 Feb 2017 15:51:59 +0000 Subject: Adding unit test for i18n delete function --- spec/functions/delete_spec.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/functions/delete_spec.rb b/spec/functions/delete_spec.rb index b44accf..4e37865 100755 --- a/spec/functions/delete_spec.rb +++ b/spec/functions/delete_spec.rb @@ -19,6 +19,7 @@ describe 'delete' do it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) } it { is_expected.to run.with_params(['two', 'one', 'two', 'three', 'two'], 'two').and_return(['one', 'three']) } it { is_expected.to run.with_params(['one', 'two', 'three', 'two'], ['one', 'two']).and_return(['three']) } + it { is_expected.to run.with_params(['ồאּẻ', 'ŧẅơ', 'ŧңŗё℮', 'ŧẅơ'], ['ồאּẻ', 'ŧẅơ']).and_return(['ŧңŗё℮']) } end describe 'deleting from a string' do @@ -30,7 +31,8 @@ describe 'delete' do it { is_expected.to run.with_params('barfoobar', 'bar').and_return('foo') } it { is_expected.to run.with_params('foobarbabarz', 'bar').and_return('foobaz') } it { is_expected.to run.with_params('foobarbabarz', ['foo', 'bar']).and_return('baz') } - # this is so sick + it { is_expected.to run.with_params('ƒōōβậяβậβậяź', ['ƒōō', 'βậя']).and_return('βậź') } + it { is_expected.to run.with_params('barfoobar', ['barbar', 'foo']).and_return('barbar') } it { is_expected.to run.with_params('barfoobar', ['foo', 'barbar']).and_return('') } end @@ -47,6 +49,10 @@ describe 'delete' do .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, ['key1', 'key2']) \ .and_return( {'key3' => 'value3'}) } + it { is_expected.to run \ + .with_params({'ĸəұ1' => 'νãŀủĕ1', 'ĸəұ2' => 'νãŀủĕ2', 'ĸəұ3' => 'νãŀủĕ3'}, ['ĸəұ1', 'ĸəұ2']) \ + .and_return( {'ĸəұ3' => 'νãŀủĕ3'}) + } end it "should leave the original array intact" do -- cgit v1.2.3 From 846ddcd09e1a5bf27acb6cb5fd1e0854bb1538f6 Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Tue, 21 Feb 2017 16:01:06 +0000 Subject: Adding unit test for i18n delete_at function --- spec/functions/delete_at_spec.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'spec') diff --git a/spec/functions/delete_at_spec.rb b/spec/functions/delete_at_spec.rb index 0e19472..0471039 100755 --- a/spec/functions/delete_at_spec.rb +++ b/spec/functions/delete_at_spec.rb @@ -18,6 +18,8 @@ describe 'delete_at' do it { is_expected.to run.with_params([0, 1, 2], 1).and_return([0, 2]) } it { is_expected.to run.with_params([0, 1, 2], -1).and_return([0, 1]) } it { is_expected.to run.with_params([0, 1, 2], -4).and_return([0, 1, 2]) } + it { is_expected.to run.with_params(["ƒờở", "βāř", "ьầż"], 1).and_return(["ƒờở", "ьầż"]) } + it "should leave the original array intact" do argument = [1, 2, 3] -- cgit v1.2.3 From 150696a028d047321e9e53081d0922e039a66312 Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Tue, 21 Feb 2017 16:04:47 +0000 Subject: Adding unit test for i18n delete_value function --- spec/functions/delete_values_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/functions/delete_values_spec.rb b/spec/functions/delete_values_spec.rb index 12907d4..329fa0b 100755 --- a/spec/functions/delete_values_spec.rb +++ b/spec/functions/delete_values_spec.rb @@ -19,7 +19,11 @@ describe 'delete_values' do .and_return({'key1' => 'value1'}) } it { is_expected.to run \ - .with_params({'key1' => 'value1', 'key2' => 'value to delete'}, 'value to delete') \ + .with_params({'ҝếỵ1 ' => 'νâĺūẹ1', 'ҝếỵ2' => 'value to delete'}, 'value to delete') \ + .and_return({'ҝếỵ1 ' => 'νâĺūẹ1'}) + } + it { is_expected.to run \ + .with_params({'key1' => 'value1', 'key2' => 'νǎŀữ℮ ťớ đêłểťė'}, 'νǎŀữ℮ ťớ đêłểťė') \ .and_return({'key1' => 'value1'}) } it { is_expected.to run \ -- cgit v1.2.3 From 3fc7694d9fd46b4647eb562170af48ed819f64ab Mon Sep 17 00:00:00 2001 From: tphoney Date: Tue, 21 Feb 2017 15:12:08 +0000 Subject: remove unsupported platforms and future parser --- spec/acceptance/abs_spec.rb | 2 +- spec/acceptance/anchor_spec.rb | 2 +- spec/acceptance/any2array_spec.rb | 2 +- spec/acceptance/base64_spec.rb | 2 +- spec/acceptance/bool2num_spec.rb | 2 +- spec/acceptance/capitalize_spec.rb | 2 +- spec/acceptance/ceiling_spec.rb | 2 +- spec/acceptance/chomp_spec.rb | 2 +- spec/acceptance/chop_spec.rb | 2 +- spec/acceptance/clamp_spec.rb | 2 +- spec/acceptance/concat_spec.rb | 2 +- spec/acceptance/count_spec.rb | 2 +- spec/acceptance/deep_merge_spec.rb | 2 +- spec/acceptance/defined_with_params_spec.rb | 2 +- spec/acceptance/delete_at_spec.rb | 2 +- spec/acceptance/delete_spec.rb | 2 +- spec/acceptance/delete_undef_values_spec.rb | 2 +- spec/acceptance/delete_values_spec.rb | 2 +- spec/acceptance/difference_spec.rb | 2 +- spec/acceptance/dirname_spec.rb | 2 +- spec/acceptance/downcase_spec.rb | 2 +- spec/acceptance/empty_spec.rb | 2 +- spec/acceptance/flatten_spec.rb | 2 +- spec/acceptance/floor_spec.rb | 2 +- spec/acceptance/fqdn_rand_string_spec.rb | 2 +- spec/acceptance/fqdn_rotate_spec.rb | 2 +- spec/acceptance/get_module_path_spec.rb | 2 +- spec/acceptance/getparam_spec.rb | 2 +- spec/acceptance/getvar_spec.rb | 2 +- spec/acceptance/grep_spec.rb | 2 +- spec/acceptance/has_interface_with_spec.rb | 2 +- spec/acceptance/has_ip_address_spec.rb | 2 +- spec/acceptance/has_ip_network_spec.rb | 2 +- spec/acceptance/has_key_spec.rb | 2 +- spec/acceptance/hash_spec.rb | 2 +- spec/acceptance/intersection_spec.rb | 2 +- spec/acceptance/is_a_spec.rb | 2 +- spec/acceptance/is_array_spec.rb | 2 +- spec/acceptance/is_bool_spec.rb | 2 +- spec/acceptance/is_domain_name_spec.rb | 2 +- spec/acceptance/is_float_spec.rb | 2 +- spec/acceptance/is_function_available_spec.rb | 2 +- spec/acceptance/is_hash_spec.rb | 2 +- spec/acceptance/is_integer_spec.rb | 2 +- spec/acceptance/is_ip_address_spec.rb | 2 +- spec/acceptance/is_ipv4_address_spec.rb | 2 +- spec/acceptance/is_ipv6_address_spec.rb | 2 +- spec/acceptance/is_mac_address_spec.rb | 2 +- spec/acceptance/is_numeric_spec.rb | 2 +- spec/acceptance/is_string_spec.rb | 2 +- spec/acceptance/join_keys_to_values_spec.rb | 2 +- spec/acceptance/join_spec.rb | 2 +- spec/acceptance/keys_spec.rb | 2 +- spec/acceptance/loadjson_spec.rb | 2 +- spec/acceptance/loadyaml_spec.rb | 2 +- spec/acceptance/lstrip_spec.rb | 2 +- spec/acceptance/max_spec.rb | 2 +- spec/acceptance/member_spec.rb | 2 +- spec/acceptance/merge_spec.rb | 2 +- spec/acceptance/min_spec.rb | 2 +- spec/acceptance/num2bool_spec.rb | 2 +- spec/acceptance/parsejson_spec.rb | 2 +- spec/acceptance/parseyaml_spec.rb | 2 +- spec/acceptance/pick_default_spec.rb | 2 +- spec/acceptance/pick_spec.rb | 2 +- spec/acceptance/prefix_spec.rb | 2 +- spec/acceptance/pw_hash_spec.rb | 2 +- spec/acceptance/range_spec.rb | 2 +- spec/acceptance/reject_spec.rb | 2 +- spec/acceptance/reverse_spec.rb | 2 +- spec/acceptance/rstrip_spec.rb | 2 +- spec/acceptance/shuffle_spec.rb | 2 +- spec/acceptance/size_spec.rb | 2 +- spec/acceptance/sort_spec.rb | 2 +- spec/acceptance/squeeze_spec.rb | 2 +- spec/acceptance/str2bool_spec.rb | 2 +- spec/acceptance/str2saltedsha512_spec.rb | 2 +- spec/acceptance/strftime_spec.rb | 2 +- spec/acceptance/strip_spec.rb | 2 +- spec/acceptance/suffix_spec.rb | 2 +- spec/acceptance/swapcase_spec.rb | 2 +- spec/acceptance/time_spec.rb | 2 +- spec/acceptance/to_bytes_spec.rb | 2 +- spec/acceptance/try_get_value_spec.rb | 2 +- spec/acceptance/type_spec.rb | 10 ++++----- spec/acceptance/union_spec.rb | 2 +- spec/acceptance/unique_spec.rb | 2 +- spec/acceptance/unsupported_spec.rb | 11 ---------- spec/acceptance/upcase_spec.rb | 2 +- spec/acceptance/uriescape_spec.rb | 2 +- spec/acceptance/validate_absolute_path_spec.rb | 2 +- spec/acceptance/validate_array_spec.rb | 2 +- spec/acceptance/validate_augeas_spec.rb | 2 +- spec/acceptance/validate_bool_spec.rb | 2 +- spec/acceptance/validate_cmd_spec.rb | 2 +- spec/acceptance/validate_hash_spec.rb | 2 +- spec/acceptance/validate_ipv4_address_spec.rb | 2 +- spec/acceptance/validate_ipv6_address_spec.rb | 2 +- spec/acceptance/validate_re_spec.rb | 2 +- spec/acceptance/validate_slength_spec.rb | 2 +- spec/acceptance/validate_string_spec.rb | 2 +- spec/acceptance/values_at_spec.rb | 2 +- spec/acceptance/values_spec.rb | 9 ++------- spec/acceptance/zip_spec.rb | 28 +++++--------------------- spec/spec_helper_acceptance.rb | 15 -------------- 105 files changed, 112 insertions(+), 161 deletions(-) delete mode 100755 spec/acceptance/unsupported_spec.rb (limited to 'spec') diff --git a/spec/acceptance/abs_spec.rb b/spec/acceptance/abs_spec.rb index 6e41e2f..5af436f 100755 --- a/spec/acceptance/abs_spec.rb +++ b/spec/acceptance/abs_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'abs function' do describe 'success' do it 'should accept a string' do pp = <<-EOS diff --git a/spec/acceptance/anchor_spec.rb b/spec/acceptance/anchor_spec.rb index 5bc2bbb..24a9064 100755 --- a/spec/acceptance/anchor_spec.rb +++ b/spec/acceptance/anchor_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'anchor type', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'anchor type' do describe 'success' do it 'should effect proper chaining of resources' do pp = <<-EOS diff --git a/spec/acceptance/any2array_spec.rb b/spec/acceptance/any2array_spec.rb index 18ea4cd..8a13911 100755 --- a/spec/acceptance/any2array_spec.rb +++ b/spec/acceptance/any2array_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'any2array function' do describe 'success' do it 'should create an empty array' do pp = <<-EOS diff --git a/spec/acceptance/base64_spec.rb b/spec/acceptance/base64_spec.rb index 97e1738..e9096a7 100755 --- a/spec/acceptance/base64_spec.rb +++ b/spec/acceptance/base64_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'base64 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'base64 function' do describe 'success' do it 'should encode then decode a string' do pp = <<-EOS diff --git a/spec/acceptance/bool2num_spec.rb b/spec/acceptance/bool2num_spec.rb index 52ff75b..c69acc6 100755 --- a/spec/acceptance/bool2num_spec.rb +++ b/spec/acceptance/bool2num_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'bool2num function' do describe 'success' do ['false', 'f', '0', 'n', 'no'].each do |bool| it "should convert a given boolean, #{bool}, to 0" do diff --git a/spec/acceptance/capitalize_spec.rb b/spec/acceptance/capitalize_spec.rb index e5e7b7b..03d01a8 100755 --- a/spec/acceptance/capitalize_spec.rb +++ b/spec/acceptance/capitalize_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'capitalize function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'capitalize function' do describe 'success' do it 'should capitalize the first letter of a string' do pp = <<-EOS diff --git a/spec/acceptance/ceiling_spec.rb b/spec/acceptance/ceiling_spec.rb index 557986e..895e4a0 100755 --- a/spec/acceptance/ceiling_spec.rb +++ b/spec/acceptance/ceiling_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'ceiling function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'ceiling function' do describe 'success' do it 'ceilings floats' do pp = <<-EOS diff --git a/spec/acceptance/chomp_spec.rb b/spec/acceptance/chomp_spec.rb index f6c1595..56e0876 100755 --- a/spec/acceptance/chomp_spec.rb +++ b/spec/acceptance/chomp_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'chomp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'chomp function' do describe 'success' do it 'should eat the newline' do pp = <<-EOS diff --git a/spec/acceptance/chop_spec.rb b/spec/acceptance/chop_spec.rb index a16a710..0993806 100755 --- a/spec/acceptance/chop_spec.rb +++ b/spec/acceptance/chop_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'chop function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'chop function' do describe 'success' do it 'should eat the last character' do pp = <<-EOS diff --git a/spec/acceptance/clamp_spec.rb b/spec/acceptance/clamp_spec.rb index 0189258..e8ccb96 100755 --- a/spec/acceptance/clamp_spec.rb +++ b/spec/acceptance/clamp_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'clamp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'clamp function' do describe 'success' do it 'clamps list of values' do pp = <<-EOS diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index c472db6..8d184d1 100755 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'concat function' do describe 'success' do it 'should concat one array to another' do pp = <<-EOS diff --git a/spec/acceptance/count_spec.rb b/spec/acceptance/count_spec.rb index fe7ca9d..18c039d 100755 --- a/spec/acceptance/count_spec.rb +++ b/spec/acceptance/count_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'count function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'count function' do describe 'success' do it 'should count elements in an array' do pp = <<-EOS diff --git a/spec/acceptance/deep_merge_spec.rb b/spec/acceptance/deep_merge_spec.rb index c0f9b12..8222f24 100755 --- a/spec/acceptance/deep_merge_spec.rb +++ b/spec/acceptance/deep_merge_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'deep_merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'deep_merge function' do describe 'success' do it 'should deep merge two hashes' do pp = <<-EOS diff --git a/spec/acceptance/defined_with_params_spec.rb b/spec/acceptance/defined_with_params_spec.rb index fc54450..a332bd6 100755 --- a/spec/acceptance/defined_with_params_spec.rb +++ b/spec/acceptance/defined_with_params_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'defined_with_params function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'defined_with_params function' do describe 'success' do it 'should successfully notify' do pp = <<-EOS diff --git a/spec/acceptance/delete_at_spec.rb b/spec/acceptance/delete_at_spec.rb index db0c01f..d4f852a 100755 --- a/spec/acceptance/delete_at_spec.rb +++ b/spec/acceptance/delete_at_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'delete_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'delete_at function' do describe 'success' do it 'should delete elements of the array' do pp = <<-EOS diff --git a/spec/acceptance/delete_spec.rb b/spec/acceptance/delete_spec.rb index a28604c..f85b093 100755 --- a/spec/acceptance/delete_spec.rb +++ b/spec/acceptance/delete_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'delete function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'delete function' do describe 'success' do it 'should delete elements of the array' do pp = <<-EOS diff --git a/spec/acceptance/delete_undef_values_spec.rb b/spec/acceptance/delete_undef_values_spec.rb index b7eda19..af45a92 100755 --- a/spec/acceptance/delete_undef_values_spec.rb +++ b/spec/acceptance/delete_undef_values_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'delete_undef_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'delete_undef_values function' do describe 'success' do it 'should delete elements of the array' do pp = <<-EOS diff --git a/spec/acceptance/delete_values_spec.rb b/spec/acceptance/delete_values_spec.rb index 6d2369c..04b6920 100755 --- a/spec/acceptance/delete_values_spec.rb +++ b/spec/acceptance/delete_values_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'delete_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'delete_values function' do describe 'success' do it 'should delete elements of the hash' do pp = <<-EOS diff --git a/spec/acceptance/difference_spec.rb b/spec/acceptance/difference_spec.rb index 2fae5c4..68f6bbe 100755 --- a/spec/acceptance/difference_spec.rb +++ b/spec/acceptance/difference_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'difference function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'difference function' do describe 'success' do it 'returns non-duplicates in the first array' do pp = <<-EOS diff --git a/spec/acceptance/dirname_spec.rb b/spec/acceptance/dirname_spec.rb index 97913dd..db83f0f 100755 --- a/spec/acceptance/dirname_spec.rb +++ b/spec/acceptance/dirname_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'dirname function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'dirname function' do describe 'success' do context 'absolute path' do it 'returns the dirname' do diff --git a/spec/acceptance/downcase_spec.rb b/spec/acceptance/downcase_spec.rb index bc4e706..300bcfa 100755 --- a/spec/acceptance/downcase_spec.rb +++ b/spec/acceptance/downcase_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'downcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'downcase function' do describe 'success' do it 'returns the downcase' do pp = <<-EOS diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb index 2d4df90..97b7333 100755 --- a/spec/acceptance/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'empty function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'empty function' do describe 'success' do it 'recognizes empty strings' do pp = <<-EOS diff --git a/spec/acceptance/flatten_spec.rb b/spec/acceptance/flatten_spec.rb index c4d66e0..289eec9 100755 --- a/spec/acceptance/flatten_spec.rb +++ b/spec/acceptance/flatten_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'flatten function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'flatten function' do describe 'success' do it 'flattens arrays' do pp = <<-EOS diff --git a/spec/acceptance/floor_spec.rb b/spec/acceptance/floor_spec.rb index 0dcdad9..8259d2a 100755 --- a/spec/acceptance/floor_spec.rb +++ b/spec/acceptance/floor_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'floor function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'floor function' do describe 'success' do it 'floors floats' do pp = <<-EOS diff --git a/spec/acceptance/fqdn_rand_string_spec.rb b/spec/acceptance/fqdn_rand_string_spec.rb index 065a517..af1b2a9 100644 --- a/spec/acceptance/fqdn_rand_string_spec.rb +++ b/spec/acceptance/fqdn_rand_string_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'fqdn_rand_string function' do describe 'success' do include_context "with faked facts" context "when the FQDN is 'fakehost.localdomain'" do diff --git a/spec/acceptance/fqdn_rotate_spec.rb b/spec/acceptance/fqdn_rotate_spec.rb index 404351f..66e94a9 100755 --- a/spec/acceptance/fqdn_rotate_spec.rb +++ b/spec/acceptance/fqdn_rotate_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'fqdn_rotate function' do describe 'success' do include_context "with faked facts" context "when the FQDN is 'fakehost.localdomain'" do diff --git a/spec/acceptance/get_module_path_spec.rb b/spec/acceptance/get_module_path_spec.rb index 6ac690c..3d10251 100755 --- a/spec/acceptance/get_module_path_spec.rb +++ b/spec/acceptance/get_module_path_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'get_module_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'get_module_path function' do describe 'success' do it 'get_module_paths dne' do pp = <<-EOS diff --git a/spec/acceptance/getparam_spec.rb b/spec/acceptance/getparam_spec.rb index b1a677e..bd12154 100755 --- a/spec/acceptance/getparam_spec.rb +++ b/spec/acceptance/getparam_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'getparam function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'getparam function' do describe 'success' do it 'getparam a notify' do pp = <<-EOS diff --git a/spec/acceptance/getvar_spec.rb b/spec/acceptance/getvar_spec.rb index 333c467..605cdce 100755 --- a/spec/acceptance/getvar_spec.rb +++ b/spec/acceptance/getvar_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'getvar function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'getvar function' do describe 'success' do it 'getvars from classes' do pp = <<-EOS diff --git a/spec/acceptance/grep_spec.rb b/spec/acceptance/grep_spec.rb index b39d48e..7c35ee4 100755 --- a/spec/acceptance/grep_spec.rb +++ b/spec/acceptance/grep_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'grep function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'grep function' do describe 'success' do it 'greps arrays' do pp = <<-EOS diff --git a/spec/acceptance/has_interface_with_spec.rb b/spec/acceptance/has_interface_with_spec.rb index 9590193..fd33af5 100755 --- a/spec/acceptance/has_interface_with_spec.rb +++ b/spec/acceptance/has_interface_with_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'has_interface_with function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do +describe 'has_interface_with function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do describe 'success' do it 'has_interface_with existing ipaddress' do pp = <<-EOS diff --git a/spec/acceptance/has_ip_address_spec.rb b/spec/acceptance/has_ip_address_spec.rb index 149a10d..878d921 100755 --- a/spec/acceptance/has_ip_address_spec.rb +++ b/spec/acceptance/has_ip_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'has_ip_address function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do +describe 'has_ip_address function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do describe 'success' do it 'has_ip_address existing ipaddress' do pp = <<-EOS diff --git a/spec/acceptance/has_ip_network_spec.rb b/spec/acceptance/has_ip_network_spec.rb index 7d2f34e..f7a7d35 100755 --- a/spec/acceptance/has_ip_network_spec.rb +++ b/spec/acceptance/has_ip_network_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'has_ip_network function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do +describe 'has_ip_network function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do describe 'success' do it 'has_ip_network existing ipaddress' do pp = <<-EOS diff --git a/spec/acceptance/has_key_spec.rb b/spec/acceptance/has_key_spec.rb index c8557cb..661c122 100755 --- a/spec/acceptance/has_key_spec.rb +++ b/spec/acceptance/has_key_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'has_key function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'has_key function' do describe 'success' do it 'has_keys in hashes' do pp = <<-EOS diff --git a/spec/acceptance/hash_spec.rb b/spec/acceptance/hash_spec.rb index ed53834..85da50b 100755 --- a/spec/acceptance/hash_spec.rb +++ b/spec/acceptance/hash_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'hash function' do describe 'success' do it 'hashs arrays' do pp = <<-EOS diff --git a/spec/acceptance/intersection_spec.rb b/spec/acceptance/intersection_spec.rb index 66b8652..02d4e7d 100755 --- a/spec/acceptance/intersection_spec.rb +++ b/spec/acceptance/intersection_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'intersection function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'intersection function' do describe 'success' do it 'intersections arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_a_spec.rb b/spec/acceptance/is_a_spec.rb index 355fd83..fb0019a 100644 --- a/spec/acceptance/is_a_spec.rb +++ b/spec/acceptance/is_a_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper_acceptance' if get_puppet_version =~ /^4/ - describe 'is_a function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do + describe 'is_a function' do it 'should match a string' do pp = <<-EOS if 'hello world'.is_a(String) { diff --git a/spec/acceptance/is_array_spec.rb b/spec/acceptance/is_array_spec.rb index 9c6bad7..1a83417 100755 --- a/spec/acceptance/is_array_spec.rb +++ b/spec/acceptance/is_array_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_array function' do describe 'success' do it 'is_arrays arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_bool_spec.rb b/spec/acceptance/is_bool_spec.rb index 60079f9..823cb46 100755 --- a/spec/acceptance/is_bool_spec.rb +++ b/spec/acceptance/is_bool_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_bool function' do describe 'success' do it 'is_bools arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_domain_name_spec.rb b/spec/acceptance/is_domain_name_spec.rb index e0f03fa..884b0bc 100755 --- a/spec/acceptance/is_domain_name_spec.rb +++ b/spec/acceptance/is_domain_name_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_domain_name function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_domain_name function' do describe 'success' do it 'is_domain_names arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_float_spec.rb b/spec/acceptance/is_float_spec.rb index 338ba58..0b38d94 100755 --- a/spec/acceptance/is_float_spec.rb +++ b/spec/acceptance/is_float_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_float function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_float function' do describe 'success' do it 'is_floats arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_function_available_spec.rb b/spec/acceptance/is_function_available_spec.rb index 2b5dd6d..f8191ee 100755 --- a/spec/acceptance/is_function_available_spec.rb +++ b/spec/acceptance/is_function_available_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_function_available function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_function_available function' do describe 'success' do it 'is_function_availables arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_hash_spec.rb b/spec/acceptance/is_hash_spec.rb index 2ef310a..64f016c 100755 --- a/spec/acceptance/is_hash_spec.rb +++ b/spec/acceptance/is_hash_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_hash function' do describe 'success' do it 'is_hashs arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_integer_spec.rb b/spec/acceptance/is_integer_spec.rb index bf6902b..7333687 100755 --- a/spec/acceptance/is_integer_spec.rb +++ b/spec/acceptance/is_integer_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_integer function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_integer function' do describe 'success' do it 'is_integers arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_ip_address_spec.rb b/spec/acceptance/is_ip_address_spec.rb index ed7a854..2c62c77 100755 --- a/spec/acceptance/is_ip_address_spec.rb +++ b/spec/acceptance/is_ip_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_ip_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_ip_address function' do describe 'success' do it 'is_ip_addresss ipv4' do pp = <<-EOS diff --git a/spec/acceptance/is_ipv4_address_spec.rb b/spec/acceptance/is_ipv4_address_spec.rb index 5dc6bf5..abe26d8 100755 --- a/spec/acceptance/is_ipv4_address_spec.rb +++ b/spec/acceptance/is_ipv4_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_ipv4_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_ipv4_address function' do describe 'success' do it 'is_ipv4_addresss' do pp = <<-EOS diff --git a/spec/acceptance/is_ipv6_address_spec.rb b/spec/acceptance/is_ipv6_address_spec.rb index 1e88be8..73a3fa4 100755 --- a/spec/acceptance/is_ipv6_address_spec.rb +++ b/spec/acceptance/is_ipv6_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_ipv6_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_ipv6_address function' do describe 'success' do it 'is_ipv6_addresss' do pp = <<-EOS diff --git a/spec/acceptance/is_mac_address_spec.rb b/spec/acceptance/is_mac_address_spec.rb index a2c892f..617bef6 100755 --- a/spec/acceptance/is_mac_address_spec.rb +++ b/spec/acceptance/is_mac_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_mac_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_mac_address function' do describe 'success' do it 'is_mac_addresss a mac' do pp = <<-EOS diff --git a/spec/acceptance/is_numeric_spec.rb b/spec/acceptance/is_numeric_spec.rb index 21c8988..7e65384 100755 --- a/spec/acceptance/is_numeric_spec.rb +++ b/spec/acceptance/is_numeric_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_numeric function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_numeric function' do describe 'success' do it 'is_numerics arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_string_spec.rb b/spec/acceptance/is_string_spec.rb index f526888..bee5e01 100755 --- a/spec/acceptance/is_string_spec.rb +++ b/spec/acceptance/is_string_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_string function' do describe 'success' do it 'is_strings arrays' do pp = <<-EOS diff --git a/spec/acceptance/join_keys_to_values_spec.rb b/spec/acceptance/join_keys_to_values_spec.rb index 70493fd..ae6947e 100755 --- a/spec/acceptance/join_keys_to_values_spec.rb +++ b/spec/acceptance/join_keys_to_values_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'join_keys_to_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'join_keys_to_values function' do describe 'success' do it 'join_keys_to_valuess hashes' do pp = <<-EOS diff --git a/spec/acceptance/join_spec.rb b/spec/acceptance/join_spec.rb index 5397ce2..75b88d8 100755 --- a/spec/acceptance/join_spec.rb +++ b/spec/acceptance/join_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'join function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'join function' do describe 'success' do it 'joins arrays' do pp = <<-EOS diff --git a/spec/acceptance/keys_spec.rb b/spec/acceptance/keys_spec.rb index 176918e..65bfe28 100755 --- a/spec/acceptance/keys_spec.rb +++ b/spec/acceptance/keys_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'keys function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'keys function' do describe 'success' do it 'keyss hashes' do pp = <<-EOS diff --git a/spec/acceptance/loadjson_spec.rb b/spec/acceptance/loadjson_spec.rb index 2992c37..ebd5307 100644 --- a/spec/acceptance/loadjson_spec.rb +++ b/spec/acceptance/loadjson_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_acceptance' tmpdir = default.tmpdir('stdlib') -describe 'loadjson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'loadjson function' do describe 'success' do it 'loadjsons array of values' do shell("echo '{\"aaa\":1,\"bbb\":2,\"ccc\":3,\"ddd\":4}' > #{tmpdir}/testjson.json") diff --git a/spec/acceptance/loadyaml_spec.rb b/spec/acceptance/loadyaml_spec.rb index ba3f0b7..57fb8cb 100644 --- a/spec/acceptance/loadyaml_spec.rb +++ b/spec/acceptance/loadyaml_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_acceptance' tmpdir = default.tmpdir('stdlib') -describe 'loadyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'loadyaml function' do describe 'success' do it 'loadyamls array of values' do shell("echo '--- diff --git a/spec/acceptance/lstrip_spec.rb b/spec/acceptance/lstrip_spec.rb index 3dc952f..eba5d0d 100755 --- a/spec/acceptance/lstrip_spec.rb +++ b/spec/acceptance/lstrip_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'lstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'lstrip function' do describe 'success' do it 'lstrips arrays' do pp = <<-EOS diff --git a/spec/acceptance/max_spec.rb b/spec/acceptance/max_spec.rb index f04e3d2..3caa813 100755 --- a/spec/acceptance/max_spec.rb +++ b/spec/acceptance/max_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'max function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'max function' do describe 'success' do it 'maxs arrays' do pp = <<-EOS diff --git a/spec/acceptance/member_spec.rb b/spec/acceptance/member_spec.rb index fe75a07..2bcadd3 100755 --- a/spec/acceptance/member_spec.rb +++ b/spec/acceptance/member_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'member function' do shared_examples 'item found' do it 'should output correctly' do apply_manifest(pp, :catch_failures => true) do |r| diff --git a/spec/acceptance/merge_spec.rb b/spec/acceptance/merge_spec.rb index 227b994..814db4e 100755 --- a/spec/acceptance/merge_spec.rb +++ b/spec/acceptance/merge_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'merge function' do describe 'success' do it 'should merge two hashes' do pp = <<-EOS diff --git a/spec/acceptance/min_spec.rb b/spec/acceptance/min_spec.rb index 509092d..7b18fac 100755 --- a/spec/acceptance/min_spec.rb +++ b/spec/acceptance/min_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'min function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'min function' do describe 'success' do it 'mins arrays' do pp = <<-EOS diff --git a/spec/acceptance/num2bool_spec.rb b/spec/acceptance/num2bool_spec.rb index 1d99ba0..00d0ddc 100755 --- a/spec/acceptance/num2bool_spec.rb +++ b/spec/acceptance/num2bool_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'num2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'num2bool function' do describe 'success' do it 'bools positive numbers and numeric strings as true' do pp = <<-EOS diff --git a/spec/acceptance/parsejson_spec.rb b/spec/acceptance/parsejson_spec.rb index d0e3de8..52133e4 100755 --- a/spec/acceptance/parsejson_spec.rb +++ b/spec/acceptance/parsejson_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'parsejson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'parsejson function' do describe 'success' do it 'parses valid json' do pp = <<-EOS diff --git a/spec/acceptance/parseyaml_spec.rb b/spec/acceptance/parseyaml_spec.rb index 64511f1..acbda46 100755 --- a/spec/acceptance/parseyaml_spec.rb +++ b/spec/acceptance/parseyaml_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'parseyaml function' do describe 'success' do it 'parses valid yaml' do pp = <<-EOS diff --git a/spec/acceptance/pick_default_spec.rb b/spec/acceptance/pick_default_spec.rb index a663f54..e7e25ab 100755 --- a/spec/acceptance/pick_default_spec.rb +++ b/spec/acceptance/pick_default_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'pick_default function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'pick_default function' do describe 'success' do it 'pick_defaults a default value' do pp = <<-EOS diff --git a/spec/acceptance/pick_spec.rb b/spec/acceptance/pick_spec.rb index 46cf63f..c70b2d9 100755 --- a/spec/acceptance/pick_spec.rb +++ b/spec/acceptance/pick_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'pick function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'pick function' do describe 'success' do it 'picks a default value' do pp = <<-EOS diff --git a/spec/acceptance/prefix_spec.rb b/spec/acceptance/prefix_spec.rb index de55530..58c691d 100755 --- a/spec/acceptance/prefix_spec.rb +++ b/spec/acceptance/prefix_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'prefix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'prefix function' do describe 'success' do it 'prefixes array of values' do pp = <<-EOS diff --git a/spec/acceptance/pw_hash_spec.rb b/spec/acceptance/pw_hash_spec.rb index cd4cb87..829d087 100644 --- a/spec/acceptance/pw_hash_spec.rb +++ b/spec/acceptance/pw_hash_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper_acceptance' # Windows and OS X do not have useful implementations of crypt(3) -describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Darwin', 'SLES']).include?(fact('operatingsystem')) do +describe 'pw_hash function', :unless => (['windows', 'Darwin', 'SLES']).include?(fact('operatingsystem')) do describe 'success' do it 'hashes passwords' do pp = <<-EOS diff --git a/spec/acceptance/range_spec.rb b/spec/acceptance/range_spec.rb index a3ccd33..f57f884 100755 --- a/spec/acceptance/range_spec.rb +++ b/spec/acceptance/range_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'range function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'range function' do describe 'success' do it 'ranges letters' do pp = <<-EOS diff --git a/spec/acceptance/reject_spec.rb b/spec/acceptance/reject_spec.rb index 7f16a00..ce4342d 100755 --- a/spec/acceptance/reject_spec.rb +++ b/spec/acceptance/reject_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'reject function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'reject function' do describe 'success' do it 'rejects array of values' do pp = <<-EOS diff --git a/spec/acceptance/reverse_spec.rb b/spec/acceptance/reverse_spec.rb index c3f0156..3b5dfad 100755 --- a/spec/acceptance/reverse_spec.rb +++ b/spec/acceptance/reverse_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'reverse function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'reverse function' do describe 'success' do it 'reverses strings' do pp = <<-EOS diff --git a/spec/acceptance/rstrip_spec.rb b/spec/acceptance/rstrip_spec.rb index b57a8b0..150dac1 100755 --- a/spec/acceptance/rstrip_spec.rb +++ b/spec/acceptance/rstrip_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'rstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'rstrip function' do describe 'success' do it 'rstrips arrays' do pp = <<-EOS diff --git a/spec/acceptance/shuffle_spec.rb b/spec/acceptance/shuffle_spec.rb index b840d1f..0738383 100755 --- a/spec/acceptance/shuffle_spec.rb +++ b/spec/acceptance/shuffle_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'shuffle function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'shuffle function' do describe 'success' do it 'shuffles arrays' do pp = <<-EOS diff --git a/spec/acceptance/size_spec.rb b/spec/acceptance/size_spec.rb index a52b778..6390c20 100755 --- a/spec/acceptance/size_spec.rb +++ b/spec/acceptance/size_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'size function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'size function' do describe 'success' do it 'single string size' do pp = <<-EOS diff --git a/spec/acceptance/sort_spec.rb b/spec/acceptance/sort_spec.rb index c85bfab..e7ff7f7 100755 --- a/spec/acceptance/sort_spec.rb +++ b/spec/acceptance/sort_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'sort function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'sort function' do describe 'success' do it 'sorts arrays' do pp = <<-EOS diff --git a/spec/acceptance/squeeze_spec.rb b/spec/acceptance/squeeze_spec.rb index 400a458..3324691 100755 --- a/spec/acceptance/squeeze_spec.rb +++ b/spec/acceptance/squeeze_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'squeeze function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'squeeze function' do describe 'success' do it 'squeezes arrays' do pp = <<-EOS diff --git a/spec/acceptance/str2bool_spec.rb b/spec/acceptance/str2bool_spec.rb index cf549da..9a8c06c 100755 --- a/spec/acceptance/str2bool_spec.rb +++ b/spec/acceptance/str2bool_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'str2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'str2bool function' do describe 'success' do it 'works with "y"' do pp = <<-EOS diff --git a/spec/acceptance/str2saltedsha512_spec.rb b/spec/acceptance/str2saltedsha512_spec.rb index 993e63b..5f03924 100755 --- a/spec/acceptance/str2saltedsha512_spec.rb +++ b/spec/acceptance/str2saltedsha512_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'str2saltedsha512 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'str2saltedsha512 function' do describe 'success' do it 'works with "y"' do pp = <<-EOS diff --git a/spec/acceptance/strftime_spec.rb b/spec/acceptance/strftime_spec.rb index 53b7f90..38521b0 100755 --- a/spec/acceptance/strftime_spec.rb +++ b/spec/acceptance/strftime_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'strftime function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'strftime function' do describe 'success' do it 'gives the Century' do pp = <<-EOS diff --git a/spec/acceptance/strip_spec.rb b/spec/acceptance/strip_spec.rb index 906fd7a..05cd395 100755 --- a/spec/acceptance/strip_spec.rb +++ b/spec/acceptance/strip_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'strip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'strip function' do describe 'success' do it 'strips arrays' do pp = <<-EOS diff --git a/spec/acceptance/suffix_spec.rb b/spec/acceptance/suffix_spec.rb index 630f866..60a6264 100755 --- a/spec/acceptance/suffix_spec.rb +++ b/spec/acceptance/suffix_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'suffix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'suffix function' do describe 'success' do it 'suffixes array of values' do pp = <<-EOS diff --git a/spec/acceptance/swapcase_spec.rb b/spec/acceptance/swapcase_spec.rb index b7894fb..9f94c0d 100755 --- a/spec/acceptance/swapcase_spec.rb +++ b/spec/acceptance/swapcase_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'swapcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'swapcase function' do describe 'success' do it 'works with strings' do pp = <<-EOS diff --git a/spec/acceptance/time_spec.rb b/spec/acceptance/time_spec.rb index cdb2960..dae1166 100755 --- a/spec/acceptance/time_spec.rb +++ b/spec/acceptance/time_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'time function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'time function' do describe 'success' do it 'gives the time' do pp = <<-EOS diff --git a/spec/acceptance/to_bytes_spec.rb b/spec/acceptance/to_bytes_spec.rb index 2b4c61f..b1015a3 100755 --- a/spec/acceptance/to_bytes_spec.rb +++ b/spec/acceptance/to_bytes_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'to_bytes function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'to_bytes function' do describe 'success' do it 'converts kB to B' do pp = <<-EOS diff --git a/spec/acceptance/try_get_value_spec.rb b/spec/acceptance/try_get_value_spec.rb index c0bf38a..716241c 100755 --- a/spec/acceptance/try_get_value_spec.rb +++ b/spec/acceptance/try_get_value_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'try_get_value function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'try_get_value function' do describe 'success' do it 'gets a value' do pp = <<-EOS diff --git a/spec/acceptance/type_spec.rb b/spec/acceptance/type_spec.rb index 67e3248..7cf445b 100755 --- a/spec/acceptance/type_spec.rb +++ b/spec/acceptance/type_spec.rb @@ -1,29 +1,29 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'type function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || is_future_parser_enabled?) do +describe 'type function' do describe 'success' do it 'types arrays' do pp = <<-EOS $a = ["the","public","art","galleries"] # Anagram: Large picture halls, I bet $o = type($a) - notice(inline_template('type is <%= @o.inspect %>')) + notice(inline_template('type is <%= @o.to_s %>')) EOS apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/type is "array"/) + expect(r.stdout).to match(/type is Tuple\[String, String, String, String\]/) end end it 'types strings' do pp = <<-EOS $a = "blowzy night-frumps vex'd jack q" $o = type($a) - notice(inline_template('type is <%= @o.inspect %>')) + notice(inline_template('type is <%= @o.to_s %>')) EOS apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/type is "string"/) + expect(r.stdout).to match(/type is String/) end end it 'types hashes' diff --git a/spec/acceptance/union_spec.rb b/spec/acceptance/union_spec.rb index 160fd7b..7229bf5 100755 --- a/spec/acceptance/union_spec.rb +++ b/spec/acceptance/union_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'union function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'union function' do describe 'success' do it 'unions arrays' do pp = <<-EOS diff --git a/spec/acceptance/unique_spec.rb b/spec/acceptance/unique_spec.rb index bfadad1..7fb5eca 100755 --- a/spec/acceptance/unique_spec.rb +++ b/spec/acceptance/unique_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'unique function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'unique function' do describe 'success' do it 'uniques arrays' do pp = <<-EOS diff --git a/spec/acceptance/unsupported_spec.rb b/spec/acceptance/unsupported_spec.rb deleted file mode 100755 index 1c559f6..0000000 --- a/spec/acceptance/unsupported_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - it 'should fail' do - pp = <<-EOS - class { 'mysql::server': } - EOS - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported osfamily/i) - end -end diff --git a/spec/acceptance/upcase_spec.rb b/spec/acceptance/upcase_spec.rb index 3d2906d..1782309 100755 --- a/spec/acceptance/upcase_spec.rb +++ b/spec/acceptance/upcase_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'upcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'upcase function' do describe 'success' do it 'upcases arrays' do pp = <<-EOS diff --git a/spec/acceptance/uriescape_spec.rb b/spec/acceptance/uriescape_spec.rb index 7e30205..e123425 100755 --- a/spec/acceptance/uriescape_spec.rb +++ b/spec/acceptance/uriescape_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'uriescape function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'uriescape function' do describe 'success' do it 'uriescape strings' do pp = <<-EOS diff --git a/spec/acceptance/validate_absolute_path_spec.rb b/spec/acceptance/validate_absolute_path_spec.rb index 7082e84..880850d 100755 --- a/spec/acceptance/validate_absolute_path_spec.rb +++ b/spec/acceptance/validate_absolute_path_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_absolute_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_absolute_path function' do describe 'success' do %w{ C:/ diff --git a/spec/acceptance/validate_array_spec.rb b/spec/acceptance/validate_array_spec.rb index 2f549d5..a76321d 100755 --- a/spec/acceptance/validate_array_spec.rb +++ b/spec/acceptance/validate_array_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_array function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/validate_augeas_spec.rb b/spec/acceptance/validate_augeas_spec.rb index 71a4c84..be213d3 100755 --- a/spec/acceptance/validate_augeas_spec.rb +++ b/spec/acceptance/validate_augeas_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_augeas function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows')) do +describe 'validate_augeas function', :unless => (fact('osfamily') == 'windows') do describe 'prep' do it 'installs augeas for tests' end diff --git a/spec/acceptance/validate_bool_spec.rb b/spec/acceptance/validate_bool_spec.rb index 5c52d0f..993f9ef 100755 --- a/spec/acceptance/validate_bool_spec.rb +++ b/spec/acceptance/validate_bool_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_bool function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/validate_cmd_spec.rb b/spec/acceptance/validate_cmd_spec.rb index 5ac66fd..5fc7b94 100755 --- a/spec/acceptance/validate_cmd_spec.rb +++ b/spec/acceptance/validate_cmd_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_cmd function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_cmd function' do describe 'success' do it 'validates a true command' do pp = <<-EOS diff --git a/spec/acceptance/validate_hash_spec.rb b/spec/acceptance/validate_hash_spec.rb index 637df0a..fc0f079 100755 --- a/spec/acceptance/validate_hash_spec.rb +++ b/spec/acceptance/validate_hash_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_hash function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/validate_ipv4_address_spec.rb b/spec/acceptance/validate_ipv4_address_spec.rb index 64841c3..67d3139 100755 --- a/spec/acceptance/validate_ipv4_address_spec.rb +++ b/spec/acceptance/validate_ipv4_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_ipv4_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_ipv4_address function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/validate_ipv6_address_spec.rb b/spec/acceptance/validate_ipv6_address_spec.rb index 6426d1a..eaa845d 100755 --- a/spec/acceptance/validate_ipv6_address_spec.rb +++ b/spec/acceptance/validate_ipv6_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_ipv6_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_ipv6_address function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/validate_re_spec.rb b/spec/acceptance/validate_re_spec.rb index 22f6d47..eefb286 100755 --- a/spec/acceptance/validate_re_spec.rb +++ b/spec/acceptance/validate_re_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_re function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_re function' do describe 'success' do it 'validates a string' do pp = <<-EOS diff --git a/spec/acceptance/validate_slength_spec.rb b/spec/acceptance/validate_slength_spec.rb index 1ab2bb9..c29fd23 100755 --- a/spec/acceptance/validate_slength_spec.rb +++ b/spec/acceptance/validate_slength_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_slength function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_slength function' do describe 'success' do it 'validates a single string max' do pp = <<-EOS diff --git a/spec/acceptance/validate_string_spec.rb b/spec/acceptance/validate_string_spec.rb index ae3468f..f04608d 100755 --- a/spec/acceptance/validate_string_spec.rb +++ b/spec/acceptance/validate_string_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_string function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/values_at_spec.rb b/spec/acceptance/values_at_spec.rb index da63cf3..eb0bf4f 100755 --- a/spec/acceptance/values_at_spec.rb +++ b/spec/acceptance/values_at_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'values_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'values_at function' do describe 'success' do it 'returns a specific value' do pp = <<-EOS diff --git a/spec/acceptance/values_spec.rb b/spec/acceptance/values_spec.rb index a2eff32..cef1c9d 100755 --- a/spec/acceptance/values_spec.rb +++ b/spec/acceptance/values_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'values function' do describe 'success' do it 'returns an array of values' do pp = <<-EOS @@ -13,12 +13,7 @@ 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 7e586e2..ae22896 100755 --- a/spec/acceptance/zip_spec.rb +++ b/spec/acceptance/zip_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'zip function' do describe 'success' do it 'zips two arrays of numbers together' do pp = <<-EOS @@ -10,11 +10,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) EOS - 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 + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]/) end it 'zips two arrays of numbers & bools together' do pp = <<-EOS @@ -23,11 +19,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) EOS - 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 + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]/) 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: @@ -40,11 +32,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two,true) notice(inline_template('<%= @output.inspect %>')) EOS - 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 + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 5, 2, 6, 3, 7, 4, 8\]/) end it 'handles unmatched length' do # XXX Is this expected behavior? @@ -54,11 +42,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) EOS - 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 + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\]\]/) end end describe 'failure' do @@ -68,7 +52,6 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one) notice(inline_template('<%= @output.inspect %>')) EOS - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Wrong number of arguments/) end it 'handles improper argument types' do @@ -78,7 +61,6 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) EOS - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Requires array/) end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 27edff8..4d85e7d 100755 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -4,8 +4,6 @@ require 'beaker-rspec' require 'beaker/puppet_install_helper' require 'beaker/module_install_helper' -UNSUPPORTED_PLATFORMS = [] - run_puppet_install_helper install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ /pe/i install_module_on(hosts) @@ -17,20 +15,7 @@ RSpec.configure do |c| # Configure all nodes in nodeset c.before :suite do - if ENV['FUTURE_PARSER'] == 'yes' - default[:default_apply_opts] ||= {} - default[:default_apply_opts].merge!({:parser => 'future'}) - end - end -end - -def is_future_parser_enabled? - if default[:type] == 'aio' || ENV['PUPPET_INSTALL_TYPE'] == 'agent' - return true - elsif default[:default_apply_opts] - return default[:default_apply_opts][:parser] == 'future' end - return false end def get_puppet_version -- cgit v1.2.3 From f4436af32c8f69469100dae36da9ef9c02966b40 Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Wed, 22 Feb 2017 14:01:35 +0000 Subject: (FM-6054) - Unit tests for low effort functions --- spec/functions/delete_undef_values_spec.rb | 1 + spec/functions/difference_spec.rb | 2 ++ spec/functions/flatten_spec.rb | 1 + spec/functions/fqdn_rand_string_spec.rb | 1 + spec/functions/fqdn_rotate_spec.rb | 1 + spec/functions/grep_spec.rb | 1 + spec/functions/hash_spec.rb | 1 + spec/functions/intersection_spec.rb | 1 + spec/functions/join_keys_to_values_spec.rb | 7 +++++++ spec/functions/join_spec.rb | 1 + spec/functions/lstrip_spec.rb | 1 + spec/functions/member_spec.rb | 2 ++ spec/functions/pick_default_spec.rb | 2 ++ spec/functions/prefix_spec.rb | 1 + spec/functions/reject_spec.rb | 1 + spec/functions/reverse_spec.rb | 2 ++ spec/functions/rstrip_spec.rb | 1 + spec/functions/size_spec.rb | 3 +++ spec/functions/strip_spec.rb | 1 + spec/functions/suffix_spec.rb | 2 ++ spec/functions/union_spec.rb | 1 + spec/functions/unique_spec.rb | 2 ++ 22 files changed, 36 insertions(+) (limited to 'spec') diff --git a/spec/functions/delete_undef_values_spec.rb b/spec/functions/delete_undef_values_spec.rb index ec9fb9c..c20cee2 100755 --- a/spec/functions/delete_undef_values_spec.rb +++ b/spec/functions/delete_undef_values_spec.rb @@ -16,6 +16,7 @@ describe 'delete_undef_values' do end it { is_expected.to run.with_params([undef_value]).and_return([]) } it { is_expected.to run.with_params(['one',undef_value,'two','three']).and_return(['one','two','three']) } + it { is_expected.to run.with_params(['ớņέ',undef_value,'ŧשּׁō','ŧħґëə']).and_return(['ớņέ','ŧשּׁō','ŧħґëə']) } end it "should leave the original argument intact" do diff --git a/spec/functions/difference_spec.rb b/spec/functions/difference_spec.rb index d5e983d..0ae3689 100755 --- a/spec/functions/difference_spec.rb +++ b/spec/functions/difference_spec.rb @@ -12,8 +12,10 @@ describe 'difference' do it { is_expected.to run.with_params([], []).and_return([]) } it { is_expected.to run.with_params([], ['one']).and_return([]) } it { is_expected.to run.with_params(['one'], ['one']).and_return([]) } + it { is_expected.to run.with_params(['ớņέ'], ['']).and_return(['ớņέ']) } it { is_expected.to run.with_params(['one'], []).and_return(['one']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['one']) } + it { is_expected.to run.with_params(['ớņέ', 'ŧשּׁō', 'ŧħґëə', 2], ['ŧשּׁō', 'ŧħґëə']).and_return(['ớņέ', 2]) } it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['one']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['one']) } diff --git a/spec/functions/flatten_spec.rb b/spec/functions/flatten_spec.rb index a4338be..b80f3c5 100755 --- a/spec/functions/flatten_spec.rb +++ b/spec/functions/flatten_spec.rb @@ -11,4 +11,5 @@ describe 'flatten' do it { is_expected.to run.with_params([['one']]).and_return(['one']) } it { is_expected.to run.with_params(["a","b","c","d","e","f","g"]).and_return(["a","b","c","d","e","f","g"]) } it { is_expected.to run.with_params([["a","b",["c",["d","e"],"f","g"]]]).and_return(["a","b","c","d","e","f","g"]) } + it { is_expected.to run.with_params(["ã","β",["ĉ",["đ","ẽ","ƒ","ġ"]]]).and_return(["ã","β","ĉ","đ","ẽ","ƒ","ġ"]) } end diff --git a/spec/functions/fqdn_rand_string_spec.rb b/spec/functions/fqdn_rand_string_spec.rb index e407084..861a59e 100644 --- a/spec/functions/fqdn_rand_string_spec.rb +++ b/spec/functions/fqdn_rand_string_spec.rb @@ -20,6 +20,7 @@ describe 'fqdn_rand_string' do it { is_expected.to run.with_params(100, '').and_return(default_charset) } it { is_expected.to run.with_params(100, 'a').and_return(/\Aa{100}\z/) } it { is_expected.to run.with_params(100, 'ab').and_return(/\A[ab]{100}\z/) } + it { is_expected.to run.with_params(100, 'ãβ').and_return(/\A[ãβ]{100}\z/) } it "provides the same 'random' value on subsequent calls for the same host" do expect(fqdn_rand_string(10)).to eql(fqdn_rand_string(10)) diff --git a/spec/functions/fqdn_rotate_spec.rb b/spec/functions/fqdn_rotate_spec.rb index db7a717..7c1038a 100755 --- a/spec/functions/fqdn_rotate_spec.rb +++ b/spec/functions/fqdn_rotate_spec.rb @@ -7,6 +7,7 @@ describe 'fqdn_rotate' do it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) } it { is_expected.to run.with_params('').and_return('') } it { is_expected.to run.with_params('a').and_return('a') } + it { is_expected.to run.with_params('ã').and_return('ã') } it { is_expected.to run.with_params([]).and_return([]) } it { is_expected.to run.with_params(['a']).and_return(['a']) } diff --git a/spec/functions/grep_spec.rb b/spec/functions/grep_spec.rb index 6e0bd6e..d2152b1 100755 --- a/spec/functions/grep_spec.rb +++ b/spec/functions/grep_spec.rb @@ -16,4 +16,5 @@ describe 'grep' do it { is_expected.to run.with_params([], 'two').and_return([]) } it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['two']) } it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['two', 'three']) } + it { is_expected.to run.with_params(['ờאּê', 'ţשּׂỡ', 'ţһŗəè'], 'ţ(שּׂỡ|һŗəè)').and_return(['ţשּׂỡ', 'ţһŗəè']) } end diff --git a/spec/functions/hash_spec.rb b/spec/functions/hash_spec.rb index 4fe99ce..092474b 100755 --- a/spec/functions/hash_spec.rb +++ b/spec/functions/hash_spec.rb @@ -10,5 +10,6 @@ describe 'hash' do it { is_expected.to run.with_params(['one']).and_raise_error(Puppet::ParseError, /Unable to compute/) } it { is_expected.to run.with_params([]).and_return({}) } it { is_expected.to run.with_params(['key1', 'value1']).and_return({ 'key1' => 'value1' }) } + it { is_expected.to run.with_params(['κ℮ұ1', '√āĺűẻ1']).and_return({ 'κ℮ұ1' => '√āĺűẻ1' }) } it { is_expected.to run.with_params(['key1', 'value1', 'key2', 'value2']).and_return({ 'key1' => 'value1', 'key2' => 'value2' }) } end diff --git a/spec/functions/intersection_spec.rb b/spec/functions/intersection_spec.rb index c0f6086..ec368a5 100755 --- a/spec/functions/intersection_spec.rb +++ b/spec/functions/intersection_spec.rb @@ -14,6 +14,7 @@ describe 'intersection' do it { is_expected.to run.with_params(['one'], []).and_return([]) } it { is_expected.to run.with_params(['one'], ['one']).and_return(['one']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) } + it { is_expected.to run.with_params(['ōŋể', 'ŧשợ', 'ţђŕẽё'], ['ŧשợ', 'ţђŕẽё']).and_return(['ŧשợ', 'ţђŕẽё']) } it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['two', 'three']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['two', 'three']) } diff --git a/spec/functions/join_keys_to_values_spec.rb b/spec/functions/join_keys_to_values_spec.rb index c2bae5b..0a2a50c 100755 --- a/spec/functions/join_keys_to_values_spec.rb +++ b/spec/functions/join_keys_to_values_spec.rb @@ -11,6 +11,12 @@ describe 'join_keys_to_values' do it { is_expected.to run.with_params({}, ':').and_return([]) } it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return(['keyvalue']) } it { is_expected.to run.with_params({ 'key' => 'value' }, ':').and_return(['key:value']) } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params({ 'ҝẽγ' => '√ạĺűē' }, ':').and_return(['ҝẽγ:√ạĺűē']) } + it { is_expected.to run.with_params({ 'ҝẽγ' => '√ạĺűē' }, '万').and_return(['ҝẽγ万√ạĺűē']) } + end + it { is_expected.to run.with_params({ 'key' => nil }, ':').and_return(['key:']) } it 'should run join_keys_to_values(, ":") and return the proper array' do result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }, ':']) @@ -21,3 +27,4 @@ describe 'join_keys_to_values' do expect(result.sort).to eq(['key1 value1', 'key2 value2', 'key2 value3'].sort) end end + diff --git a/spec/functions/join_spec.rb b/spec/functions/join_spec.rb index a300571..98852d5 100755 --- a/spec/functions/join_spec.rb +++ b/spec/functions/join_spec.rb @@ -16,4 +16,5 @@ describe 'join' do it { is_expected.to run.with_params(['one'], ':').and_return('one') } it { is_expected.to run.with_params(['one', 'two', 'three']).and_return('onetwothree') } it { is_expected.to run.with_params(['one', 'two', 'three'], ':').and_return('one:two:three') } + it { is_expected.to run.with_params(['ōŋể', 'ŧשợ', 'ţђŕẽё'], ':').and_return('ōŋể:ŧשợ:ţђŕẽё') } end diff --git a/spec/functions/lstrip_spec.rb b/spec/functions/lstrip_spec.rb index 981794e..a5a09ed 100755 --- a/spec/functions/lstrip_spec.rb +++ b/spec/functions/lstrip_spec.rb @@ -22,6 +22,7 @@ describe 'lstrip' do it { is_expected.to run.with_params('one ').and_return('one ') } it { is_expected.to run.with_params(' one ').and_return('one ') } it { is_expected.to run.with_params(' one ').and_return('one ') } + it { is_expected.to run.with_params(' ǿňè ').and_return('ǿňè ') } it { is_expected.to run.with_params("\tone ").and_return('one ') } it { is_expected.to run.with_params("\t one ").and_return('one ') } it { is_expected.to run.with_params("one \t").and_return("one \t") } diff --git a/spec/functions/member_spec.rb b/spec/functions/member_spec.rb index 527f887..8988632 100755 --- a/spec/functions/member_spec.rb +++ b/spec/functions/member_spec.rb @@ -17,5 +17,7 @@ describe 'member' do it { is_expected.to run.with_params(['one'], 'one').and_return(true) } it { is_expected.to run.with_params(['one'], ['one']).and_return(true) } it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'two']).and_return(true) } + it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ŧẅồ']).and_return(true) } it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'five']).and_return(false) } + it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ƒί√ə']).and_return(false) } end diff --git a/spec/functions/pick_default_spec.rb b/spec/functions/pick_default_spec.rb index e2fc64a..a7ffc86 100755 --- a/spec/functions/pick_default_spec.rb +++ b/spec/functions/pick_default_spec.rb @@ -5,6 +5,7 @@ describe 'pick_default' do it { is_expected.to run.with_params().and_raise_error(Puppet::Error, /Must receive at least one argument/) } it { is_expected.to run.with_params('one', 'two').and_return('one') } + it { is_expected.to run.with_params('ớņệ', 'ťωơ').and_return('ớņệ') } it { is_expected.to run.with_params('', 'two').and_return('two') } it { is_expected.to run.with_params(:undef, 'two').and_return('two') } it { is_expected.to run.with_params(:undefined, 'two').and_return('two') } @@ -13,6 +14,7 @@ describe 'pick_default' do [ '', :undef, :undefined, nil, {}, [], 1, 'default' ].each do |value| describe "when providing #{value.inspect} as default" do it { is_expected.to run.with_params('one', value).and_return('one') } + it { is_expected.to run.with_params('ớņệ', value).and_return('ớņệ') } it { is_expected.to run.with_params([], value).and_return([]) } it { is_expected.to run.with_params({}, value).and_return({}) } it { is_expected.to run.with_params(value, value).and_return(value) } diff --git a/spec/functions/prefix_spec.rb b/spec/functions/prefix_spec.rb index 3761022..5510c58 100755 --- a/spec/functions/prefix_spec.rb +++ b/spec/functions/prefix_spec.rb @@ -11,6 +11,7 @@ describe 'prefix' do it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /expected second argument to be a String/) } it { is_expected.to run.with_params([]).and_return([]) } it { is_expected.to run.with_params(['one', 2]).and_return(['one', '2']) } + it { is_expected.to run.with_params(['ớņệ', 2]).and_return(['ớņệ', '2']) } it { is_expected.to run.with_params([], '').and_return([]) } it { is_expected.to run.with_params([''], '').and_return(['']) } it { is_expected.to run.with_params(['one'], 'pre').and_return(['preone']) } diff --git a/spec/functions/reject_spec.rb b/spec/functions/reject_spec.rb index 4863050..86db7c7 100755 --- a/spec/functions/reject_spec.rb +++ b/spec/functions/reject_spec.rb @@ -16,4 +16,5 @@ describe 'reject' do it { is_expected.to run.with_params([], 'two').and_return([]) } it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) } it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['one']) } + it { is_expected.to run.with_params(['όʼnệ', 'ţщồ', 'ţңяέέ'], 'ţ(щồ|ңяέέ)').and_return(['όʼnệ']) } end diff --git a/spec/functions/reverse_spec.rb b/spec/functions/reverse_spec.rb index e00dee9..79bc0ad 100755 --- a/spec/functions/reverse_spec.rb +++ b/spec/functions/reverse_spec.rb @@ -15,11 +15,13 @@ describe 'reverse' do it { is_expected.to run.with_params(['one']).and_return(['one']) } it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['three', 'two', 'one']) } it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) } + it { is_expected.to run.with_params(['ổňë', 'ťŵọ', 'ŧңяəė', 'ƒŏůŗ']).and_return(['ƒŏůŗ', 'ŧңяəė', 'ťŵọ', 'ổňë']) } it { is_expected.to run.with_params('').and_return('') } it { is_expected.to run.with_params('a').and_return('a') } it { is_expected.to run.with_params('abc').and_return('cba') } it { is_expected.to run.with_params('abcd').and_return('dcba') } + it { is_expected.to run.with_params('āβćđ').and_return('đćβā') } context 'when using a class extending String' do it 'should call its reverse method' do diff --git a/spec/functions/rstrip_spec.rb b/spec/functions/rstrip_spec.rb index d2efac8..a7663e2 100755 --- a/spec/functions/rstrip_spec.rb +++ b/spec/functions/rstrip_spec.rb @@ -22,6 +22,7 @@ describe 'rstrip' do it { is_expected.to run.with_params('one ').and_return('one') } it { is_expected.to run.with_params(' one ').and_return(' one') } it { is_expected.to run.with_params(' one ').and_return(' one') } + it { is_expected.to run.with_params(' ǿňè ').and_return(' ǿňè') } it { is_expected.to run.with_params("\tone ").and_return("\tone") } it { is_expected.to run.with_params("\t one ").and_return("\t one") } it { is_expected.to run.with_params("one\t").and_return('one') } diff --git a/spec/functions/size_spec.rb b/spec/functions/size_spec.rb index c0047ee..2047423 100755 --- a/spec/functions/size_spec.rb +++ b/spec/functions/size_spec.rb @@ -19,11 +19,14 @@ describe 'size' do it { is_expected.to run.with_params({}).and_return(0) } it { is_expected.to run.with_params({'1' => '2'}).and_return(1) } it { is_expected.to run.with_params({'1' => '2', '4' => '4'}).and_return(2) } + it { is_expected.to run.with_params({'€' => '@', '竹' => 'ǿňè'}).and_return(2) } it { is_expected.to run.with_params('').and_return(0) } it { is_expected.to run.with_params('a').and_return(1) } it { is_expected.to run.with_params('abc').and_return(3) } it { is_expected.to run.with_params('abcd').and_return(4) } + it { is_expected.to run.with_params('万').and_return(1) } + it { is_expected.to run.with_params('āβćđ').and_return(4) } context 'when using a class extending String' do it 'should call its size method' do diff --git a/spec/functions/strip_spec.rb b/spec/functions/strip_spec.rb index 689b6dd..18e943d 100755 --- a/spec/functions/strip_spec.rb +++ b/spec/functions/strip_spec.rb @@ -30,5 +30,6 @@ describe 'strip' do it { is_expected.to run.with_params("\tone \t").and_return('one') } it { is_expected.to run.with_params("\t one \t").and_return('one') } it { is_expected.to run.with_params(' o n e ').and_return('o n e') } + it { is_expected.to run.with_params(' ỏŋέ ').and_return('ỏŋέ') } it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return('one') } end diff --git a/spec/functions/suffix_spec.rb b/spec/functions/suffix_spec.rb index efba4ab..e0eafb1 100755 --- a/spec/functions/suffix_spec.rb +++ b/spec/functions/suffix_spec.rb @@ -15,6 +15,8 @@ describe 'suffix' do it { is_expected.to run.with_params([''], '').and_return(['']) } it { is_expected.to run.with_params(['one'], 'post').and_return(['onepost']) } it { is_expected.to run.with_params(['one', 'two', 'three'], 'post').and_return(['onepost', 'twopost', 'threepost']) } + it { is_expected.to run.with_params(['ỗńέ', 'ťשׂǿ', 'ŧҺř℮ə'], 'рổŝţ').and_return(['ỗńέрổŝţ', 'ťשׂǿрổŝţ', 'ŧҺř℮əрổŝţ']) } + it { is_expected.to run.with_params({}).and_return({}) } diff --git a/spec/functions/union_spec.rb b/spec/functions/union_spec.rb index cfd38b6..3f36f24 100755 --- a/spec/functions/union_spec.rb +++ b/spec/functions/union_spec.rb @@ -20,5 +20,6 @@ describe 'union' do it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one', 'two', 'three']) } it { is_expected.to run.with_params(['one', 'two'], ['two', 'three'], ['one', 'three']).and_return(['one', 'two', 'three']) } it { is_expected.to run.with_params(['one', 'two'], ['three', 'four'], ['one', 'two', 'three'], ['four']).and_return(['one', 'two', 'three', 'four']) } + it { is_expected.to run.with_params(['ốńə', 'ţשׂợ'], ['ŧĥяếệ', 'ƒởųŗ'], ['ốńə', 'ţשׂợ', 'ŧĥяếệ'], ['ƒởųŗ']).and_return(['ốńə', 'ţשׂợ', 'ŧĥяếệ', 'ƒởųŗ']) } it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3', 1, 2]) end end diff --git a/spec/functions/unique_spec.rb b/spec/functions/unique_spec.rb index 24257a0..7955acb 100755 --- a/spec/functions/unique_spec.rb +++ b/spec/functions/unique_spec.rb @@ -17,11 +17,13 @@ describe 'unique' do it { is_expected.to run.with_params([]).and_return([]) } it { is_expected.to run.with_params(['a']).and_return(['a']) } it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) } + it { is_expected.to run.with_params(['ã', 'ъ', 'ã']).and_return(['ã', 'ъ']) } end context 'when called with a string' do it { is_expected.to run.with_params('').and_return('') } it { is_expected.to run.with_params('a').and_return('a') } it { is_expected.to run.with_params('aaba').and_return('ab') } + it { is_expected.to run.with_params('ããъã').and_return('ãъ') } end end -- cgit v1.2.3 From b13af823335e6952c8494ecbdb6b2955fbd2d9eb Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Tue, 28 Feb 2017 12:03:01 +0000 Subject: (FM-6058) - Unit tests for med effort functions --- spec/functions/basename_spec.rb | 5 +++++ spec/functions/chomp_spec.rb | 5 +++++ spec/functions/chop_spec.rb | 5 +++++ spec/functions/deep_merge_spec.rb | 4 ++++ spec/functions/dirname_spec.rb | 5 +++++ spec/functions/fqdn_uuid_spec.rb | 1 - spec/functions/getvar_spec.rb | 15 +++++++++++++++ spec/functions/has_key_spec.rb | 5 +++++ spec/functions/is_a_spec.rb | 5 +++++ spec/functions/pick_spec.rb | 5 +++++ spec/functions/regexpescape_spec.rb | 5 +++++ spec/functions/shell_escape_spec.rb | 5 +++++ spec/functions/shell_join_spec.rb | 5 +++++ spec/functions/shell_split_spec.rb | 5 +++++ spec/functions/shuffle_spec.rb | 5 +++++ spec/functions/values_at_spec.rb | 5 +++++ spec/functions/values_spec.rb | 5 +++++ spec/functions/zip_spec.rb | 6 ++++++ 18 files changed, 95 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/functions/basename_spec.rb b/spec/functions/basename_spec.rb index c84e192..3e02b01 100755 --- a/spec/functions/basename_spec.rb +++ b/spec/functions/basename_spec.rb @@ -11,4 +11,9 @@ describe 'basename' do it { is_expected.to run.with_params('/path/to/a/file.ext', '.ext').and_return('file') } it { is_expected.to run.with_params('relative_path/to/a/file.ext', '.ext').and_return('file') } it { is_expected.to run.with_params('scheme:///path/to/a/file.ext').and_return('file.ext') } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params('scheme:///√ạĺűē/竹.ext').and_return('竹.ext') } + it { is_expected.to run.with_params('ҝẽγ:/√ạĺűē/竹.ㄘ', '.ㄘ').and_return('竹') } + end end diff --git a/spec/functions/chomp_spec.rb b/spec/functions/chomp_spec.rb index 6878742..56bd9b1 100755 --- a/spec/functions/chomp_spec.rb +++ b/spec/functions/chomp_spec.rb @@ -17,4 +17,9 @@ describe 'chomp' do it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return("one") } it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") } it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new("two"), "three\n"]).and_return(["one", "two", "three"]) } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") } + it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") } + end end diff --git a/spec/functions/chop_spec.rb b/spec/functions/chop_spec.rb index db7d18b..b70fc37 100755 --- a/spec/functions/chop_spec.rb +++ b/spec/functions/chop_spec.rb @@ -17,4 +17,9 @@ describe 'chop' do it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return("one") } it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") } it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new("two"), "three\n"]).and_return(["one", "tw", "three"]) } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") } + it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") } + end end diff --git a/spec/functions/deep_merge_spec.rb b/spec/functions/deep_merge_spec.rb index 397e048..c91a07e 100755 --- a/spec/functions/deep_merge_spec.rb +++ b/spec/functions/deep_merge_spec.rb @@ -52,4 +52,8 @@ describe 'deep_merge' do expect(argument1).to eq(original1) expect(argument2).to eq(original2) end + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params({'ĸέỹ1' => 'ϋǻļủë1'}, {'この文字列' => '万' }).and_return({'ĸέỹ1' => 'ϋǻļủë1', 'この文字列' => '万'}) } + end end diff --git a/spec/functions/dirname_spec.rb b/spec/functions/dirname_spec.rb index 46c4c35..c494915 100755 --- a/spec/functions/dirname_spec.rb +++ b/spec/functions/dirname_spec.rb @@ -10,4 +10,9 @@ describe 'dirname' do it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError) } it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('/path/to/a') } it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('relative_path/to/a') } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params('scheme:///√ạĺűē/竹.ext').and_return('scheme:///√ạĺűē') } + it { is_expected.to run.with_params('ҝẽγ:/√ạĺűē/竹.ㄘ').and_return('ҝẽγ:/√ạĺűē') } + end end diff --git a/spec/functions/fqdn_uuid_spec.rb b/spec/functions/fqdn_uuid_spec.rb index a2d1618..d0c30d6 100644 --- a/spec/functions/fqdn_uuid_spec.rb +++ b/spec/functions/fqdn_uuid_spec.rb @@ -10,5 +10,4 @@ describe 'fqdn_uuid' do it { should run.with_params('puppetlabs.com').and_return('9c70320f-6815-5fc5-ab0f-debe68bf764c') } it { should run.with_params('google.com').and_return('64ee70a4-8cc1-5d25-abf2-dea6c79a09c8') } end - end diff --git a/spec/functions/getvar_spec.rb b/spec/functions/getvar_spec.rb index 54f1842..55789d8 100755 --- a/spec/functions/getvar_spec.rb +++ b/spec/functions/getvar_spec.rb @@ -20,4 +20,19 @@ describe 'getvar' do it { is_expected.to run.with_params('::site::data::foo').and_return('baz') } it { is_expected.to run.with_params('::site::data::bar').and_return(nil) } end + + context 'given variables in namespaces' do + let(:pre_condition) { + <<-'ENDofPUPPETcode' + class site::info { $lock = 'ŧҺîš íš ắ śţřĭŋĝ' } + class site::new { $item = '万Ü€‰' } + include site::info + include site::new + ENDofPUPPETcode + } + + it { is_expected.to run.with_params('site::info::lock').and_return('ŧҺîš íš ắ śţřĭŋĝ') } + it { is_expected.to run.with_params('::site::new::item').and_return('万Ü€‰') } + end end + diff --git a/spec/functions/has_key_spec.rb b/spec/functions/has_key_spec.rb index 965d5a6..0e0e1cc 100755 --- a/spec/functions/has_key_spec.rb +++ b/spec/functions/has_key_spec.rb @@ -12,4 +12,9 @@ describe 'has_key' do it { is_expected.to run.with_params({ 'key' => 'value' }, "key").and_return(true) } it { is_expected.to run.with_params({}, "key").and_return(false) } it { is_expected.to run.with_params({ 'key' => 'value'}, "not a key").and_return(false) } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params({ 'κéỳ ' => '٧ậļųể' }, "κéỳ ").and_return(true) } + it { is_expected.to run.with_params({ 'キー' => '٧ậļųể' }, "キー").and_return(true) } + end end diff --git a/spec/functions/is_a_spec.rb b/spec/functions/is_a_spec.rb index 8dec13f..2d6cb46 100644 --- a/spec/functions/is_a_spec.rb +++ b/spec/functions/is_a_spec.rb @@ -21,5 +21,10 @@ if Puppet.version.to_f >= 4.0 it 'fails when comparing an integer and a string' do is_expected.to run.with_params(5, String).and_return(false) end + + it 'suceeds when comparing an UTF8 and double byte characters' do + is_expected.to run.with_params('このテキスト', String).and_return(true) + is_expected.to run.with_params('ŧћịś ŧêχŧ', String).and_return(true) + end end end diff --git a/spec/functions/pick_spec.rb b/spec/functions/pick_spec.rb index 2c7caa8..438553b 100755 --- a/spec/functions/pick_spec.rb +++ b/spec/functions/pick_spec.rb @@ -9,4 +9,9 @@ describe 'pick' do it { is_expected.to run.with_params(:undef, 'two').and_return('two') } it { is_expected.to run.with_params(:undefined, 'two').and_return('two') } it { is_expected.to run.with_params(nil, 'two').and_return('two') } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params(nil, 'このテキスト').and_return('このテキスト') } + it { is_expected.to run.with_params('', 'ŝẳмрłề џţƒ8 ţẽם', 'このテキスト').and_return('ŝẳмрłề џţƒ8 ţẽם') } + end end diff --git a/spec/functions/regexpescape_spec.rb b/spec/functions/regexpescape_spec.rb index 6efa847..36dbe70 100644 --- a/spec/functions/regexpescape_spec.rb +++ b/spec/functions/regexpescape_spec.rb @@ -32,5 +32,10 @@ describe 'regexpescape' do it { is_expected.to run.with_params([]).and_return([]) } it { is_expected.to run.with_params(['one*', "two"]).and_return(['one\*', "two"]) } it { is_expected.to run.with_params(['one*', 1, true, {}, "two"]).and_return(['one\*', 1, true, {}, "two"]) } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params(['ŏʼnε*']).and_return(['ŏʼnε\*']) } + it { is_expected.to run.with_params(['インターネット*']).and_return(['インターネット\*']) } + end end end diff --git a/spec/functions/shell_escape_spec.rb b/spec/functions/shell_escape_spec.rb index 3061dec..77917dd 100644 --- a/spec/functions/shell_escape_spec.rb +++ b/spec/functions/shell_escape_spec.rb @@ -19,4 +19,9 @@ describe 'shell_escape' do it { is_expected.to run.with_params('~`!@#$%^&*()_+-=[]\{}|;\':",./<>?') .and_return('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?') } end + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params('スペー スを含むテ キスト').and_return('\\ス\\ペ\\ー\\ \\ス\\を\\含\\む\\テ\\ \\ \\キ\\ス\\ト') } + it { is_expected.to run.with_params('μťƒ 8 ŧĕχť').and_return('\\μ\\ť\\ƒ\\ 8\\ \\ \\ŧ\\ĕ\\χ\\ť') } + end end diff --git a/spec/functions/shell_join_spec.rb b/spec/functions/shell_join_spec.rb index 6815f7c..46305bf 100644 --- a/spec/functions/shell_join_spec.rb +++ b/spec/functions/shell_join_spec.rb @@ -15,6 +15,11 @@ describe 'shell_join' do it { is_expected.to run.with_params(['foo', 'bar baz']).and_return('foo bar\ baz') } it { is_expected.to run.with_params(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?']) .and_return('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?') } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params(['μťƒ', '8', 'ŧĕχť']).and_return('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť') } + it { is_expected.to run.with_params(['スペー', 'スを含むテ', ' キスト']).and_return('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト') } + end end describe 'stringification' do diff --git a/spec/functions/shell_split_spec.rb b/spec/functions/shell_split_spec.rb index beeb977..f8f9c90 100644 --- a/spec/functions/shell_split_spec.rb +++ b/spec/functions/shell_split_spec.rb @@ -20,5 +20,10 @@ describe 'shell_split' do .and_return(['~`!@#$%^&*()_+-=[]\{}|;\':",./<>?']) } it { is_expected.to run.with_params('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?') .and_return(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?']) } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť').and_return(['μťƒ', '8', 'ŧĕχť']) } + it { is_expected.to run.with_params('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト').and_return(['スペー', 'スを含むテ', ' キスト']) } + end end end diff --git a/spec/functions/shuffle_spec.rb b/spec/functions/shuffle_spec.rb index ebc3a73..4673daa 100755 --- a/spec/functions/shuffle_spec.rb +++ b/spec/functions/shuffle_spec.rb @@ -26,6 +26,11 @@ describe 'shuffle' do it { is_expected.to run.with_params('abc').and_return('bac') } it { is_expected.to run.with_params('abcd').and_return('dcba') } + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params('ůţƒ8 ŧέχŧ şŧґíńģ').and_return('ģńş ůχţέƒŧí8ґŧŧ ') } + it { is_expected.to run.with_params('日本語の文字列').and_return('字本日語文列の') } + end + context 'when using a class extending String' do it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return('lkhdsfajg') } end diff --git a/spec/functions/values_at_spec.rb b/spec/functions/values_at_spec.rb index a8348f3..681c101 100755 --- a/spec/functions/values_at_spec.rb +++ b/spec/functions/values_at_spec.rb @@ -30,6 +30,11 @@ describe 'values_at' do it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError, /index exceeds array size/) } end + context 'when requesting a single item using UTF8 and double byte characters' do + it { is_expected.to run.with_params(['ẩ', 'β', 'с', 'ď'], 0).and_return(['ẩ']) } + it { is_expected.to run.with_params(['文', '字', 'の', '値'], 2).and_return(['の']) } + end + context 'when requesting multiple items' do it { is_expected.to run.with_params([0, 1, 2], [1, -1]).and_raise_error(Puppet::ParseError, /Unknown format of given index/) } it { is_expected.to run.with_params([0, 1, 2], [0, 2]).and_return([0, 2]) } diff --git a/spec/functions/values_spec.rb b/spec/functions/values_spec.rb index 4abf0bd..26c6dfb 100755 --- a/spec/functions/values_spec.rb +++ b/spec/functions/values_spec.rb @@ -16,4 +16,9 @@ describe 'values' do result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2', 'duplicate_value_key' => 'value2' }]) expect(result).to match_array(['value1', 'value2', 'value2']) end + + it 'should run with UTF8 and double byte characters' do + result = subject.call([{ 'かぎ' => '使用', 'ҝĕұ' => '√ẩŀứệ', 'ҝĕұďŭрļǐçằťè' => '√ẩŀứệ' }]) + expect(result).to match_array(['使用', '√ẩŀứệ', '√ẩŀứệ']) + end end diff --git a/spec/functions/zip_spec.rb b/spec/functions/zip_spec.rb index abca7ee..e1ae8ee 100755 --- a/spec/functions/zip_spec.rb +++ b/spec/functions/zip_spec.rb @@ -12,4 +12,10 @@ describe 'zip' do it { is_expected.to run.with_params([1,2,3], [4,5,6]).and_return([[1,4], [2,5], [3,6]]) } it { is_expected.to run.with_params([1,2,3], [4,5,6], false).and_return([[1,4], [2,5], [3,6]]) } it { is_expected.to run.with_params([1,2,3], [4,5,6], true).and_return([1, 4, 2, 5, 3, 6]) } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params(['ầ', 'ь', 'ć'], ['đ', 'ề', 'ƒ']).and_return([['ầ','đ'], ['ь','ề'], ['ć', 'ƒ']]) } + it { is_expected.to run.with_params(['ペ', '含', '値'], ['ッ', '文', 'イ']).and_return([['ペ','ッ'], ['含','文'], ['値', 'イ']]) } + end end + -- cgit v1.2.3 From afc313bb81013473dd12a578fe652ebdd07b179a Mon Sep 17 00:00:00 2001 From: tphoney Date: Tue, 28 Feb 2017 18:07:56 +0000 Subject: loosen the regex for tuple checking --- spec/acceptance/type_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/acceptance/type_spec.rb b/spec/acceptance/type_spec.rb index 7cf445b..5cc9470 100755 --- a/spec/acceptance/type_spec.rb +++ b/spec/acceptance/type_spec.rb @@ -12,7 +12,7 @@ describe 'type function' do EOS apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/type is Tuple\[String, String, String, String\]/) + expect(r.stdout).to match(/type is Tuple\[String.*, String.*, String.*, String.*\]/) end end it 'types strings' do -- cgit v1.2.3 From 496d19640cc239f59e456c381bd9912cde60a07e Mon Sep 17 00:00:00 2001 From: Peter Souter Date: Fri, 3 Mar 2017 11:43:12 +0000 Subject: (MODULES-4485) Improve ipv6 support for type * Improves regex to catch some valid (but less known) ipv6 strings, mostly those which are a mix of ipv6 strings and embedded ipv4 numbers * Regex inspired by the following: * https://github.com/sindresorhus/ip-regex * https://gist.github.com/cpetschnig/294476 * The original Dartware forum thread where someone originally created this beast of a regex, now lost except to archive.org * Whilst we're here, we can add the more tricky ipv6 strings to the existing functions to validate * Luckily, the `ipaddr` native ruby library used in the original functions already supports these --- spec/aliases/ipv6_spec.rb | 14 ++++++++++++-- spec/functions/validate_ipv6_address_spec.rb | 10 ++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/aliases/ipv6_spec.rb b/spec/aliases/ipv6_spec.rb index 13d7c3e..6237eba 100644 --- a/spec/aliases/ipv6_spec.rb +++ b/spec/aliases/ipv6_spec.rb @@ -5,7 +5,14 @@ if Puppet.version.to_f >= 4.5 describe 'accepts ipv6 addresses' do [ '2001:0db8:85a3:0000:0000:8a2e:0370:7334', - 'fa76:8765:34ac:0823:ab76:eee9:0987:1111' + 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', + 'fe80:0000:0000:0000:0204:61ff:fe9d:f156', + 'fe80:0:0:0:204:61ff:fe9d:f156', + 'fe80::204:61ff:fe9d:f156', + 'fe80:0:0:0:0204:61ff:254.157.241.86', + '::1', + 'fe80::', + '2001::', ].each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -18,7 +25,10 @@ if Puppet.version.to_f >= 4.5 'nope', '77', '4.4.4', - '2000:7334' + '2000:7334', + '::ffff:2.3.4', + '::ffff:257.1.2.3', + '::ffff:12345678901234567890.1.26', ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/functions/validate_ipv6_address_spec.rb b/spec/functions/validate_ipv6_address_spec.rb index 78810d4..137db36 100755 --- a/spec/functions/validate_ipv6_address_spec.rb +++ b/spec/functions/validate_ipv6_address_spec.rb @@ -29,6 +29,13 @@ describe 'validate_ipv6_address' do it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') } it { is_expected.to run.with_params('::1/64') } it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') } + it { is_expected.to run.with_params('fe80:0000:0000:0000:0204:61ff:fe9d:f156') } + it { is_expected.to run.with_params('fe80:0:0:0:204:61ff:fe9d:f156') } + it { is_expected.to run.with_params('fe80::204:61ff:fe9d:f156') } + it { is_expected.to run.with_params('fe80:0:0:0:0204:61ff:254.157.241.86') } + it { is_expected.to run.with_params('::1') } + it { is_expected.to run.with_params('fe80::') } + it { is_expected.to run.with_params('2001::') } end describe 'invalid inputs' do @@ -38,6 +45,9 @@ describe 'validate_ipv6_address' do it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } + it { is_expected.to run.with_params('::ffff:2.3.4').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } + it { is_expected.to run.with_params('::ffff:257.1.2.3').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } + it { is_expected.to run.with_params('::ffff:12345678901234567890.1.26').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } it { is_expected.to run.with_params('affe:beef').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, /is not a string/) } it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, /is not a string/) } -- cgit v1.2.3 From 2f463600c2c0b6ac95ec71d3e5b17d1b2abdcd22 Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Fri, 3 Mar 2017 15:25:53 +0000 Subject: (FM-6063) - Unit tests for high effort functions --- spec/functions/concat_spec.rb | 5 ++++- spec/functions/defined_with_params_spec.rb | 5 +++++ spec/functions/dig44_spec.rb | 26 ++++++++++++++++++++++++++ spec/functions/dos2unix_spec.rb | 17 ++++++++++++----- spec/functions/ensure_packages_spec.rb | 7 +++++++ spec/functions/getparam_spec.rb | 8 ++++++++ spec/functions/is_mac_address_spec.rb | 6 ++++++ spec/functions/keys_spec.rb | 5 +++++ spec/functions/load_module_metadata_spec.rb | 10 ++++++++++ spec/functions/loadjson_spec.rb | 6 ++++-- spec/functions/loadyaml_spec.rb | 4 +++- spec/functions/parsejson_spec.rb | 11 ++++++++--- spec/functions/parseyaml_spec.rb | 11 ++++++++--- spec/functions/range_spec.rb | 8 ++++++++ spec/functions/seeded_rand_spec.rb | 5 +++++ spec/functions/squeeze_spec.rb | 6 ++++++ 16 files changed, 125 insertions(+), 15 deletions(-) (limited to 'spec') diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb index 0e67a60..6ab1b6e 100755 --- a/spec/functions/concat_spec.rb +++ b/spec/functions/concat_spec.rb @@ -11,8 +11,11 @@ describe 'concat' do it { is_expected.to run.with_params(['1','2','3'],[['4','5'],'6']).and_return(['1','2','3',['4','5'],'6']) } it { is_expected.to run.with_params(['1','2'],['3','4'],['5','6']).and_return(['1','2','3','4','5','6']) } it { is_expected.to run.with_params(['1','2'],'3','4',['5','6']).and_return(['1','2','3','4','5','6']) } + +context 'should run with UTF8 and double byte characters' do it { is_expected.to run.with_params([{"a" => "b"}], {"c" => "d", "e" => "f"}).and_return([{"a" => "b"}, {"c" => "d", "e" => "f"}]) } - it { is_expected.to run.with_params(['ấ','β','c'],['đ','ể','ƒ']).and_return(['ấ','β','c','đ','ể','ƒ']) } + it { is_expected.to run.with_params(['ấ','β','©'],['đ','ể','文字列']).and_return(['ấ','β','©','đ','ể','文字列']) } +end it "should leave the original array intact" do argument1 = ['1','2','3'] diff --git a/spec/functions/defined_with_params_spec.rb b/spec/functions/defined_with_params_spec.rb index e2f3abe..a0db0b7 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -11,6 +11,11 @@ describe 'defined_with_params' do it { is_expected.to run.with_params('User[dan]', {}).and_return(true) } it { is_expected.to run.with_params('User[bob]', {}).and_return(false) } it { is_expected.to run.with_params('User[dan]', {'foo' => 'bar'}).and_return(false) } + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params('User[ĵĭмოү]', {}).and_return(false) } + it { is_expected.to run.with_params('User[ポーラ]', {}).and_return(false) } + end end describe 'when compared against a resource with attributes' do diff --git a/spec/functions/dig44_spec.rb b/spec/functions/dig44_spec.rb index 4f7408d..a7b8a3d 100644 --- a/spec/functions/dig44_spec.rb +++ b/spec/functions/dig44_spec.rb @@ -25,6 +25,18 @@ describe 'dig44' do } end + let(:utf8_data) do + { + 'ẵ' => { + 'в' => [ + '©', + 'ĝ', + 'に', + ] + } + } + end + context 'single values' do it 'should exist' do is_expected.not_to be_nil @@ -100,6 +112,20 @@ describe 'dig44' do it 'should return "nil" if value is not found and no default value is provided' do is_expected.to run.with_params(data, %w(a 1)).and_return(nil) end + end + + context 'Internationalization (i18N) values' do + + it 'should be able to return a unicode character' do + is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 0]).and_return('©') + end + it 'should be able to return a utf8 character' do + is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 1]).and_return('ĝ') + end + + it 'should be able to return a double byte character' do + is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 2]).and_return('に') + end end end diff --git a/spec/functions/dos2unix_spec.rb b/spec/functions/dos2unix_spec.rb index 9c84703..97abae7 100644 --- a/spec/functions/dos2unix_spec.rb +++ b/spec/functions/dos2unix_spec.rb @@ -29,12 +29,19 @@ describe 'dos2unix' do end end - context 'Converting from unix to unix format' do - sample_text = "Hello\nWorld\n" - desired_output = "Hello\nWorld\n" + context 'Internationalization (i18N) values' do + sample_text_utf8 = "Ħ℮ļłǿ\r\nשׁөŕłđ\r\n" + desired_output_utf8 = "Ħ℮ļłǿ\nשׁөŕłđ\n" - it 'should output unix format' do - should run.with_params(sample_text).and_return(desired_output) + sample_text_doublebyte = "こんにちは\r\n世界\r\n" + desired_output_doublebyte = "こんにちは\n世界\n" + + it 'should output uft8 string' do + should run.with_params(sample_text_utf8).and_return(desired_output_utf8) + end + + it 'should output double byte string' do + should run.with_params(sample_text_doublebyte).and_return(desired_output_doublebyte) end end end diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 5d97684..6f94d72 100755 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -36,9 +36,16 @@ describe 'ensure_packages' do context 'given hash of packages' do before { subject.call([{"foo" => { "provider" => "rpm" }, "bar" => { "provider" => "gem" }}, { "ensure" => "present"}]) } + before { subject.call([{"パッケージ" => { "ensure" => "absent"}}]) } + before { subject.call([{"ρǻ¢κầģẻ" => { "ensure" => "absent"}}]) } # this lambda is required due to strangeness within rspec-puppet's expectation handling it { expect(lambda { catalogue }).to contain_package('foo').with({'provider' => 'rpm', 'ensure' => 'present'}) } it { expect(lambda { catalogue }).to contain_package('bar').with({'provider' => 'gem', 'ensure' => 'present'}) } + + context 'should run with UTF8 and double byte characters' do + it { expect(lambda { catalogue }).to contain_package('パッケージ').with({'ensure' => 'absent'}) } + it { expect(lambda { catalogue }).to contain_package('ρǻ¢κầģẻ').with({'ensure' => 'absent'}) } + end end end diff --git a/spec/functions/getparam_spec.rb b/spec/functions/getparam_spec.rb index e4ef9e6..522ed3b 100755 --- a/spec/functions/getparam_spec.rb +++ b/spec/functions/getparam_spec.rb @@ -24,4 +24,12 @@ describe 'getparam' do it { is_expected.to run.with_params('User[one]', 'shell').and_return('/bin/sh') } it { is_expected.to run.with_params('User[one]', 'managehome').and_return(false) } end + + describe 'when compared against a user resource with UTF8 and double byte params' do + let(:pre_condition) { 'user { ["三", "ƒốưř"]: ensure => present }' } + + it { is_expected.to run.with_params('User[三]', 'ensure').and_return('present') } + it { is_expected.to run.with_params('User[ƒốưř]', 'ensure').and_return('present') } + + end end diff --git a/spec/functions/is_mac_address_spec.rb b/spec/functions/is_mac_address_spec.rb index 5f76a91..c1e33b8 100755 --- a/spec/functions/is_mac_address_spec.rb +++ b/spec/functions/is_mac_address_spec.rb @@ -9,6 +9,12 @@ describe 'is_mac_address' do it { is_expected.to run.with_params('00:00:00:00:00:0g').and_return(false) } it { is_expected.to run.with_params('').and_return(false) } it { is_expected.to run.with_params('one').and_return(false) } + + context 'function can handle UTF8 and double byte characters' do + it { is_expected.to run.with_params('ƒốưř').and_return(false) } + it { is_expected.to run.with_params('三+').and_return(false) } + end + it { pending "should properly typecheck its arguments" is_expected.to run.with_params(1).and_return(false) diff --git a/spec/functions/keys_spec.rb b/spec/functions/keys_spec.rb index 2e009dc..fc7d6d8 100755 --- a/spec/functions/keys_spec.rb +++ b/spec/functions/keys_spec.rb @@ -16,4 +16,9 @@ describe 'keys' do result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }]) expect(result).to match_array(['key1', 'key2']) end + + it 'should run with UTF8 and double byte characters' do + result = subject.call([{ 'ҝểү' => '√ẳŀμệ', 'キー' => '値' }]) + expect(result).to match_array(['ҝểү', 'キー']) + end end diff --git a/spec/functions/load_module_metadata_spec.rb b/spec/functions/load_module_metadata_spec.rb index 841cd7d..9496fcb 100755 --- a/spec/functions/load_module_metadata_spec.rb +++ b/spec/functions/load_module_metadata_spec.rb @@ -10,6 +10,15 @@ describe 'load_module_metadata' do allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') end + + context "when calling with valid utf8 and double byte character arguments" do + before :each do + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"ĭďèʼnţĩƒіểя": "ċơņťęאּť ỡƒ ţħíš - +この文字"}') + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/).and_return('{"ĭďèʼnţĩƒіểя": "ċơņťęאּť ỡƒ ţħíš - +この文字"}') + end + it "should json parse the file" do if Puppet::Util::Platform.windows? allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/') @@ -47,5 +56,6 @@ describe 'load_module_metadata' do result = subject.call(['science', true]) expect(result).to eq({}) end + end end end diff --git a/spec/functions/loadjson_spec.rb b/spec/functions/loadjson_spec.rb index 26125bc..dbef805 100644 --- a/spec/functions/loadjson_spec.rb +++ b/spec/functions/loadjson_spec.rb @@ -23,6 +23,8 @@ describe 'loadjson' do allow(PSON).to receive(:load).never } it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) } + it { is_expected.to run.with_params(filename, {'đẽƒằưļŧ' => '٧ẵłựέ'}).and_return({'đẽƒằưļŧ' => '٧ẵłựέ'}) } + it { is_expected.to run.with_params(filename, {'デフォルト' => '値'}).and_return({'デフォルト' => '値'}) } end context 'when an existing file is specified' do @@ -33,8 +35,8 @@ describe 'loadjson' do '/tmp/doesexist' end } - let(:data) { { 'key' => 'value' } } - let(:json) { '{"key":"value"}' } + let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'} } + let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } before { allow(File).to receive(:exists?).with(filename).and_return(true).once allow(File).to receive(:read).with(filename).and_return(json).once diff --git a/spec/functions/loadyaml_spec.rb b/spec/functions/loadyaml_spec.rb index 9f16a1a..e9428e3 100755 --- a/spec/functions/loadyaml_spec.rb +++ b/spec/functions/loadyaml_spec.rb @@ -11,11 +11,13 @@ describe 'loadyaml' do YAML.expects(:load_file).never } it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) } + it { is_expected.to run.with_params(filename, {'đẽƒằưļŧ' => '٧ẵłựέ'}).and_return({'đẽƒằưļŧ' => '٧ẵłựέ'}) } + it { is_expected.to run.with_params(filename, {'デフォルト' => '値'}).and_return({'デフォルト' => '値'}) } end context 'when an existing file is specified' do let(:filename) { '/tmp/doesexist' } - let(:data) { { 'key' => 'value' } } + let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'} } before { File.expects(:exists?).with(filename).returns(true).once YAML.expects(:load_file).with(filename).returns(data).once diff --git a/spec/functions/parsejson_spec.rb b/spec/functions/parsejson_spec.rb index a01f1f6..7b07e49 100755 --- a/spec/functions/parsejson_spec.rb +++ b/spec/functions/parsejson_spec.rb @@ -12,12 +12,12 @@ describe 'parsejson' do context 'with correct JSON data' do - it 'should be able to parse a JSON data with a Hash' do + it 'should be able to parse JSON data with a Hash' do is_expected.to run.with_params('{"a":"1","b":"2"}'). and_return({'a'=>'1', 'b'=>'2'}) end - it 'should be able to parse a JSON data with an Array' do + it 'should be able to parse JSON data with an Array' do is_expected.to run.with_params('["a","b","c"]'). and_return(['a', 'b', 'c']) end @@ -29,11 +29,16 @@ describe 'parsejson' do and_return({}) end - it 'should be able to parse a JSON data with a mixed structure' do + it 'should be able to parse JSON data with a mixed structure' do is_expected.to run.with_params('{"a":"1","b":2,"c":{"d":[true,false]}}'). and_return({'a' =>'1', 'b' => 2, 'c' => { 'd' => [true, false] } }) end + it 'should be able to parse JSON data with a UTF8 and double byte characters' do + is_expected.to run.with_params('{"×":"これ","ý":"記号","です":{"©":["Á","ß"]}}'). + and_return({'×' =>'これ', 'ý' => '記号', 'です' => { '©' => ['Á', 'ß'] } }) + end + it 'should not return the default value if the data was parsed correctly' do is_expected.to run.with_params('{"a":"1"}', 'default_value'). and_return({'a' => '1'}) diff --git a/spec/functions/parseyaml_spec.rb b/spec/functions/parseyaml_spec.rb index fa947ca..c2a138c 100755 --- a/spec/functions/parseyaml_spec.rb +++ b/spec/functions/parseyaml_spec.rb @@ -18,21 +18,26 @@ describe 'parseyaml' do and_return('just a string') end - it 'should be able to parse a YAML data with a Hash' do + it 'should be able to parse YAML data with a Hash' do is_expected.to run.with_params("---\na: '1'\nb: '2'\n"). and_return({'a' => '1', 'b' => '2'}) end - it 'should be able to parse a YAML data with an Array' do + it 'should be able to parse YAML data with an Array' do is_expected.to run.with_params("---\n- a\n- b\n- c\n"). and_return(['a', 'b', 'c']) end - it 'should be able to parse a YAML data with a mixed structure' do + it 'should be able to parse YAML data with a mixed structure' do is_expected.to run.with_params("---\na: '1'\nb: 2\nc:\n d:\n - :a\n - true\n - false\n"). and_return({'a' => '1', 'b' => 2, 'c' => {'d' => [:a, true, false]}}) end + it 'should be able to parse YAML data with a UTF8 and double byte characters' do + is_expected.to run.with_params("---\na: ×\nこれ: 記号\nです:\n ©:\n - Á\n - ß\n"). + and_return({"a"=>"×", "これ"=>"記号", "です"=>{"©"=>["Á", "ß"]} }) + end + it 'should not return the default value if the data was parsed correctly' do is_expected.to run.with_params("---\na: '1'\n", 'default_value'). and_return({'a' => '1'}) diff --git a/spec/functions/range_spec.rb b/spec/functions/range_spec.rb index 492cad4..ca569d5 100755 --- a/spec/functions/range_spec.rb +++ b/spec/functions/range_spec.rb @@ -79,6 +79,14 @@ describe 'range' do it { is_expected.to run.with_params('01', '04').and_return([1, 2, 3, 4]) } end + context 'with prefixed numbers as utf8 strings as bounds' do + it { is_expected.to run.with_params('ħөŝŧ01', 'ħөŝŧ04').and_return(['ħөŝŧ01', 'ħөŝŧ02', 'ħөŝŧ03', 'ħөŝŧ04']) } + end + + context 'with prefixed numbers as double byte character strings as bounds' do + it { is_expected.to run.with_params('ホスト01', 'ホスト04').and_return(['ホスト01', 'ホスト02', 'ホスト03', 'ホスト04']) } + end + context 'with dash-range syntax' do it { is_expected.to run.with_params('4-1').and_return([]) } it { is_expected.to run.with_params('1-1').and_return([1]) } diff --git a/spec/functions/seeded_rand_spec.rb b/spec/functions/seeded_rand_spec.rb index 38e134e..ac108f4 100644 --- a/spec/functions/seeded_rand_spec.rb +++ b/spec/functions/seeded_rand_spec.rb @@ -50,4 +50,9 @@ describe 'seeded_rand' do scope.function_seeded_rand([max, seed]) end + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params(1000, 'ǿňè')} + it { is_expected.to run.with_params(1000, '文字列')} + end end diff --git a/spec/functions/squeeze_spec.rb b/spec/functions/squeeze_spec.rb index 7f09c30..b267d9a 100755 --- a/spec/functions/squeeze_spec.rb +++ b/spec/functions/squeeze_spec.rb @@ -16,6 +16,12 @@ describe 'squeeze' do it { is_expected.to run.with_params('aaaaaaaaabbbbbbbbbbcccccccccc', 'b-c').and_return('aaaaaaaaabc') } end + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params('ậậậậậậậậậậậậậậậậậậậậ').and_return('ậ') } + it { is_expected.to run.with_params('語語語語語語語', '語').and_return('語') } + it { is_expected.to run.with_params('ậậậậậậậậậậậậậậậậậ語語語語©©©©©', '©').and_return('ậậậậậậậậậậậậậậậậậ語語語語©') } + end + context 'when squeezing values in an array' do it { is_expected.to run \ -- cgit v1.2.3 From 3ed65c0d1b0af1e95a47440b1c2e32c2e00fbd41 Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Tue, 7 Mar 2017 10:25:41 +0000 Subject: (FM-6085) - Unit tests for Data Types --- spec/aliases/absolute_path_spec.rb | 4 ++++ spec/aliases/httpsurl_spec.rb | 6 +++++- spec/aliases/httpurl_spec.rb | 6 +++++- spec/aliases/unixpath_spec.rb | 6 +++++- spec/aliases/windowspath_spec.rb | 7 +++++-- 5 files changed, 24 insertions(+), 5 deletions(-) (limited to 'spec') diff --git a/spec/aliases/absolute_path_spec.rb b/spec/aliases/absolute_path_spec.rb index 3fb9d12..eeda76a 100644 --- a/spec/aliases/absolute_path_spec.rb +++ b/spec/aliases/absolute_path_spec.rb @@ -15,6 +15,8 @@ if Puppet.version.to_f >= 4.5 / /var/tmp /var/opt/../lib/puppet + /var/ůťƒ8 + /var/ネット }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -50,6 +52,8 @@ if Puppet.version.to_f >= 4.5 etc/puppetlabs/puppet opt/puppet/bin relative\\windows + \var\ůťƒ8 + \var\ネット }.each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/httpsurl_spec.rb b/spec/aliases/httpsurl_spec.rb index 97ae006..9cc9a76 100644 --- a/spec/aliases/httpsurl_spec.rb +++ b/spec/aliases/httpsurl_spec.rb @@ -7,6 +7,8 @@ if Puppet.version.to_f >= 4.5 https://hello.com https://notcreative.org https://notexciting.co.uk + https://graphemica.com/❤ + https://graphemica.com/緩 }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -26,7 +28,9 @@ if Puppet.version.to_f >= 4.5 '', "httds://notquiteright.org", "hptts:/nah", - "https;//notrightbutclose.org" + "https;//notrightbutclose.org", + "http://graphemica.com/❤", + "http://graphemica.com/緩" ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/httpurl_spec.rb b/spec/aliases/httpurl_spec.rb index 8bd57ca..f92ddb3 100644 --- a/spec/aliases/httpurl_spec.rb +++ b/spec/aliases/httpurl_spec.rb @@ -10,6 +10,8 @@ if Puppet.version.to_f >= 4.5 http://anhttp.com http://runningoutofideas.gov http:// + http://graphemica.com/❤ + http://graphemica.com/緩 }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -29,7 +31,9 @@ if Puppet.version.to_f >= 4.5 '', "httds://notquiteright.org", "hptts:/nah", - "https;//notrightbutclose.org" + "https;//notrightbutclose.org", + "hts://graphemica.com/❤", + "https:graphemica.com/緩" ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/unixpath_spec.rb b/spec/aliases/unixpath_spec.rb index aee161d..7824cb6 100644 --- a/spec/aliases/unixpath_spec.rb +++ b/spec/aliases/unixpath_spec.rb @@ -7,6 +7,8 @@ if Puppet.version.to_f >= 4.5 /usr2/username/bin:/usr/local/bin:/usr/bin:. /var/tmp /Users/helencampbell/workspace/puppetlabs-stdlib + /var/ůťƒ8 + /var/ネット }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -27,7 +29,9 @@ if Puppet.version.to_f >= 4.5 "C:/whatever", "\\var\\tmp", "\\Users/hc/wksp/stdlib", - "*/Users//nope" + "*/Users//nope", + "var\ůťƒ8", + "var\ネット" ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/windowspath_spec.rb b/spec/aliases/windowspath_spec.rb index c13794e..b8ddcb7 100644 --- a/spec/aliases/windowspath_spec.rb +++ b/spec/aliases/windowspath_spec.rb @@ -10,6 +10,8 @@ if Puppet.version.to_f >= 4.5 X:/foo/bar X:\\foo\\bar \\\\host\\windows + X:/var/ůťƒ8 + X:/var/ネット }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -30,7 +32,9 @@ if Puppet.version.to_f >= 4.5 "httds://notquiteright.org", "/usr2/username/bin:/usr/local/bin:/usr/bin:.", "C;//notright/here", - "C:noslashes" + "C:noslashes", + "C:ネット", + "C:ůťƒ8" ].each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -38,7 +42,6 @@ if Puppet.version.to_f >= 4.5 end end end - end end end -- cgit v1.2.3 From e3d6572694a71971e90213d334ad7639709cce4d Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Wed, 8 Mar 2017 10:56:18 +0000 Subject: (FM-6086) - Unit tests for Resource Types --- spec/unit/puppet/type/file_line_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'spec') diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index c559e44..7da8a7d 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -47,6 +47,24 @@ describe Puppet::Type.type(:file_line) do :match => '^\s*foo=.*$' )}.not_to raise_error end + it 'should accept utf8 characters' do + expect { + Puppet::Type.type(:file_line).new( + :name => 'ƒồỗ', + :path => my_path, + :line => 'ƒồỗ=ьåя', + :match => '^ьåя=βļάħ$' + )}.not_to raise_error + end + it 'should accept double byte characters' do + expect { + Puppet::Type.type(:file_line).new( + :name => 'フーバー', + :path => my_path, + :line => 'この=それ', + :match => '^この=ああ$' + )}.not_to raise_error + end it 'should accept posix filenames' do file_line[:path] = tmp_path expect(file_line[:path]).to eq(tmp_path) -- cgit v1.2.3 From 46e3a2349e9eef4001db8be9581fae9dfbccaf14 Mon Sep 17 00:00:00 2001 From: Geoff Williams Date: Tue, 14 Mar 2017 01:24:36 +1100 Subject: (#FM-6068) allow file encoding to be specified (#726) * (#FM-6068) allow file encoding to be specified Add a new parameter `encoding` to allow non UTF-8 files to specify a file encoding. This prevents receiving the error message "invalid byte sequence in UTF-8" when special characters that are not UTF-8 encoded appear in the input stream, such as the copyright symbol. * (#FM-6068) allow file encoding to be specified Added docs and tests as requested --- spec/unit/puppet/type/file_line_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index 7da8a7d..150149b 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -87,7 +87,12 @@ describe Puppet::Type.type(:file_line) do it 'should default to replace => true' do expect(file_line[:replace]).to eq :true end - + it 'should default to encoding => UTF-8' do + expect(file_line[:encoding]).to eq 'UTF-8' + end + it 'should accept encoding => iso-8859-1' do + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :present, :encoding => 'iso-8859-1', :line => 'bar') }.not_to raise_error + end it "should autorequire the file it manages" do catalog = Puppet::Resource::Catalog.new file = Puppet::Type.type(:file).new(:name => tmp_path) -- cgit v1.2.3 From 318dcfaec6ba6d0e4af1e32e55ea20b721679537 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Tue, 14 Mar 2017 11:16:07 +0000 Subject: (MODULES-4528) Use versioncmp to check Puppet version for 4.10.x compat `Puppet.version.to_f` on Puppet 4.10.0 will evaluate to `4.1`, causing test and behavioural changes when conditionals check that the version is equal or greater than versions such as `4.3`. Version comparisons that are vulnerable to this have been changed to use Puppet's versioncmp implementation, while most others only check for for major version boundaries which is safe. --- spec/aliases/absolute_path_spec.rb | 2 +- spec/aliases/absolutepath_spec.rb | 2 +- spec/aliases/array_spec.rb | 2 +- spec/aliases/bool_spec.rb | 2 +- spec/aliases/float_spec.rb | 2 +- spec/aliases/hash_spec.rb | 2 +- spec/aliases/httpsurl_spec.rb | 2 +- spec/aliases/httpurl_spec.rb | 2 +- spec/aliases/integer_spec.rb | 2 +- spec/aliases/ip_address.rb | 2 +- spec/aliases/ipv4_spec.rb | 2 +- spec/aliases/ipv6_spec.rb | 2 +- spec/aliases/numeric_spec.rb | 2 +- spec/aliases/string_spec.rb | 2 +- spec/aliases/unixpath_spec.rb | 2 +- spec/aliases/windowspath_spec.rb | 2 +- spec/functions/deprecation_spec.rb | 2 +- spec/functions/ensure_resource_spec.rb | 2 +- spec/functions/validate_legacy_spec.rb | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) (limited to 'spec') diff --git a/spec/aliases/absolute_path_spec.rb b/spec/aliases/absolute_path_spec.rb index eeda76a..0e9798e 100644 --- a/spec/aliases/absolute_path_spec.rb +++ b/spec/aliases/absolute_path_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::absolute_path', type: :class do describe 'valid paths handling' do %w{ diff --git a/spec/aliases/absolutepath_spec.rb b/spec/aliases/absolutepath_spec.rb index aa435d7..337074c 100644 --- a/spec/aliases/absolutepath_spec.rb +++ b/spec/aliases/absolutepath_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::absolutepath', type: :class do describe 'valid handling' do %w{ diff --git a/spec/aliases/array_spec.rb b/spec/aliases/array_spec.rb index d0f9877..89cc2af 100644 --- a/spec/aliases/array_spec.rb +++ b/spec/aliases/array_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::array', type: :class do describe 'accepts arrays' do [ diff --git a/spec/aliases/bool_spec.rb b/spec/aliases/bool_spec.rb index 78c57fc..b84ab51 100644 --- a/spec/aliases/bool_spec.rb +++ b/spec/aliases/bool_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::bool', type: :class do describe 'accepts booleans' do [ diff --git a/spec/aliases/float_spec.rb b/spec/aliases/float_spec.rb index cc20758..66079c6 100644 --- a/spec/aliases/float_spec.rb +++ b/spec/aliases/float_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::float', type: :class do describe 'accepts floats' do [ diff --git a/spec/aliases/hash_spec.rb b/spec/aliases/hash_spec.rb index e10a04b..6e5060d 100644 --- a/spec/aliases/hash_spec.rb +++ b/spec/aliases/hash_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::hash', type: :class do describe 'accepts hashes' do [ diff --git a/spec/aliases/httpsurl_spec.rb b/spec/aliases/httpsurl_spec.rb index 9cc9a76..3e51118 100644 --- a/spec/aliases/httpsurl_spec.rb +++ b/spec/aliases/httpsurl_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::httpsurl', type: :class do describe 'valid handling' do %w{ diff --git a/spec/aliases/httpurl_spec.rb b/spec/aliases/httpurl_spec.rb index f92ddb3..fd49a47 100644 --- a/spec/aliases/httpurl_spec.rb +++ b/spec/aliases/httpurl_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::httpurl', type: :class do describe 'valid handling' do %w{ diff --git a/spec/aliases/integer_spec.rb b/spec/aliases/integer_spec.rb index 260090a..bd00c2a 100644 --- a/spec/aliases/integer_spec.rb +++ b/spec/aliases/integer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::integer', type: :class do describe 'accepts integers' do [ diff --git a/spec/aliases/ip_address.rb b/spec/aliases/ip_address.rb index 664bf24..67a555c 100644 --- a/spec/aliases/ip_address.rb +++ b/spec/aliases/ip_address.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::ip_address', type: :class do describe 'accepts ipv4 and ipv6 addresses' do [ diff --git a/spec/aliases/ipv4_spec.rb b/spec/aliases/ipv4_spec.rb index 210b4b1..6a503ad 100644 --- a/spec/aliases/ipv4_spec.rb +++ b/spec/aliases/ipv4_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::ipv4', type: :class do describe 'accepts ipv4 addresses' do SharedData::IPV4_PATTERNS.each do |value| diff --git a/spec/aliases/ipv6_spec.rb b/spec/aliases/ipv6_spec.rb index 6237eba..ae90f42 100644 --- a/spec/aliases/ipv6_spec.rb +++ b/spec/aliases/ipv6_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::ipv6', type: :class do describe 'accepts ipv6 addresses' do [ diff --git a/spec/aliases/numeric_spec.rb b/spec/aliases/numeric_spec.rb index 0e98bee..bc17f4f 100644 --- a/spec/aliases/numeric_spec.rb +++ b/spec/aliases/numeric_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::numeric', type: :class do describe 'accepts numerics' do [ diff --git a/spec/aliases/string_spec.rb b/spec/aliases/string_spec.rb index 8a93585..d8fb885 100644 --- a/spec/aliases/string_spec.rb +++ b/spec/aliases/string_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::string', type: :class do describe 'accepts strings' do [ diff --git a/spec/aliases/unixpath_spec.rb b/spec/aliases/unixpath_spec.rb index 7824cb6..ac7d64d 100644 --- a/spec/aliases/unixpath_spec.rb +++ b/spec/aliases/unixpath_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::unixpath', type: :class do describe 'valid handling' do %w{ diff --git a/spec/aliases/windowspath_spec.rb b/spec/aliases/windowspath_spec.rb index b8ddcb7..c20e373 100644 --- a/spec/aliases/windowspath_spec.rb +++ b/spec/aliases/windowspath_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::windowspath', type: :class do describe 'valid handling' do %w{ diff --git a/spec/functions/deprecation_spec.rb b/spec/functions/deprecation_spec.rb index 8a65b69..bde4e89 100644 --- a/spec/functions/deprecation_spec.rb +++ b/spec/functions/deprecation_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'deprecation' do before(:each) { # this is to reset the strict variable to default diff --git a/spec/functions/ensure_resource_spec.rb b/spec/functions/ensure_resource_spec.rb index fddc4c4..5366205 100755 --- a/spec/functions/ensure_resource_spec.rb +++ b/spec/functions/ensure_resource_spec.rb @@ -4,7 +4,7 @@ describe 'ensure_resource' do it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a type/) } it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, /Must specify a title/) } - if Puppet.version.to_f >= 4.6 + if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0 it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(ArgumentError) } else it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(Puppet::ParseError) } diff --git a/spec/functions/validate_legacy_spec.rb b/spec/functions/validate_legacy_spec.rb index 10b2aee..7b48f12 100644 --- a/spec/functions/validate_legacy_spec.rb +++ b/spec/functions/validate_legacy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.4 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.4.0') >= 0 describe 'validate_legacy' do it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params.and_raise_error(ArgumentError) } -- cgit v1.2.3 From 2d9a94ebe827d88222c46af33416ae333ae102b2 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Mon, 13 Mar 2017 14:09:29 +0000 Subject: Addition of new length function --- spec/functions/length.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 spec/functions/length.rb (limited to 'spec') diff --git a/spec/functions/length.rb b/spec/functions/length.rb new file mode 100755 index 0000000..d1ab003 --- /dev/null +++ b/spec/functions/length.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe 'length' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(ArgumentError, /'length' expects 1 argument, got none/) } + it { is_expected.to run.with_params([], 'extra').and_raise_error(ArgumentError, /'length' expects 1 argument, got 2/) } + it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, /expects a value of type String, Array, or Hash, got Integer/) } + it { is_expected.to run.with_params(true).and_raise_error(ArgumentError, /expects a value of type String, Array, or Hash, got Boolean/) } + it { is_expected.to run.with_params('1').and_return(1) } + it { is_expected.to run.with_params('1.0').and_return(3) } + it { is_expected.to run.with_params([]).and_return(0) } + it { is_expected.to run.with_params(['a']).and_return(1) } + it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) } + it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(4) } + + it { is_expected.to run.with_params({}).and_return(0) } + it { is_expected.to run.with_params({'1' => '2'}).and_return(1) } + it { is_expected.to run.with_params({'1' => '2', '4' => '4'}).and_return(2) } + it { is_expected.to run.with_params({'€' => '@', '竹' => 'ǿňè'}).and_return(2) } + + it { is_expected.to run.with_params('').and_return(0) } + it { is_expected.to run.with_params('a').and_return(1) } + it { is_expected.to run.with_params('abc').and_return(3) } + it { is_expected.to run.with_params('abcd').and_return(4) } + it { is_expected.to run.with_params('万').and_return(1) } + it { is_expected.to run.with_params('āβćđ').and_return(4) } + + context 'when using a class extending String' do + it 'should call its size method' do + value = AlsoString.new('asdfghjkl') + value.expects(:length).returns('foo') + expect(subject).to run.with_params(value).and_return('foo') + end + end +end -- cgit v1.2.3 From 0bca13947be9f55b7456cc78e2ba979bd7aa1c8c Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Wed, 15 Mar 2017 10:24:00 +0000 Subject: Permit double slash in absolute/Unix path types --- spec/aliases/absolute_path_spec.rb | 1 + spec/aliases/absolutepath_spec.rb | 1 + spec/aliases/unixpath_spec.rb | 2 ++ 3 files changed, 4 insertions(+) (limited to 'spec') diff --git a/spec/aliases/absolute_path_spec.rb b/spec/aliases/absolute_path_spec.rb index eeda76a..682c283 100644 --- a/spec/aliases/absolute_path_spec.rb +++ b/spec/aliases/absolute_path_spec.rb @@ -15,6 +15,7 @@ if Puppet.version.to_f >= 4.5 / /var/tmp /var/opt/../lib/puppet + /var/opt//lib/puppet /var/ůťƒ8 /var/ネット }.each do |value| diff --git a/spec/aliases/absolutepath_spec.rb b/spec/aliases/absolutepath_spec.rb index aa435d7..a20c071 100644 --- a/spec/aliases/absolutepath_spec.rb +++ b/spec/aliases/absolutepath_spec.rb @@ -15,6 +15,7 @@ if Puppet.version.to_f >= 4.5 //host/windows /var/tmp /var/opt/../lib/puppet + /var/opt//lib/puppet }.each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/unixpath_spec.rb b/spec/aliases/unixpath_spec.rb index 7824cb6..505516a 100644 --- a/spec/aliases/unixpath_spec.rb +++ b/spec/aliases/unixpath_spec.rb @@ -9,6 +9,8 @@ if Puppet.version.to_f >= 4.5 /Users/helencampbell/workspace/puppetlabs-stdlib /var/ůťƒ8 /var/ネット + /var//tmp + /var/../tmp }.each do |value| describe value.inspect do let(:params) {{ value: value }} -- cgit v1.2.3 From da75bdfa7c067049b4be362fb2a6fad719e6fc3e Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Tue, 21 Mar 2017 10:52:20 +0000 Subject: Update alias spec error message expectation for PUP-7371 The fix for PUP-7371 adds the missing `Undef` into the error message being tested in type aliases specs, fixing the following failure against Puppet's master branch: test::string rejects other values [] should fail to compile and raise an error matching /parameter 'value' expects a String/ Failure/Error: it { is_expected.to compile.and_raise_error(/parameter 'value' expects a String/) } error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Class[Test::String]: parameter 'value' expects a value of type Undef or String, got Array at line 2:1 on node example # ./spec/aliases/string_spec.rb:27:in `block (5 levels) in ' --- spec/aliases/string_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/aliases/string_spec.rb b/spec/aliases/string_spec.rb index d8fb885..3ea1967 100644 --- a/spec/aliases/string_spec.rb +++ b/spec/aliases/string_spec.rb @@ -24,7 +24,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 ].each do |value| describe value.inspect do let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a String/) } + it { is_expected.to compile.and_raise_error(/parameter 'value' expects a (?:value of type Undef or )?String/) } end end end -- cgit v1.2.3 From c4d84d49069dc0b2bcf834f5aec93ed9f7a65bcb Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 13 Apr 2017 16:36:59 -0700 Subject: (maint) Stdlib::Compat::Integer accepts numbers with newlines apparently --- spec/aliases/integer_spec.rb | 4 +++- spec/functions/is_integer_spec.rb | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/aliases/integer_spec.rb b/spec/aliases/integer_spec.rb index bd00c2a..8cb4658 100644 --- a/spec/aliases/integer_spec.rb +++ b/spec/aliases/integer_spec.rb @@ -8,6 +8,8 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 '3', -3, '-3', + "123\nfoo", + "foo\n123", ].each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -17,7 +19,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 end describe 'rejects other values' do - [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3.7, '3.7',-3.7, '-342.2315e-12' ].each do |value| + [ "foo\nbar", true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3.7, '3.7',-3.7, '-342.2315e-12' ].each do |value| describe value.inspect do let(:params) {{ value: value }} it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Integer, Pattern(\[.*\]+)?, or Array/) } diff --git a/spec/functions/is_integer_spec.rb b/spec/functions/is_integer_spec.rb index b296830..8118ef4 100755 --- a/spec/functions/is_integer_spec.rb +++ b/spec/functions/is_integer_spec.rb @@ -11,6 +11,8 @@ describe 'is_integer' do it { is_expected.to run.with_params('3').and_return(true) } it { is_expected.to run.with_params(-3).and_return(true) } it { is_expected.to run.with_params('-3').and_return(true) } + it { is_expected.to run.with_params("123\nfoo").and_return(true) } + it { is_expected.to run.with_params("foo\n123").and_return(true) } it { is_expected.to run.with_params(3.7).and_return(false) } it { is_expected.to run.with_params('3.7').and_return(false) } @@ -24,6 +26,7 @@ describe 'is_integer' do it { is_expected.to run.with_params(true).and_return(false) } it { is_expected.to run.with_params(false).and_return(false) } it { is_expected.to run.with_params('0001234').and_return(false) } + it { is_expected.to run.with_params("foo\nbar").and_return(false) } context 'Checking for deprecation warning' do after(:all) do -- cgit v1.2.3 From 4f19c27137d6de29ae63bf73115f1e8fefd00b03 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 25 Apr 2017 12:08:46 -0700 Subject: (PE-20308) Pass a literal type and not a string to findresource - `defined_with_params` calls `findresource(reference.to_s)` - `findresource` is https://github.com/puppetlabs/puppet/blob/4.8.1/lib/puppet/parser/compiler.rb#L407 and points to https://github.com/puppetlabs/puppet/blob/4.8.1/lib/puppet/resource/catalog.rb#L352 - This calls `Puppet::Resource.new` with the type https://github.com/puppetlabs/puppet/blob/4.8.1/lib/puppet/resource/catalog.rb#L366 - This ends up calling `resource_type` via https://github.com/puppetlabs/puppet/blob/4.8.1/lib/puppet/resource.rb#L317-L319 and that ends up declaring the type via the autoloader api at https://github.com/puppetlabs/puppet/blob/4.8.1/lib/puppet/resource.rb#L390 - But why does the autoloader API fail to find it in the current environment? - Okay, so when the autoloader is trying to find the type, it uses the typeloader to look it up in the current environment https://github.com/puppetlabs/puppet/blob/4.8.1/lib/puppet/metatype/manager.rb#L171 - this calls `get_file` and `mark_loaded` https://github.com/puppetlabs/puppet/blob/4.8.1/lib/puppet/util/autoload.rb#L64-L67 Suggested workaround is to pass a literal type instead of a string to `findresource` to fix in stdlib, and also to fix loading/requiring of type in core puppet. This seems to affect more recent versions of puppet, so fallback to original behavior on pre-4.5 --- spec/functions/defined_with_params_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'spec') diff --git a/spec/functions/defined_with_params_spec.rb b/spec/functions/defined_with_params_spec.rb index a0db0b7..979e25a 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -37,4 +37,22 @@ describe 'defined_with_params' do it { is_expected.to run.with_params('File[/tmp/a]', {}).and_return(true) } it { is_expected.to run.with_params('File[/tmp/a]', { 'ensure' => 'present', 'owner' => :undef }).and_return(true) } end + + describe 'when the reference is a' do + let :pre_condition do + 'user { "dan": }' + end + context 'reference' do + it { is_expected.to run.with_params(Puppet::Resource.new('User[dan]'), {}).and_return(true) } + end + if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + context 'array' do + it 'fails' do + expect { + subject.call([['User[dan]'], {}]) + }.to raise_error ArgumentError, /not understood: 'Array'/ + end + end + end + end end -- cgit v1.2.3 From ccabfd3e1f4617a583546efaa4303bc24e53b89c Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 26 Apr 2017 09:18:43 -0700 Subject: (PE-20308) Correct boundary for 4.5 vs 4.6 --- spec/functions/defined_with_params_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/functions/defined_with_params_spec.rb b/spec/functions/defined_with_params_spec.rb index 979e25a..7118d85 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -45,7 +45,7 @@ describe 'defined_with_params' do context 'reference' do it { is_expected.to run.with_params(Puppet::Resource.new('User[dan]'), {}).and_return(true) } end - if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0 context 'array' do it 'fails' do expect { -- cgit v1.2.3 From 9244c67206363f8e887531b164fc24cef729f3d8 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Thu, 27 Apr 2017 10:00:04 +0100 Subject: Test for defined_with_params() returning false for defined types defined_with_params() now returns false for defined types, causing duplicate resources when using ensure_resources(). Introduced by 4f19c27 in PE-20308. --- spec/fixtures/test/manifests/deftype.pp | 3 +++ spec/functions/defined_with_params_spec.rb | 8 ++++++++ spec/functions/ensure_resource_spec.rb | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 spec/fixtures/test/manifests/deftype.pp (limited to 'spec') diff --git a/spec/fixtures/test/manifests/deftype.pp b/spec/fixtures/test/manifests/deftype.pp new file mode 100644 index 0000000..825f8fe --- /dev/null +++ b/spec/fixtures/test/manifests/deftype.pp @@ -0,0 +1,3 @@ +define test::deftype($param = 'foo') { + notify { "deftype: $title": } +} diff --git a/spec/functions/defined_with_params_spec.rb b/spec/functions/defined_with_params_spec.rb index 7118d85..775fa74 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -55,4 +55,12 @@ describe 'defined_with_params' do end end end + + describe 'when passed a defined type' do + let :pre_condition do + 'test::deftype { "foo": }' + end + it { is_expected.to run.with_params('Test::Deftype[foo]', {}).and_return(true) } + it { is_expected.to run.with_params('Test::Deftype[bar]', {}).and_return(false) } + end end diff --git a/spec/functions/ensure_resource_spec.rb b/spec/functions/ensure_resource_spec.rb index 5366205..c847bf7 100755 --- a/spec/functions/ensure_resource_spec.rb +++ b/spec/functions/ensure_resource_spec.rb @@ -38,6 +38,13 @@ describe 'ensure_resource' do it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') } it { expect(lambda { catalogue }).to contain_user('username1').without_gid } end + + describe 'after running ensure_resource("test::deftype", "foo", {})' do + before { subject.call(['test::deftype', 'foo', {}]) } + + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_test__deftype('foo').without_ensure } + end end context 'given a catalog with UTF8 chars' do @@ -114,4 +121,15 @@ describe 'ensure_resource' do } end end + + context 'given a catalog with "test::deftype { foo: }"' do + let(:pre_condition) { 'test::deftype { "foo": }' } + + describe 'after running ensure_resource("test::deftype", "foo", {})' do + before { subject.call(['test::deftype', 'foo', {}]) } + + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_test__deftype('foo').without_ensure } + end + end end -- cgit v1.2.3 From 32e5a87bb3b8c1d0fabc1e8c2687e4a750173cb5 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 28 Apr 2017 15:48:56 -0700 Subject: (PE-20308) Also fix defined type strings & references --- spec/functions/defined_with_params_spec.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'spec') diff --git a/spec/functions/defined_with_params_spec.rb b/spec/functions/defined_with_params_spec.rb index 775fa74..491a03b 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -62,5 +62,7 @@ describe 'defined_with_params' do end it { is_expected.to run.with_params('Test::Deftype[foo]', {}).and_return(true) } it { is_expected.to run.with_params('Test::Deftype[bar]', {}).and_return(false) } + it { is_expected.to run.with_params(Puppet::Resource.new('Test::Deftype[foo]'), {}).and_return(true) } + it { is_expected.to run.with_params(Puppet::Resource.new('Test::Deftype[bar]'), {}).and_return(false) } end end -- cgit v1.2.3 From 51fd72ca4accb2760a364d65dfe6f9b672f68d83 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 28 Apr 2017 13:47:47 -0700 Subject: add tests --- spec/functions/ensure_packages_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'spec') diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 6f94d72..1f89785 100755 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -34,6 +34,14 @@ describe 'ensure_packages' do end end + context 'given an empty packages array' do + let(:pre_condition) { 'notify { "hi": } -> Package <| |>; $somearray = ["vim",""]; ensure_packages($somearray)' } + + describe 'after running ensure_package(["vim", ""])' do + it { expect { catalogue }.to raise_error(Puppet::ParseError, /Empty String provided/) } + end + end + context 'given hash of packages' do before { subject.call([{"foo" => { "provider" => "rpm" }, "bar" => { "provider" => "gem" }}, { "ensure" => "present"}]) } before { subject.call([{"パッケージ" => { "ensure" => "absent"}}]) } -- cgit v1.2.3 From 58131d8ff1886352e964aafef58ffeb65c5d2cdd Mon Sep 17 00:00:00 2001 From: tphoney Date: Mon, 3 Jul 2017 17:08:09 +0100 Subject: (MODULES-5003) file_line fix all broken lines --- spec/unit/puppet/provider/file_line/ruby_spec.rb | 37 ++++++++++++++++++------ 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'spec') diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb index 1f41f62..0e12aa2 100755 --- a/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb @@ -29,7 +29,7 @@ describe provider_class do File.open(tmpfile, 'w') do |fh| fh.write('foo1') end - expect(provider.exists?).to be_nil + expect(provider.exists?).to eql (false) end it 'should append to an existing file when creating' do provider.create @@ -69,7 +69,7 @@ describe provider_class do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo2") end - expect(@provider.exists?).to be_nil + expect(@provider.exists?).to eql (false) @provider.create expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo2\nfoo = bar") end @@ -112,7 +112,7 @@ describe provider_class do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz") end - expect(@provider.exists?).to be_nil + expect(@provider.exists?).to eql(false) expect { @provider.create }.to raise_error(Puppet::Error, /More than one line.*matches/) expect(File.read(@tmpfile)).to eql("foo1\nfoo=blah\nfoo2\nfoo=baz") end @@ -131,11 +131,30 @@ describe provider_class do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz") end - expect(@provider.exists?).to be_nil + expect(@provider.exists?).to eql(false) @provider.create expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2\nfoo = bar") end + it 'should replace all lines that match, even when some lines are correct' do + @resource = Puppet::Type::File_line.new( + { + :name => 'neil', + :path => @tmpfile, + :line => "\thard\tcore\t0\n", + :match => '^[ \t]hard[ \t]+core[ \t]+.*', + :multiple => true, + } + ) + @provider = provider_class.new(@resource) + File.open(@tmpfile, 'w') do |fh| + fh.write("\thard\tcore\t90\n\thard\tcore\t0\n") + end + expect(@provider.exists?).to eql(false) + @provider.create + expect(File.read(@tmpfile).chomp).to eql("\thard\tcore\t0\n\thard\tcore\t0") + end + it 'should raise an error with invalid values' do expect { @resource = Puppet::Type::File_line.new( @@ -154,7 +173,7 @@ describe provider_class do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo=blah\nfoo2") end - expect(@provider.exists?).to be_nil + expect(@provider.exists?).to eql(false) @provider.create expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") end @@ -162,7 +181,7 @@ describe provider_class do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo2") end - expect(@provider.exists?).to be_nil + expect(@provider.exists?).to eql(false) @provider.create expect(File.read(@tmpfile)).to eql("foo1\nfoo2\nfoo = bar\n") end @@ -170,7 +189,7 @@ describe provider_class do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo = bar\nfoo2") end - expect(@provider.exists?).to be_truthy + expect(@provider.exists?).to eql(false) @provider.create expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") end @@ -274,7 +293,7 @@ describe provider_class do } ) @provider = provider_class.new(@resource) - expect(@provider.exists?).to be_nil + expect(@provider.exists?).to eql (false) @provider.create expect(File.read(@tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo1\ninserted = line\nfoo = baz") end @@ -367,7 +386,7 @@ describe provider_class do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo\nfoo2") end - expect(@provider.exists?).to be_truthy + expect(@provider.exists?).to be_nil end it 'should remove one line if it matches' do -- cgit v1.2.3 From 085496fd19c21bf2d02b8ad871d7cab850b92b93 Mon Sep 17 00:00:00 2001 From: tphoney Date: Thu, 6 Jul 2017 12:02:58 +0100 Subject: (MODULES-5186) move test to correct location --- spec/functions/ensure_resources_spec.rb | 22 ++++++++++++++++++++++ spec/unit/ensure_resources_spec.rb | 22 ---------------------- 2 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 spec/functions/ensure_resources_spec.rb delete mode 100644 spec/unit/ensure_resources_spec.rb (limited to 'spec') diff --git a/spec/functions/ensure_resources_spec.rb b/spec/functions/ensure_resources_spec.rb new file mode 100644 index 0000000..aea723e --- /dev/null +++ b/spec/functions/ensure_resources_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +describe 'test::ensure_resources', type: :class do + let(:params) {{ resource_type: 'user', title_hash: title_param, attributes_hash: {'ensure' => 'present'} }} + + describe 'given a title hash of multiple resources' do + + let(:title_param) { {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700'}} } + + it { is_expected.to compile } + it { is_expected.to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600', 'ensure' => 'present'}) } + it { is_expected.to contain_user('alex').with({ 'gid' => 'mygroup', 'uid' => '700', 'ensure' => 'present'}) } + end + + describe 'given a title hash of a single resource' do + + let(:title_param) { {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }} } + + it { is_expected.to compile } + it { is_expected.to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600', 'ensure' => 'present'}) } + end +end diff --git a/spec/unit/ensure_resources_spec.rb b/spec/unit/ensure_resources_spec.rb deleted file mode 100644 index aea723e..0000000 --- a/spec/unit/ensure_resources_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe 'test::ensure_resources', type: :class do - let(:params) {{ resource_type: 'user', title_hash: title_param, attributes_hash: {'ensure' => 'present'} }} - - describe 'given a title hash of multiple resources' do - - let(:title_param) { {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700'}} } - - it { is_expected.to compile } - it { is_expected.to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600', 'ensure' => 'present'}) } - it { is_expected.to contain_user('alex').with({ 'gid' => 'mygroup', 'uid' => '700', 'ensure' => 'present'}) } - end - - describe 'given a title hash of a single resource' do - - let(:title_param) { {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }} } - - it { is_expected.to compile } - it { is_expected.to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600', 'ensure' => 'present'}) } - end -end -- cgit v1.2.3 From 700b735893b77f6ebc6420f72f1e474d5053f12b Mon Sep 17 00:00:00 2001 From: tphoney Date: Fri, 7 Jul 2017 15:28:52 +0100 Subject: (MODULES-5186) dont run this test on windows --- spec/unit/puppet/provider/file_line/ruby_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb index 1f41f62..3d28687 100755 --- a/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb @@ -2,7 +2,8 @@ require 'spec_helper' require 'tempfile' provider_class = Puppet::Type.type(:file_line).provider(:ruby) -describe provider_class do +# These tests fail on windows when run as part of the rake task. Individually they pass +describe provider_class, :unless => Puppet::Util::Platform.windows? do context "when adding" do let :tmpfile do tmp = Tempfile.new('tmp') -- cgit v1.2.3 From fe7ccd8b89556cc6cc1f5ea7f58b5ac2aedb23ec Mon Sep 17 00:00:00 2001 From: Frank de Jong Date: Sat, 8 Jul 2017 09:43:40 +0200 Subject: Add validate_domain_name function --- spec/functions/validate_domain_name_spec.rb | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 spec/functions/validate_domain_name_spec.rb (limited to 'spec') diff --git a/spec/functions/validate_domain_name_spec.rb b/spec/functions/validate_domain_name_spec.rb new file mode 100644 index 0000000..69fcae4 --- /dev/null +++ b/spec/functions/validate_domain_name_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe 'validate_domain_name' do + describe 'signature validation' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + end + + describe 'valid inputs' do + it { is_expected.to run.with_params('com', 'com.') } + it { is_expected.to run.with_params('x.com', 'x.com.') } + it { is_expected.to run.with_params('foo.example.com', 'foo.example.com.') } + it { is_expected.to run.with_params('2foo.example.com', '2foo.example.com.') } + it { is_expected.to run.with_params('www.2foo.example.com', 'www.2foo.example.com.') } + it { is_expected.to run.with_params('domain.tld', 'puppet.com') } + end + + describe 'invalid inputs' do + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /is not a string/) } + it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) } + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) } + it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) } + + it { is_expected.to run.with_params('foo.example.com', []).and_raise_error(Puppet::ParseError, /is not a string/) } + it { is_expected.to run.with_params('foo.example.com', {}).and_raise_error(Puppet::ParseError, /is not a string/) } + it { is_expected.to run.with_params('foo.example.com', 1).and_raise_error(Puppet::ParseError, /is not a string/) } + it { is_expected.to run.with_params('foo.example.com', true).and_raise_error(Puppet::ParseError, /is not a string/) } + + it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /is not a syntactically correct domain name/) } + it { is_expected.to run.with_params('invalid domain').and_raise_error(Puppet::ParseError, /is not a syntactically correct domain name/) } + it { is_expected.to run.with_params('-foo.example.com').and_raise_error(Puppet::ParseError, /is not a syntactically correct domain name/) } + it { is_expected.to run.with_params('www.example.2com').and_raise_error(Puppet::ParseError, /is not a syntactically correct domain name/) } + it { is_expected.to run.with_params('192.168.1.1').and_raise_error(Puppet::ParseError, /is not a syntactically correct domain name/) } + end +end -- cgit v1.2.3 From 2220810c4ad8ea22b2cdc58bc0b9c7392a388b01 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Sun, 14 May 2017 14:16:28 +0100 Subject: Fix filenames of two function spec tests The tests weren't being run. Total tests increase from 2742 to 2769. Also fix 'when using a class extending String' test. It had been failing with... ``` RuntimeError: can't modify frozen AlsoString ``` --- spec/functions/is_function_available.rb | 9 ------- spec/functions/is_function_available_spec.rb | 9 +++++++ spec/functions/length.rb | 35 ---------------------------- spec/functions/length_spec.rb | 31 ++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 44 deletions(-) delete mode 100755 spec/functions/is_function_available.rb create mode 100755 spec/functions/is_function_available_spec.rb delete mode 100755 spec/functions/length.rb create mode 100755 spec/functions/length_spec.rb (limited to 'spec') diff --git a/spec/functions/is_function_available.rb b/spec/functions/is_function_available.rb deleted file mode 100755 index 44f08c0..0000000 --- a/spec/functions/is_function_available.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'spec_helper' - -describe 'is_function_available' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { is_expected.to run.with_params('include').and_return(true) } - it { is_expected.to run.with_params('no_such_function').and_return(false) } -end diff --git a/spec/functions/is_function_available_spec.rb b/spec/functions/is_function_available_spec.rb new file mode 100755 index 0000000..44f08c0 --- /dev/null +++ b/spec/functions/is_function_available_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe 'is_function_available' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { is_expected.to run.with_params('include').and_return(true) } + it { is_expected.to run.with_params('no_such_function').and_return(false) } +end diff --git a/spec/functions/length.rb b/spec/functions/length.rb deleted file mode 100755 index d1ab003..0000000 --- a/spec/functions/length.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe 'length' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(ArgumentError, /'length' expects 1 argument, got none/) } - it { is_expected.to run.with_params([], 'extra').and_raise_error(ArgumentError, /'length' expects 1 argument, got 2/) } - it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, /expects a value of type String, Array, or Hash, got Integer/) } - it { is_expected.to run.with_params(true).and_raise_error(ArgumentError, /expects a value of type String, Array, or Hash, got Boolean/) } - it { is_expected.to run.with_params('1').and_return(1) } - it { is_expected.to run.with_params('1.0').and_return(3) } - it { is_expected.to run.with_params([]).and_return(0) } - it { is_expected.to run.with_params(['a']).and_return(1) } - it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(4) } - - it { is_expected.to run.with_params({}).and_return(0) } - it { is_expected.to run.with_params({'1' => '2'}).and_return(1) } - it { is_expected.to run.with_params({'1' => '2', '4' => '4'}).and_return(2) } - it { is_expected.to run.with_params({'€' => '@', '竹' => 'ǿňè'}).and_return(2) } - - it { is_expected.to run.with_params('').and_return(0) } - it { is_expected.to run.with_params('a').and_return(1) } - it { is_expected.to run.with_params('abc').and_return(3) } - it { is_expected.to run.with_params('abcd').and_return(4) } - it { is_expected.to run.with_params('万').and_return(1) } - it { is_expected.to run.with_params('āβćđ').and_return(4) } - - context 'when using a class extending String' do - it 'should call its size method' do - value = AlsoString.new('asdfghjkl') - value.expects(:length).returns('foo') - expect(subject).to run.with_params(value).and_return('foo') - end - end -end diff --git a/spec/functions/length_spec.rb b/spec/functions/length_spec.rb new file mode 100755 index 0000000..487cf21 --- /dev/null +++ b/spec/functions/length_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe 'length' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(ArgumentError, /'length' expects 1 argument, got none/) } + it { is_expected.to run.with_params([], 'extra').and_raise_error(ArgumentError, /'length' expects 1 argument, got 2/) } + it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, /expects a value of type String, Array, or Hash, got Integer/) } + it { is_expected.to run.with_params(true).and_raise_error(ArgumentError, /expects a value of type String, Array, or Hash, got Boolean/) } + it { is_expected.to run.with_params('1').and_return(1) } + it { is_expected.to run.with_params('1.0').and_return(3) } + it { is_expected.to run.with_params([]).and_return(0) } + it { is_expected.to run.with_params(['a']).and_return(1) } + it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) } + it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(4) } + + it { is_expected.to run.with_params({}).and_return(0) } + it { is_expected.to run.with_params({'1' => '2'}).and_return(1) } + it { is_expected.to run.with_params({'1' => '2', '4' => '4'}).and_return(2) } + it { is_expected.to run.with_params({'€' => '@', '竹' => 'ǿňè'}).and_return(2) } + + it { is_expected.to run.with_params('').and_return(0) } + it { is_expected.to run.with_params('a').and_return(1) } + it { is_expected.to run.with_params('abc').and_return(3) } + it { is_expected.to run.with_params('abcd').and_return(4) } + it { is_expected.to run.with_params('万').and_return(1) } + it { is_expected.to run.with_params('āβćđ').and_return(4) } + + context 'when using a class extending String' do + it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return(9) } + end +end -- cgit v1.2.3 From 715c40dc9083068598387ab67396136e87eb553d Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Tue, 11 Jul 2017 15:43:37 -0700 Subject: (MODULES-5187) fix spec tests for puppet 5 changes --- spec/aliases/integer_spec.rb | 6 +++++- spec/functions/merge_spec.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/aliases/integer_spec.rb b/spec/aliases/integer_spec.rb index 8cb4658..aec9fd6 100644 --- a/spec/aliases/integer_spec.rb +++ b/spec/aliases/integer_spec.rb @@ -22,7 +22,11 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 [ "foo\nbar", true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3.7, '3.7',-3.7, '-342.2315e-12' ].each do |value| describe value.inspect do let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Integer, Pattern(\[.*\]+)?, or Array/) } + if Gem::Version.new(Puppet.version) >= Gem::Version.new('5.0.0') + it { is_expected.to compile.and_raise_error(/parameter 'value' expects a Stdlib::Compat::Integer = Variant\[Integer, Pattern\[.*\], Array\[.*\]\] value/) } + else + it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Integer, Pattern(\[.*\]+)?, or Array/) } + end end end end diff --git a/spec/functions/merge_spec.rb b/spec/functions/merge_spec.rb index 7b53363..3b2e3ef 100755 --- a/spec/functions/merge_spec.rb +++ b/spec/functions/merge_spec.rb @@ -4,7 +4,7 @@ describe 'merge' do it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } it { is_expected.to run.with_params({}, 'two').and_raise_error(Puppet::ParseError, /unexpected argument type String/) } - it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, /unexpected argument type Fixnum/) } + it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, /unexpected argument type (Fixnum|Integer)/) } it { pending 'should not special case this' is_expected.to run.with_params({}).and_return({}) -- cgit v1.2.3 From 01d3004f0a6a1c662aea90edd5b1524139706c61 Mon Sep 17 00:00:00 2001 From: tphoney Date: Thu, 13 Jul 2017 16:12:08 +0100 Subject: (FM-6239) rewrite of test following std patterns --- spec/functions/ensure_resources_spec.rb | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'spec') diff --git a/spec/functions/ensure_resources_spec.rb b/spec/functions/ensure_resources_spec.rb index aea723e..7cca671 100644 --- a/spec/functions/ensure_resources_spec.rb +++ b/spec/functions/ensure_resources_spec.rb @@ -1,22 +1,25 @@ require 'spec_helper' -describe 'test::ensure_resources', type: :class do - let(:params) {{ resource_type: 'user', title_hash: title_param, attributes_hash: {'ensure' => 'present'} }} +describe 'ensure_resources' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a type/) } + it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, /Must specify a title/) } describe 'given a title hash of multiple resources' do + before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700'}}, {'ensure' => 'present'}]) } - let(:title_param) { {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700'}} } - - it { is_expected.to compile } - it { is_expected.to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600', 'ensure' => 'present'}) } - it { is_expected.to contain_user('alex').with({ 'gid' => 'mygroup', 'uid' => '700', 'ensure' => 'present'}) } + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') } + it { expect(lambda { catalogue }).to contain_user('alex').with_ensure('present') } + it { expect(lambda { catalogue }).to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600'}) } + it { expect(lambda { catalogue }).to contain_user('alex').with({ 'gid' => 'mygroup', 'uid' => '700'}) } end describe 'given a title hash of a single resource' do + before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }}, {'ensure' => 'present'}]) } - let(:title_param) { {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }} } - - it { is_expected.to compile } - it { is_expected.to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600', 'ensure' => 'present'}) } + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') } + it { expect(lambda { catalogue }).to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600'}) } end end -- cgit v1.2.3 From 81d7d35fd78917ee1a5e66cb7459ea341bc452ea Mon Sep 17 00:00:00 2001 From: tkishel Date: Thu, 13 Jul 2017 15:16:04 -0700 Subject: (MODULES-5003) file_line_does_not_change_multiple_lines_when_one_matches The exists? method is called to determine the need to call the create and destroy methods. When the ensure, match, and multiple attributes are defined, the exists? method needs to return false unless all the lines that match the match attribute equal the line attribute. The first commit is minimal, and implements this change. The second commit normalizes the code, which I needed for comprehension. --- spec/unit/puppet/provider/file_line/ruby_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb index dcf8509..ab6edf9 100755 --- a/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb @@ -190,7 +190,7 @@ describe provider_class, :unless => Puppet::Util::Platform.windows? do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo = bar\nfoo2") end - expect(@provider.exists?).to eql(false) + expect(@provider.exists?).to eql(true) @provider.create expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") end @@ -387,7 +387,7 @@ describe provider_class, :unless => Puppet::Util::Platform.windows? do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo\nfoo2") end - expect(@provider.exists?).to be_nil + expect(@provider.exists?).to eql (true) end it 'should remove one line if it matches' do -- cgit v1.2.3 From 33922a4ec7a8c204a17e0c3017eea21faa220f39 Mon Sep 17 00:00:00 2001 From: tphoney Date: Fri, 14 Jul 2017 10:14:04 +0100 Subject: FM-6239 clean up for puppet 5.tests/deprecation --- spec/aliases/absolutepath_spec.rb | 2 +- spec/aliases/float_spec.rb | 2 +- spec/aliases/numeric_spec.rb | 2 +- spec/aliases/string_spec.rb | 2 +- spec/functions/deep_merge_spec.rb | 2 +- spec/functions/strftime_spec.rb | 4 ++-- spec/functions/unique_spec.rb | 46 ++++++++++++++++++++------------------- 7 files changed, 31 insertions(+), 29 deletions(-) (limited to 'spec') diff --git a/spec/aliases/absolutepath_spec.rb b/spec/aliases/absolutepath_spec.rb index cd442f2..ff23dc0 100644 --- a/spec/aliases/absolutepath_spec.rb +++ b/spec/aliases/absolutepath_spec.rb @@ -40,7 +40,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 ].each do |value| describe value.inspect do let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Variant/) } + it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for.*Variant/) } end end end diff --git a/spec/aliases/float_spec.rb b/spec/aliases/float_spec.rb index 66079c6..84e1934 100644 --- a/spec/aliases/float_spec.rb +++ b/spec/aliases/float_spec.rb @@ -20,7 +20,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3, '3', -3, '-3'].each do |value| describe value.inspect do let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Float or Pattern(\[.*\]+)?/) } + it { is_expected.to compile.and_raise_error(/parameter 'value' expects.*Float.*Pattern/) } end end end diff --git a/spec/aliases/numeric_spec.rb b/spec/aliases/numeric_spec.rb index bc17f4f..09c28ec 100644 --- a/spec/aliases/numeric_spec.rb +++ b/spec/aliases/numeric_spec.rb @@ -24,7 +24,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x' ].each do |value| describe value.inspect do let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Numeric, Pattern(\[.*\]+)?, or Array/) } + it { is_expected.to compile.and_raise_error(/parameter 'value' expects.*Numeric.*Pattern.*Array/) } end end end diff --git a/spec/aliases/string_spec.rb b/spec/aliases/string_spec.rb index 3ea1967..4fc8ce6 100644 --- a/spec/aliases/string_spec.rb +++ b/spec/aliases/string_spec.rb @@ -24,7 +24,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 ].each do |value| describe value.inspect do let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a (?:value of type Undef or )?String/) } + it { is_expected.to compile.and_raise_error(/parameter 'value' expects a (?:value of type Undef or )?.*String/) } end end end diff --git a/spec/functions/deep_merge_spec.rb b/spec/functions/deep_merge_spec.rb index c91a07e..819e025 100755 --- a/spec/functions/deep_merge_spec.rb +++ b/spec/functions/deep_merge_spec.rb @@ -4,7 +4,7 @@ describe 'deep_merge' do it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } it { is_expected.to run.with_params({ 'key' => 'value' }).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } it { is_expected.to run.with_params({}, '2').and_raise_error(Puppet::ParseError, /unexpected argument type String/) } - it { is_expected.to run.with_params({}, 2).and_raise_error(Puppet::ParseError, /unexpected argument type Fixnum/) } + it { is_expected.to run.with_params({}, 2).and_raise_error(Puppet::ParseError, /unexpected argument/) } it { is_expected.to run.with_params({}, '').and_return({}) } it { is_expected.to run.with_params({}, {}).and_return({}) } it { is_expected.to run.with_params({}, {}, {}).and_return({}) } diff --git a/spec/functions/strftime_spec.rb b/spec/functions/strftime_spec.rb index e76774a..41cda6a 100755 --- a/spec/functions/strftime_spec.rb +++ b/spec/functions/strftime_spec.rb @@ -14,9 +14,9 @@ describe 'strftime' do expect(result.to_i).to(be > 1311953157) end - it "using %s should be lower then 1.5 trillion" do + it "using %s should be greater than 1.5 trillion" do result = scope.function_strftime(["%s"]) - expect(result.to_i).to(be < 1500000000) + expect(result.to_i).to(be > 1500000000) end it "should return a date when given %Y-%m-%d" do diff --git a/spec/functions/unique_spec.rb b/spec/functions/unique_spec.rb index 7955acb..76932ec 100755 --- a/spec/functions/unique_spec.rb +++ b/spec/functions/unique_spec.rb @@ -1,29 +1,31 @@ require 'spec_helper' describe 'unique' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - end + if Puppet.version.to_f < 5.0 + describe 'signature validation' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { + pending("Current implementation ignores parameters after the first.") + is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) + } + it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } + it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } + end - context 'when called with an array' do - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) } - it { is_expected.to run.with_params(['ã', 'ъ', 'ã']).and_return(['ã', 'ъ']) } - end + context 'when called with an array' do + it { is_expected.to run.with_params([]).and_return([]) } + it { is_expected.to run.with_params(['a']).and_return(['a']) } + it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) } + it { is_expected.to run.with_params(['ã', 'ъ', 'ã']).and_return(['ã', 'ъ']) } + end - context 'when called with a string' do - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('aaba').and_return('ab') } - it { is_expected.to run.with_params('ããъã').and_return('ãъ') } + context 'when called with a string' do + it { is_expected.to run.with_params('').and_return('') } + it { is_expected.to run.with_params('a').and_return('a') } + it { is_expected.to run.with_params('aaba').and_return('ab') } + it { is_expected.to run.with_params('ããъã').and_return('ãъ') } + end end end -- cgit v1.2.3 From 42d4ea7af9197f77a3062727eb166c719ca6296a Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Fri, 7 Jul 2017 17:30:17 -0700 Subject: (MODULES-4908) adds support for sensitive data type to pw_hash Also includes a small fix to integer_spec so tests pass. --- spec/aliases/integer_spec.rb | 2 +- spec/functions/pw_hash_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/aliases/integer_spec.rb b/spec/aliases/integer_spec.rb index aec9fd6..9cf0357 100644 --- a/spec/aliases/integer_spec.rb +++ b/spec/aliases/integer_spec.rb @@ -22,7 +22,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 [ "foo\nbar", true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3.7, '3.7',-3.7, '-342.2315e-12' ].each do |value| describe value.inspect do let(:params) {{ value: value }} - if Gem::Version.new(Puppet.version) >= Gem::Version.new('5.0.0') + if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 it { is_expected.to compile.and_raise_error(/parameter 'value' expects a Stdlib::Compat::Integer = Variant\[Integer, Pattern\[.*\], Array\[.*\]\] value/) } else it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Integer, Pattern(\[.*\]+)?, or Array/) } diff --git a/spec/functions/pw_hash_spec.rb b/spec/functions/pw_hash_spec.rb index df5348c..9e03464 100644 --- a/spec/functions/pw_hash_spec.rb +++ b/spec/functions/pw_hash_spec.rb @@ -65,5 +65,13 @@ describe 'pw_hash' do it { is_expected.to run.with_params('password', 'sha-256', 'salt').and_return('$5$salt$Gcm6FsVtF/Qa77ZKD.iwsJlCVPY0XSMgLJL0Hnww/c1') } it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_return('$6$salt$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy.g.') } end + + if Puppet::Util::Package.versioncmp(Puppet.version, '4.7.0') >= 0 + describe 'when arguments are sensitive' do + it { is_expected.to run.with_params(Puppet::Pops::Types::PSensitiveType::Sensitive.new('password'), 'md5', 'salt').and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') } + it { is_expected.to run.with_params(Puppet::Pops::Types::PSensitiveType::Sensitive.new('password'), 'md5', Puppet::Pops::Types::PSensitiveType::Sensitive.new('salt')).and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') } + it { is_expected.to run.with_params('password', 'md5', Puppet::Pops::Types::PSensitiveType::Sensitive.new('salt')).and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') } + end + end end end -- cgit v1.2.3 From 703fa777e1daee97e2aea529064d773662ef1fe0 Mon Sep 17 00:00:00 2001 From: "asif.shaikh" Date: Wed, 1 Feb 2017 20:14:27 -0800 Subject: Add new file_line option append_on_no_match --- spec/unit/puppet/provider/file_line/ruby_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'spec') diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb index ab6edf9..dcca4a4 100755 --- a/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb @@ -194,6 +194,24 @@ describe provider_class, :unless => Puppet::Util::Platform.windows? do @provider.create expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") end + + it 'should not add line after no matches found' do + @resource = Puppet::Type::File_line.new( + { + :name => 'foo', + :path => @tmpfile, + :line => 'inserted = line', + :match => '^foo3$', + :append_on_no_match => false, + } + ) + @provider = provider_class.new(@resource) + File.open(@tmpfile, 'w') do |fh| + fh.write("foo1\nfoo = blah\nfoo2\nfoo = baz") + end + expect(@provider.exists?).to be true + expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = blah\nfoo2\nfoo = baz") + end end describe 'using after' do -- cgit v1.2.3 From 39ea2c0bc49d812f41dcbbed6635e25607f80970 Mon Sep 17 00:00:00 2001 From: Nick Walker Date: Tue, 28 Mar 2017 13:16:26 -0700 Subject: Add a round function to complement ceiling and floor --- spec/functions/round_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 spec/functions/round_spec.rb (limited to 'spec') diff --git a/spec/functions/round_spec.rb b/spec/functions/round_spec.rb new file mode 100755 index 0000000..5aa801c --- /dev/null +++ b/spec/functions/round_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe 'stdlib::round' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params(34.3).and_return(34) } + it { is_expected.to run.with_params(-34.3).and_return(-34) } + it { is_expected.to run.with_params(34.5).and_return(35) } + it { is_expected.to run.with_params(-34.5).and_return(-35) } + it { is_expected.to run.with_params(34.7).and_return(35) } + it { is_expected.to run.with_params(-34.7).and_return(-35) } +end -- cgit v1.2.3 From 772a2d2f406b65ef65161a04455865b37a1c8456 Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Thu, 27 Jul 2017 09:24:52 -0700 Subject: (maint) move/rewrite round() as ruby function --- spec/functions/round_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/functions/round_spec.rb b/spec/functions/round_spec.rb index 5aa801c..8b13478 100755 --- a/spec/functions/round_spec.rb +++ b/spec/functions/round_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'stdlib::round' do +describe 'round' do it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params(34.3).and_return(34) } it { is_expected.to run.with_params(-34.3).and_return(-34) } @@ -8,4 +8,7 @@ describe 'stdlib::round' do it { is_expected.to run.with_params(-34.5).and_return(-35) } it { is_expected.to run.with_params(34.7).and_return(35) } it { is_expected.to run.with_params(-34.7).and_return(-35) } + it { is_expected.to run.with_params("test").and_raise_error Puppet::ParseError } + it { is_expected.to run.with_params("test", "best").and_raise_error Puppet::ParseError } + it { is_expected.to run.with_params(3, 4).and_raise_error Puppet::ParseError } end -- cgit v1.2.3 From bd324f9d86a79eb3a7a1a781c82eede8a4a447b8 Mon Sep 17 00:00:00 2001 From: WhatsARanjit Date: Fri, 25 Aug 2017 01:11:35 +0000 Subject: Added to_json function with tests and README --- spec/functions/to_json_pretty_spec.rb | 11 +++++++++++ spec/functions/to_json_spec.rb | 19 +++++++++++++++++++ spec/functions/to_yaml_spec.rb | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100755 spec/functions/to_json_pretty_spec.rb create mode 100755 spec/functions/to_json_spec.rb create mode 100755 spec/functions/to_yaml_spec.rb (limited to 'spec') diff --git a/spec/functions/to_json_pretty_spec.rb b/spec/functions/to_json_pretty_spec.rb new file mode 100755 index 0000000..abbcc2c --- /dev/null +++ b/spec/functions/to_json_pretty_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe 'to_json_pretty' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params([]).and_return("[\n\n]") } + it { is_expected.to run.with_params(['one']).and_return("[\n \"one\"\n]") } + it { is_expected.to run.with_params(['one', 'two']).and_return("[\n \"one\",\n \"two\"\n]") } + it { is_expected.to run.with_params({}).and_return("{\n}") } + it { is_expected.to run.with_params({ 'key' => 'value' }).and_return("{\n \"key\": \"value\"\n}") } + it { is_expected.to run.with_params({"one" => {"oneA" => "A","oneB" => {"oneB1" => "1","oneB2" => "2"}},"two" => ["twoA","twoB"]}).and_return("{\n \"one\": {\n \"oneA\": \"A\",\n \"oneB\": {\n \"oneB1\": \"1\",\n \"oneB2\": \"2\"\n }\n },\n \"two\": [\n \"twoA\",\n \"twoB\"\n ]\n}") } +end diff --git a/spec/functions/to_json_spec.rb b/spec/functions/to_json_spec.rb new file mode 100755 index 0000000..925523c --- /dev/null +++ b/spec/functions/to_json_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe 'to_json' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params('').and_return("\"\"") } + it { is_expected.to run.with_params(true).and_return("true") } + it { is_expected.to run.with_params('one').and_return("\"one\"") } + it { is_expected.to run.with_params([]).and_return("[]") } + it { is_expected.to run.with_params(['one']).and_return("[\"one\"]") } + it { is_expected.to run.with_params(['one', 'two']).and_return("[\"one\",\"two\"]") } + it { is_expected.to run.with_params({}).and_return("{}") } + it { is_expected.to run.with_params({ 'key' => 'value' }).and_return("{\"key\":\"value\"}") } + it { is_expected.to run.with_params({"one" => {"oneA" => "A","oneB" => {"oneB1" => "1","oneB2" => "2"}},"two" => ["twoA","twoB"]}).and_return("{\"one\":{\"oneA\":\"A\",\"oneB\":{\"oneB1\":\"1\",\"oneB2\":\"2\"}},\"two\":[\"twoA\",\"twoB\"]}") } + + it { is_expected.to run.with_params('‰').and_return('"‰"') } + it { is_expected.to run.with_params('竹').and_return('"竹"') } + it { is_expected.to run.with_params('Ü').and_return('"Ü"') } + it { is_expected.to run.with_params('∇').and_return('"∇"') } +end diff --git a/spec/functions/to_yaml_spec.rb b/spec/functions/to_yaml_spec.rb new file mode 100755 index 0000000..3f69a70 --- /dev/null +++ b/spec/functions/to_yaml_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'to_yaml' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params('').and_return("--- ''\n") } + it { is_expected.to run.with_params(true).and_return("--- true\n...\n") } + it { is_expected.to run.with_params('one').and_return("--- one\n...\n") } + it { is_expected.to run.with_params([]).and_return("--- []\n") } + it { is_expected.to run.with_params(['one']).and_return("---\n- one\n") } + it { is_expected.to run.with_params(['one', 'two']).and_return("---\n- one\n- two\n") } + it { is_expected.to run.with_params({}).and_return("--- {}\n") } + it { is_expected.to run.with_params({ 'key' => 'value' }).and_return("---\nkey: value\n") } + it { is_expected.to run.with_params({"one" => {"oneA" => "A","oneB" => {"oneB1" => "1","oneB2" => "2"}},"two" => ["twoA","twoB"]}).and_return("---\none:\n oneA: A\n oneB:\n oneB1: '1'\n oneB2: '2'\ntwo:\n- twoA\n- twoB\n") } + + it { is_expected.to run.with_params('‰').and_return("--- \"‰\"\n") } + it { is_expected.to run.with_params('∇').and_return("--- \"∇\"\n") } +end -- cgit v1.2.3 From d6985693edd80383aec75cd5d5dc77c193fd658e Mon Sep 17 00:00:00 2001 From: tphoney Date: Mon, 25 Sep 2017 10:59:58 +0100 Subject: removing duplicate test absolute_path test --- spec/aliases/absolutepath_spec.rb | 50 --------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 spec/aliases/absolutepath_spec.rb (limited to 'spec') diff --git a/spec/aliases/absolutepath_spec.rb b/spec/aliases/absolutepath_spec.rb deleted file mode 100644 index ff23dc0..0000000 --- a/spec/aliases/absolutepath_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'test::absolutepath', type: :class do - describe 'valid handling' do - %w{ - /usr2/username/bin:/usr/local/bin:/usr/bin:. - C:/ - C:\\ - C:\\WINDOWS\\System32 - C:/windows/system32 - X:/foo/bar - X:\\foo\\bar - \\\\host\\windows - //host/windows - /var/tmp - /var/opt/../lib/puppet - /var/opt//lib/puppet - }.each do |value| - describe value.inspect do - let(:params) {{ value: value }} - it { is_expected.to compile } - end - end - end - - describe 'invalid path handling' do - context 'garbage inputs' do - [ - nil, - [ nil ], - [ nil, nil ], - { 'foo' => 'bar' }, - { }, - '', - "*/Users//nope", - "\\Users/hc/wksp/stdlib", - "C:noslashes", - "\\var\\tmp" - ].each do |value| - describe value.inspect do - let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for.*Variant/) } - end - end - end - - end - end -end -- cgit v1.2.3 From ad5d92461596d8d0b1c001d49061d70b36761d59 Mon Sep 17 00:00:00 2001 From: Alex Harvey Date: Fri, 29 Sep 2017 16:14:37 +1000 Subject: (maint) Clarify docs and add new tests Based on a Stack Overflow question, it was noted that the documentation for `file_line` isn't complete and the underlying behaviour somewhat confusing. https://stackoverflow.com/questions/46468922/how-to-change-the-contents-of-a-file-by-using-puppet/46473458 In this patch I add additional unit tests and better examples and complete documentation. --- spec/unit/puppet/provider/file_line/ruby_spec.rb | 91 +++++++++++++++++++++++- spec/unit/puppet/type/file_line_spec.rb | 3 + 2 files changed, 92 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb index dcca4a4..4ec9bae 100755 --- a/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb @@ -337,7 +337,7 @@ describe provider_class, :unless => Puppet::Util::Platform.windows? do end end - context "when removing" do + context "when removing with a line" do before :each do # TODO: these should be ported over to use the PuppetLabs spec_helper # file fixtures once the following pull request has been merged: @@ -378,6 +378,23 @@ describe provider_class, :unless => Puppet::Util::Platform.windows? do @provider.destroy expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n") end + + it 'example in the docs' do + @resource = Puppet::Type::File_line.new( + { + :name => 'bashrc_proxy', + :ensure => 'absent', + :path => @tmpfile, + :line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', + } + ) + @provider = provider_class.new(@resource) + File.open(@tmpfile, 'w') do |fh| + fh.write("foo1\nfoo2\nexport HTTP_PROXY=http://squid.puppetlabs.vm:3128\nfoo4\n") + end + @provider.destroy + expect(File.read(@tmpfile)).to eql("foo1\nfoo2\nfoo4\n") + end end context "when removing with a match" do @@ -416,6 +433,41 @@ describe provider_class, :unless => Puppet::Util::Platform.windows? do expect(File.read(@tmpfile)).to eql("foo1\nfoo2") end + it 'the line parameter is actually not used at all but is silently ignored if here' do + @resource = Puppet::Type::File_line.new( + { + :name => 'foo', + :path => @tmpfile, + :line => 'supercalifragilisticexpialidocious', + :ensure => 'absent', + :match => 'o$', + :match_for_absence => true, + } + ) + File.open(@tmpfile, 'w') do |fh| + fh.write("foo1\nfoo\nfoo2") + end + @provider.destroy + expect(File.read(@tmpfile)).to eql("foo1\nfoo2") + end + + it 'and may not be here and does not need to be here' do + @resource = Puppet::Type::File_line.new( + { + :name => 'foo', + :path => @tmpfile, + :ensure => 'absent', + :match => 'o$', + :match_for_absence => true, + } + ) + File.open(@tmpfile, 'w') do |fh| + fh.write("foo1\nfoo\nfoo2") + end + @provider.destroy + expect(File.read(@tmpfile)).to eql("foo1\nfoo2") + end + it 'should raise an error if more than one line matches' do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo\nfoo2\nfoo\nfoo") @@ -480,6 +532,41 @@ describe provider_class, :unless => Puppet::Util::Platform.windows? do expect(File.read(@tmpfile)).to eql("foo1\nfoo\n") end - end + it 'example in the docs' do + @resource = Puppet::Type::File_line.new( + { + :name => 'bashrc_proxy', + :ensure => 'absent', + :path => @tmpfile, + :line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', + :match => '^export\ HTTP_PROXY\=', + :match_for_absence => true, + } + ) + @provider = provider_class.new(@resource) + File.open(@tmpfile, 'w') do |fh| + fh.write("foo1\nfoo2\nexport HTTP_PROXY=foo\nfoo4\n") + end + @provider.destroy + expect(File.read(@tmpfile)).to eql("foo1\nfoo2\nfoo4\n") + end + it 'example in the docs showing line is redundant' do + @resource = Puppet::Type::File_line.new( + { + :name => 'bashrc_proxy', + :ensure => 'absent', + :path => @tmpfile, + :match => '^export\ HTTP_PROXY\=', + :match_for_absence => true, + } + ) + @provider = provider_class.new(@resource) + File.open(@tmpfile, 'w') do |fh| + fh.write("foo1\nfoo2\nexport HTTP_PROXY=foo\nfoo4\n") + end + @provider.destroy + expect(File.read(@tmpfile)).to eql("foo1\nfoo2\nfoo4\n") + end + end end diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index 150149b..db07352 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -78,6 +78,9 @@ describe Puppet::Type.type(:file_line) do it 'should not require that a line is specified when matching for absence' do expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error end + it 'although if a line is specified anyway when matching for absence it still works and the line is silently ignored' do + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :line => 'i_am_irrelevant', :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error + end it 'should require that a file is specified' do expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, /path is a required attribute/) end -- cgit v1.2.3