diff options
author | Morgan Haskel <morgan@puppetlabs.com> | 2014-06-05 16:16:34 -0400 |
---|---|---|
committer | Morgan Haskel <morgan@puppetlabs.com> | 2014-06-05 16:16:34 -0400 |
commit | ffe21fc67491c4502114505c82142781d72720ab (patch) | |
tree | 7f0ee09079863a19f07e0bb999e387eedb32e17e | |
parent | f9f6e92dffa8364cfbbd92a6a65f4be4ef176d2c (diff) | |
parent | 6287a200af558d277f83b919e8409f6c798eef39 (diff) | |
download | puppet-stdlib-ffe21fc67491c4502114505c82142781d72720ab.tar.gz puppet-stdlib-ffe21fc67491c4502114505c82142781d72720ab.tar.bz2 |
Merge pull request #268 from apenney/rspec3
Rspec3 changes
92 files changed, 510 insertions, 510 deletions
diff --git a/spec/functions/abs_spec.rb b/spec/functions/abs_spec.rb index c0b4297..3c25ce2 100755 --- a/spec/functions/abs_spec.rb +++ b/spec/functions/abs_spec.rb @@ -6,20 +6,20 @@ describe "the abs function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("abs").should == "function_abs" + expect(Puppet::Parser::Functions.function("abs")).to eq("function_abs") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_abs([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_abs([]) }.to( raise_error(Puppet::ParseError)) end it "should convert a negative number into a positive" do result = scope.function_abs(["-34"]) - result.should(eq(34)) + expect(result).to(eq(34)) end it "should do nothing with a positive number" do result = scope.function_abs(["5678"]) - result.should(eq(5678)) + expect(result).to(eq(5678)) end end diff --git a/spec/functions/any2array_spec.rb b/spec/functions/any2array_spec.rb index b266e84..87cd04b 100755 --- a/spec/functions/any2array_spec.rb +++ b/spec/functions/any2array_spec.rb @@ -5,51 +5,51 @@ describe "the any2array function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("any2array").should == "function_any2array" + expect(Puppet::Parser::Functions.function("any2array")).to eq("function_any2array") end it "should return an empty array if there is less than 1 argument" do result = scope.function_any2array([]) - result.should(eq([])) + expect(result).to(eq([])) end it "should convert boolean true to [ true ] " do result = scope.function_any2array([true]) - result.should(eq([true])) + expect(result).to(eq([true])) end it "should convert one object to [object]" do result = scope.function_any2array(['one']) - result.should(eq(['one'])) + expect(result).to(eq(['one'])) end it "should convert multiple objects to [objects]" do result = scope.function_any2array(['one', 'two']) - result.should(eq(['one', 'two'])) + expect(result).to(eq(['one', 'two'])) end it "should return empty array it was called with" do result = scope.function_any2array([[]]) - result.should(eq([])) + expect(result).to(eq([])) end it "should return one-member array it was called with" do result = scope.function_any2array([['string']]) - result.should(eq(['string'])) + expect(result).to(eq(['string'])) end it "should return multi-member array it was called with" do result = scope.function_any2array([['one', 'two']]) - result.should(eq(['one', 'two'])) + expect(result).to(eq(['one', 'two'])) end it "should return members of a hash it was called with" do result = scope.function_any2array([{ 'key' => 'value' }]) - result.should(eq(['key', 'value'])) + expect(result).to(eq(['key', 'value'])) end it "should return an empty array if it was called with an empty hash" do result = scope.function_any2array([{ }]) - result.should(eq([])) + expect(result).to(eq([])) end end diff --git a/spec/functions/base64_spec.rb b/spec/functions/base64_spec.rb index 5faa5e6..e93fafc 100755 --- a/spec/functions/base64_spec.rb +++ b/spec/functions/base64_spec.rb @@ -6,7 +6,7 @@ describe "the base64 function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("base64").should == "function_base64" + expect(Puppet::Parser::Functions.function("base64")).to eq("function_base64") end it "should raise a ParseError if there are other than 2 arguments" do @@ -25,10 +25,10 @@ describe "the base64 function" do it "should encode a encoded string" do result = scope.function_base64(["encode",'thestring']) - result.should =~ /\AdGhlc3RyaW5n\n\Z/ + expect(result).to match(/\AdGhlc3RyaW5n\n\Z/) end it "should decode a base64 encoded string" do result = scope.function_base64(["decode",'dGhlc3RyaW5n']) - result.should == 'thestring' + expect(result).to eq('thestring') end end diff --git a/spec/functions/bool2num_spec.rb b/spec/functions/bool2num_spec.rb index 518ac85..fbf461b 100755 --- a/spec/functions/bool2num_spec.rb +++ b/spec/functions/bool2num_spec.rb @@ -5,20 +5,20 @@ describe "the bool2num function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("bool2num").should == "function_bool2num" + expect(Puppet::Parser::Functions.function("bool2num")).to eq("function_bool2num") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_bool2num([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_bool2num([]) }.to( raise_error(Puppet::ParseError)) end it "should convert true to 1" do result = scope.function_bool2num([true]) - result.should(eq(1)) + expect(result).to(eq(1)) end it "should convert false to 0" do result = scope.function_bool2num([false]) - result.should(eq(0)) + expect(result).to(eq(0)) end end diff --git a/spec/functions/capitalize_spec.rb b/spec/functions/capitalize_spec.rb index 69c9758..0cc2d76 100755 --- a/spec/functions/capitalize_spec.rb +++ b/spec/functions/capitalize_spec.rb @@ -5,15 +5,15 @@ describe "the capitalize function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("capitalize").should == "function_capitalize" + expect(Puppet::Parser::Functions.function("capitalize")).to eq("function_capitalize") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_capitalize([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_capitalize([]) }.to( raise_error(Puppet::ParseError)) end it "should capitalize the beginning of a string" do result = scope.function_capitalize(["abc"]) - result.should(eq("Abc")) + expect(result).to(eq("Abc")) end end diff --git a/spec/functions/chomp_spec.rb b/spec/functions/chomp_spec.rb index e425365..d2ae287 100755 --- a/spec/functions/chomp_spec.rb +++ b/spec/functions/chomp_spec.rb @@ -5,15 +5,15 @@ describe "the chomp function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("chomp").should == "function_chomp" + expect(Puppet::Parser::Functions.function("chomp")).to eq("function_chomp") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_chomp([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_chomp([]) }.to( raise_error(Puppet::ParseError)) end it "should chomp the end of a string" do result = scope.function_chomp(["abc\n"]) - result.should(eq("abc")) + expect(result).to(eq("abc")) end end diff --git a/spec/functions/chop_spec.rb b/spec/functions/chop_spec.rb index 9e466de..d9dbb88 100755 --- a/spec/functions/chop_spec.rb +++ b/spec/functions/chop_spec.rb @@ -5,15 +5,15 @@ describe "the chop function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("chop").should == "function_chop" + expect(Puppet::Parser::Functions.function("chop")).to eq("function_chop") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_chop([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_chop([]) }.to( raise_error(Puppet::ParseError)) end it "should chop the end of a string" do result = scope.function_chop(["asdf\n"]) - result.should(eq("asdf")) + expect(result).to(eq("asdf")) end end diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb index 6e67620..b853b4c 100755 --- a/spec/functions/concat_spec.rb +++ b/spec/functions/concat_spec.rb @@ -5,26 +5,26 @@ describe "the concat function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should raise a ParseError if the client does not provide two arguments" do - lambda { scope.function_concat([]) }.should(raise_error(Puppet::ParseError)) + expect { scope.function_concat([]) }.to(raise_error(Puppet::ParseError)) end it "should raise a ParseError if the first parameter is not an array" do - lambda { scope.function_concat([1, []])}.should(raise_error(Puppet::ParseError)) + expect { scope.function_concat([1, []])}.to(raise_error(Puppet::ParseError)) end it "should be able to concat an array" do result = scope.function_concat([['1','2','3'],['4','5','6']]) - result.should(eq(['1','2','3','4','5','6'])) + expect(result).to(eq(['1','2','3','4','5','6'])) end it "should be able to concat a primitive to an array" do result = scope.function_concat([['1','2','3'],'4']) - result.should(eq(['1','2','3','4'])) + expect(result).to(eq(['1','2','3','4'])) end it "should not accidentally flatten nested arrays" do result = scope.function_concat([['1','2','3'],[['4','5'],'6']]) - result.should(eq(['1','2','3',['4','5'],'6'])) + expect(result).to(eq(['1','2','3',['4','5'],'6'])) end end diff --git a/spec/functions/count_spec.rb b/spec/functions/count_spec.rb index 2453815..f8f1d48 100755 --- a/spec/functions/count_spec.rb +++ b/spec/functions/count_spec.rb @@ -6,23 +6,23 @@ describe "the count function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("count").should == "function_count" + expect(Puppet::Parser::Functions.function("count")).to eq("function_count") end it "should raise a ArgumentError if there is more than 2 arguments" do - lambda { scope.function_count(['foo', 'bar', 'baz']) }.should( raise_error(ArgumentError)) + expect { scope.function_count(['foo', 'bar', 'baz']) }.to( raise_error(ArgumentError)) end it "should be able to count arrays" do - scope.function_count([["1","2","3"]]).should(eq(3)) + expect(scope.function_count([["1","2","3"]])).to(eq(3)) end it "should be able to count matching elements in arrays" do - scope.function_count([["1", "2", "2"], "2"]).should(eq(2)) + expect(scope.function_count([["1", "2", "2"], "2"])).to(eq(2)) end it "should not count nil or empty strings" do - scope.function_count([["foo","bar",nil,""]]).should(eq(2)) + expect(scope.function_count([["foo","bar",nil,""]])).to(eq(2)) end it 'does not count an undefined hash key or an out of bound array index (which are both :undef)' do diff --git a/spec/functions/deep_merge_spec.rb b/spec/functions/deep_merge_spec.rb index f134701..7087904 100755 --- a/spec/functions/deep_merge_spec.rb +++ b/spec/functions/deep_merge_spec.rb @@ -7,7 +7,7 @@ describe Puppet::Parser::Functions.function(:deep_merge) do describe 'when calling deep_merge from puppet' do it "should not compile when no arguments are passed" do - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ Puppet[:code] = '$x = deep_merge()' expect { scope.compiler.compile @@ -15,7 +15,7 @@ describe Puppet::Parser::Functions.function(:deep_merge) do end it "should not compile when 1 argument is passed" do - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ Puppet[:code] = "$my_hash={'one' => 1}\n$x = deep_merge($my_hash)" expect { scope.compiler.compile @@ -35,71 +35,71 @@ describe Puppet::Parser::Functions.function(:deep_merge) do it 'should be able to deep_merge two hashes' do new_hash = scope.function_deep_merge([{'one' => '1', 'two' => '1'}, {'two' => '2', 'three' => '2'}]) - new_hash['one'].should == '1' - new_hash['two'].should == '2' - new_hash['three'].should == '2' + expect(new_hash['one']).to eq('1') + expect(new_hash['two']).to eq('2') + expect(new_hash['three']).to eq('2') end it 'should deep_merge multiple hashes' do hash = scope.function_deep_merge([{'one' => 1}, {'one' => '2'}, {'one' => '3'}]) - hash['one'].should == '3' + expect(hash['one']).to eq('3') end it 'should accept empty hashes' do - scope.function_deep_merge([{},{},{}]).should == {} + expect(scope.function_deep_merge([{},{},{}])).to eq({}) end it 'should deep_merge subhashes' do hash = scope.function_deep_merge([{'one' => 1}, {'two' => 2, 'three' => { 'four' => 4 } }]) - hash['one'].should == 1 - hash['two'].should == 2 - hash['three'].should == { 'four' => 4 } + expect(hash['one']).to eq(1) + expect(hash['two']).to eq(2) + expect(hash['three']).to eq({ 'four' => 4 }) end it 'should append to subhashes' do hash = scope.function_deep_merge([{'one' => { 'two' => 2 } }, { 'one' => { 'three' => 3 } }]) - hash['one'].should == { 'two' => 2, 'three' => 3 } + expect(hash['one']).to eq({ 'two' => 2, 'three' => 3 }) end it 'should append to subhashes 2' do hash = scope.function_deep_merge([{'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }, {'two' => 'dos', 'three' => { 'five' => 5 } }]) - hash['one'].should == 1 - hash['two'].should == 'dos' - hash['three'].should == { 'four' => 4, 'five' => 5 } + expect(hash['one']).to eq(1) + expect(hash['two']).to eq('dos') + expect(hash['three']).to eq({ 'four' => 4, 'five' => 5 }) end it 'should append to subhashes 3' do hash = scope.function_deep_merge([{ 'key1' => { 'a' => 1, 'b' => 2 }, 'key2' => { 'c' => 3 } }, { 'key1' => { 'b' => 99 } }]) - hash['key1'].should == { 'a' => 1, 'b' => 99 } - hash['key2'].should == { 'c' => 3 } + expect(hash['key1']).to eq({ 'a' => 1, 'b' => 99 }) + expect(hash['key2']).to eq({ 'c' => 3 }) end it 'should not change the original hashes' do hash1 = {'one' => { 'two' => 2 } } hash2 = { 'one' => { 'three' => 3 } } hash = scope.function_deep_merge([hash1, hash2]) - hash1.should == {'one' => { 'two' => 2 } } - hash2.should == { 'one' => { 'three' => 3 } } - hash['one'].should == { 'two' => 2, 'three' => 3 } + expect(hash1).to eq({'one' => { 'two' => 2 } }) + expect(hash2).to eq({ 'one' => { 'three' => 3 } }) + expect(hash['one']).to eq({ 'two' => 2, 'three' => 3 }) end it 'should not change the original hashes 2' do hash1 = {'one' => { 'two' => [1,2] } } hash2 = { 'one' => { 'three' => 3 } } hash = scope.function_deep_merge([hash1, hash2]) - hash1.should == {'one' => { 'two' => [1,2] } } - hash2.should == { 'one' => { 'three' => 3 } } - hash['one'].should == { 'two' => [1,2], 'three' => 3 } + expect(hash1).to eq({'one' => { 'two' => [1,2] } }) + expect(hash2).to eq({ 'one' => { 'three' => 3 } }) + expect(hash['one']).to eq({ 'two' => [1,2], 'three' => 3 }) end it 'should not change the original hashes 3' do hash1 = {'one' => { 'two' => [1,2, {'two' => 2} ] } } hash2 = { 'one' => { 'three' => 3 } } hash = scope.function_deep_merge([hash1, hash2]) - hash1.should == {'one' => { 'two' => [1,2, {'two' => 2}] } } - hash2.should == { 'one' => { 'three' => 3 } } - hash['one'].should == { 'two' => [1,2, {'two' => 2} ], 'three' => 3 } - hash['one']['two'].should == [1,2, {'two' => 2}] + expect(hash1).to eq({'one' => { 'two' => [1,2, {'two' => 2}] } }) + expect(hash2).to eq({ 'one' => { 'three' => 3 } }) + expect(hash['one']).to eq({ 'two' => [1,2, {'two' => 2} ], 'three' => 3 }) + expect(hash['one']['two']).to eq([1,2, {'two' => 2}]) end end end diff --git a/spec/functions/defined_with_params_spec.rb b/spec/functions/defined_with_params_spec.rb index 28dbab3..3590304 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -4,16 +4,16 @@ require 'spec_helper' require 'rspec-puppet' describe 'defined_with_params' do describe 'when a resource is not specified' do - it { should run.with_params().and_raise_error(ArgumentError) } + it { is_expected.to run.with_params().and_raise_error(ArgumentError) } end describe 'when compared against a resource with no attributes' do let :pre_condition do 'user { "dan": }' end it do - should run.with_params('User[dan]', {}).and_return(true) - should run.with_params('User[bob]', {}).and_return(false) - should run.with_params('User[dan]', {'foo' => 'bar'}).and_return(false) + is_expected.to run.with_params('User[dan]', {}).and_return(true) + is_expected.to run.with_params('User[bob]', {}).and_return(false) + is_expected.to run.with_params('User[dan]', {'foo' => 'bar'}).and_return(false) end end @@ -22,14 +22,14 @@ describe 'defined_with_params' do 'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}' end it do - should run.with_params('User[dan]', {}).and_return(true) - should run.with_params('User[dan]', '').and_return(true) - should run.with_params('User[dan]', {'ensure' => 'present'} + is_expected.to run.with_params('User[dan]', {}).and_return(true) + is_expected.to run.with_params('User[dan]', '').and_return(true) + is_expected.to run.with_params('User[dan]', {'ensure' => 'present'} ).and_return(true) - should run.with_params('User[dan]', + is_expected.to run.with_params('User[dan]', {'ensure' => 'present', 'managehome' => false} ).and_return(true) - should run.with_params('User[dan]', + is_expected.to run.with_params('User[dan]', {'ensure' => 'absent', 'managehome' => false} ).and_return(false) end diff --git a/spec/functions/delete_at_spec.rb b/spec/functions/delete_at_spec.rb index 593cf45..7c20aec 100755 --- a/spec/functions/delete_at_spec.rb +++ b/spec/functions/delete_at_spec.rb @@ -5,21 +5,21 @@ describe "the delete_at function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("delete_at").should == "function_delete_at" + expect(Puppet::Parser::Functions.function("delete_at")).to eq("function_delete_at") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_delete_at([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_delete_at([]) }.to( raise_error(Puppet::ParseError)) end it "should delete an item at specified location from an array" do result = scope.function_delete_at([['a','b','c'],1]) - result.should(eq(['a','c'])) + expect(result).to(eq(['a','c'])) end it "should not change origin array passed as argument" do origin_array = ['a','b','c','d'] result = scope.function_delete_at([origin_array, 1]) - origin_array.should(eq(['a','b','c','d'])) + expect(origin_array).to(eq(['a','b','c','d'])) end end diff --git a/spec/functions/delete_spec.rb b/spec/functions/delete_spec.rb index 1508a63..39b3176 100755 --- a/spec/functions/delete_spec.rb +++ b/spec/functions/delete_spec.rb @@ -5,52 +5,52 @@ describe "the delete function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("delete").should == "function_delete" + expect(Puppet::Parser::Functions.function("delete")).to eq("function_delete") end it "should raise a ParseError if there are fewer than 2 arguments" do - lambda { scope.function_delete([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_delete([]) }.to( raise_error(Puppet::ParseError)) end it "should raise a ParseError if there are greater than 2 arguments" do - lambda { scope.function_delete([[], 'foo', 'bar']) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_delete([[], 'foo', 'bar']) }.to( raise_error(Puppet::ParseError)) end it "should raise a TypeError if a number is passed as the first argument" do - lambda { scope.function_delete([1, 'bar']) }.should( raise_error(TypeError)) + expect { scope.function_delete([1, 'bar']) }.to( raise_error(TypeError)) end it "should delete all instances of an element from an array" do result = scope.function_delete([['a','b','c','b'],'b']) - result.should(eq(['a','c'])) + expect(result).to(eq(['a','c'])) end it "should delete all instances of a substring from a string" do result = scope.function_delete(['foobarbabarz','bar']) - result.should(eq('foobaz')) + expect(result).to(eq('foobaz')) end it "should delete a key from a hash" do result = scope.function_delete([{ 'a' => 1, 'b' => 2, 'c' => 3 },'b']) - result.should(eq({ 'a' => 1, 'c' => 3 })) + expect(result).to(eq({ 'a' => 1, 'c' => 3 })) end it "should not change origin array passed as argument" do origin_array = ['a','b','c','d'] result = scope.function_delete([origin_array, 'b']) - origin_array.should(eq(['a','b','c','d'])) + expect(origin_array).to(eq(['a','b','c','d'])) end it "should not change the origin string passed as argument" do origin_string = 'foobarbabarz' result = scope.function_delete([origin_string,'bar']) - origin_string.should(eq('foobarbabarz')) + expect(origin_string).to(eq('foobarbabarz')) end it "should not change origin hash passed as argument" do origin_hash = { 'a' => 1, 'b' => 2, 'c' => 3 } result = scope.function_delete([origin_hash, 'b']) - origin_hash.should(eq({ 'a' => 1, 'b' => 2, 'c' => 3 })) + expect(origin_hash).to(eq({ 'a' => 1, 'b' => 2, 'c' => 3 })) end end diff --git a/spec/functions/delete_undef_values_spec.rb b/spec/functions/delete_undef_values_spec.rb index b341d88..dc67953 100755 --- a/spec/functions/delete_undef_values_spec.rb +++ b/spec/functions/delete_undef_values_spec.rb @@ -5,37 +5,37 @@ describe "the delete_undef_values function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("delete_undef_values").should == "function_delete_undef_values" + expect(Puppet::Parser::Functions.function("delete_undef_values")).to eq("function_delete_undef_values") end it "should raise a ParseError if there is less than 1 argument" do - lambda { scope.function_delete_undef_values([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_delete_undef_values([]) }.to( raise_error(Puppet::ParseError)) end it "should raise a ParseError if the argument is not Array nor Hash" do - lambda { scope.function_delete_undef_values(['']) }.should( raise_error(Puppet::ParseError)) - lambda { scope.function_delete_undef_values([nil]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_delete_undef_values(['']) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_delete_undef_values([nil]) }.to( raise_error(Puppet::ParseError)) end it "should delete all undef items from Array and only these" do result = scope.function_delete_undef_values([['a',:undef,'c','undef']]) - result.should(eq(['a','c','undef'])) + expect(result).to(eq(['a','c','undef'])) end it "should delete all undef items from Hash and only these" do result = scope.function_delete_undef_values([{'a'=>'A','b'=>:undef,'c'=>'C','d'=>'undef'}]) - result.should(eq({'a'=>'A','c'=>'C','d'=>'undef'})) + expect(result).to(eq({'a'=>'A','c'=>'C','d'=>'undef'})) end it "should not change origin array passed as argument" do origin_array = ['a',:undef,'c','undef'] result = scope.function_delete_undef_values([origin_array]) - origin_array.should(eq(['a',:undef,'c','undef'])) + expect(origin_array).to(eq(['a',:undef,'c','undef'])) end it "should not change origin hash passed as argument" do origin_hash = { 'a' => 1, 'b' => :undef, 'c' => 'undef' } result = scope.function_delete_undef_values([origin_hash]) - origin_hash.should(eq({ 'a' => 1, 'b' => :undef, 'c' => 'undef' })) + expect(origin_hash).to(eq({ 'a' => 1, 'b' => :undef, 'c' => 'undef' })) end end diff --git a/spec/functions/delete_values_spec.rb b/spec/functions/delete_values_spec.rb index 8d7f231..4f4d411 100755 --- a/spec/functions/delete_values_spec.rb +++ b/spec/functions/delete_values_spec.rb @@ -5,32 +5,32 @@ describe "the delete_values function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("delete_values").should == "function_delete_values" + expect(Puppet::Parser::Functions.function("delete_values")).to eq("function_delete_values") end it "should raise a ParseError if there are fewer than 2 arguments" do - lambda { scope.function_delete_values([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_delete_values([]) }.to( raise_error(Puppet::ParseError)) end it "should raise a ParseError if there are greater than 2 arguments" do - lambda { scope.function_delete_values([[], 'foo', 'bar']) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_delete_values([[], 'foo', 'bar']) }.to( raise_error(Puppet::ParseError)) end it "should raise a TypeError if the argument is not a hash" do - lambda { scope.function_delete_values([1,'bar']) }.should( raise_error(TypeError)) - lambda { scope.function_delete_values(['foo','bar']) }.should( raise_error(TypeError)) - lambda { scope.function_delete_values([[],'bar']) }.should( raise_error(TypeError)) + expect { scope.function_delete_values([1,'bar']) }.to( raise_error(TypeError)) + expect { scope.function_delete_values(['foo','bar']) }.to( raise_error(TypeError)) + expect { scope.function_delete_values([[],'bar']) }.to( raise_error(TypeError)) end it "should delete all instances of a value from a hash" do result = scope.function_delete_values([{ 'a'=>'A', 'b'=>'B', 'B'=>'C', 'd'=>'B' },'B']) - result.should(eq({ 'a'=>'A', 'B'=>'C' })) + expect(result).to(eq({ 'a'=>'A', 'B'=>'C' })) end it "should not change origin hash passed as argument" do origin_hash = { 'a' => 1, 'b' => 2, 'c' => 3 } result = scope.function_delete_values([origin_hash, 2]) - origin_hash.should(eq({ 'a' => 1, 'b' => 2, 'c' => 3 })) + expect(origin_hash).to(eq({ 'a' => 1, 'b' => 2, 'c' => 3 })) end end diff --git a/spec/functions/difference_spec.rb b/spec/functions/difference_spec.rb index 9feff09..24b2b1b 100755 --- a/spec/functions/difference_spec.rb +++ b/spec/functions/difference_spec.rb @@ -5,15 +5,15 @@ describe "the difference function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("difference").should == "function_difference" + expect(Puppet::Parser::Functions.function("difference")).to eq("function_difference") end it "should raise a ParseError if there are fewer than 2 arguments" do - lambda { scope.function_difference([]) }.should( raise_error(Puppet::ParseError) ) + expect { scope.function_difference([]) }.to( raise_error(Puppet::ParseError) ) end it "should return the difference between two arrays" do result = scope.function_difference([["a","b","c"],["b","c","d"]]) - result.should(eq(["a"])) + expect(result).to(eq(["a"])) end end diff --git a/spec/functions/dirname_spec.rb b/spec/functions/dirname_spec.rb index fb3b4fe..8a3bcab 100755 --- a/spec/functions/dirname_spec.rb +++ b/spec/functions/dirname_spec.rb @@ -5,20 +5,20 @@ describe "the dirname function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("dirname").should == "function_dirname" + expect(Puppet::Parser::Functions.function("dirname")).to eq("function_dirname") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_dirname([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_dirname([]) }.to( raise_error(Puppet::ParseError)) end it "should return dirname for an absolute path" do result = scope.function_dirname(['/path/to/a/file.ext']) - result.should(eq('/path/to/a')) + expect(result).to(eq('/path/to/a')) end it "should return dirname for a relative path" do result = scope.function_dirname(['path/to/a/file.ext']) - result.should(eq('path/to/a')) + expect(result).to(eq('path/to/a')) end end diff --git a/spec/functions/downcase_spec.rb b/spec/functions/downcase_spec.rb index acef1f0..a844780 100755 --- a/spec/functions/downcase_spec.rb +++ b/spec/functions/downcase_spec.rb @@ -5,20 +5,20 @@ describe "the downcase function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("downcase").should == "function_downcase" + expect(Puppet::Parser::Functions.function("downcase")).to eq("function_downcase") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_downcase([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_downcase([]) }.to( raise_error(Puppet::ParseError)) end it "should downcase a string" do result = scope.function_downcase(["ASFD"]) - result.should(eq("asfd")) + expect(result).to(eq("asfd")) end it "should do nothing to a string that is already downcase" do result = scope.function_downcase(["asdf asdf"]) - result.should(eq("asdf asdf")) + expect(result).to(eq("asdf asdf")) end end diff --git a/spec/functions/empty_spec.rb b/spec/functions/empty_spec.rb index 7745875..1f2ace4 100755 --- a/spec/functions/empty_spec.rb +++ b/spec/functions/empty_spec.rb @@ -4,20 +4,20 @@ require 'spec_helper' describe "the empty function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("empty").should == "function_empty" + expect(Puppet::Parser::Functions.function("empty")).to eq("function_empty") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_empty([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_empty([]) }.to( raise_error(Puppet::ParseError)) end it "should return a true for an empty string" do result = scope.function_empty(['']) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return a false for a non-empty string" do result = scope.function_empty(['asdf']) - result.should(eq(false)) + expect(result).to(eq(false)) end end diff --git a/spec/functions/flatten_spec.rb b/spec/functions/flatten_spec.rb index dba7a6b..de8c66d 100755 --- a/spec/functions/flatten_spec.rb +++ b/spec/functions/flatten_spec.rb @@ -4,24 +4,24 @@ require 'spec_helper' describe "the flatten function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("flatten").should == "function_flatten" + expect(Puppet::Parser::Functions.function("flatten")).to eq("function_flatten") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_flatten([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_flatten([]) }.to( raise_error(Puppet::ParseError)) end it "should raise a ParseError if there is more than 1 argument" do - lambda { scope.function_flatten([[], []]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_flatten([[], []]) }.to( raise_error(Puppet::ParseError)) end it "should flatten a complex data structure" do result = scope.function_flatten([["a","b",["c",["d","e"],"f","g"]]]) - result.should(eq(["a","b","c","d","e","f","g"])) + expect(result).to(eq(["a","b","c","d","e","f","g"])) end it "should do nothing to a structure that is already flat" do result = scope.function_flatten([["a","b","c","d"]]) - result.should(eq(["a","b","c","d"])) + expect(result).to(eq(["a","b","c","d"])) end end diff --git a/spec/functions/floor_spec.rb b/spec/functions/floor_spec.rb index dbc8c77..12a6917 100755 --- a/spec/functions/floor_spec.rb +++ b/spec/functions/floor_spec.rb @@ -6,34 +6,34 @@ describe "the floor function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("floor").should == "function_floor" + expect(Puppet::Parser::Functions.function("floor")).to eq("function_floor") end it "should raise a ParseError if there is less than 1 argument" do - lambda { scope.function_floor([]) }.should( raise_error(Puppet::ParseError, /Wrong number of arguments/)) + expect { scope.function_floor([]) }.to( raise_error(Puppet::ParseError, /Wrong number of arguments/)) end it "should should raise a ParseError if input isn't numeric (eg. String)" do - lambda { scope.function_floor(["foo"]) }.should( raise_error(Puppet::ParseError, /Wrong argument type/)) + expect { scope.function_floor(["foo"]) }.to( raise_error(Puppet::ParseError, /Wrong argument type/)) end it "should should raise a ParseError if input isn't numeric (eg. Boolean)" do - lambda { scope.function_floor([true]) }.should( raise_error(Puppet::ParseError, /Wrong argument type/)) + expect { scope.function_floor([true]) }.to( raise_error(Puppet::ParseError, /Wrong argument type/)) end it "should return an integer when a numeric type is passed" do result = scope.function_floor([12.4]) - result.is_a?(Integer).should(eq(true)) + expect(result.is_a?(Integer)).to(eq(true)) end it "should return the input when an integer is passed" do result = scope.function_floor([7]) - result.should(eq(7)) + expect(result).to(eq(7)) end it "should return the largest integer less than or equal to the input" do result = scope.function_floor([3.8]) - result.should(eq(3)) + expect(result).to(eq(3)) end end diff --git a/spec/functions/fqdn_rotate_spec.rb b/spec/functions/fqdn_rotate_spec.rb index 2577723..b2dc1f5 100755 --- a/spec/functions/fqdn_rotate_spec.rb +++ b/spec/functions/fqdn_rotate_spec.rb @@ -5,22 +5,22 @@ describe "the fqdn_rotate function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("fqdn_rotate").should == "function_fqdn_rotate" + expect(Puppet::Parser::Functions.function("fqdn_rotate")).to eq("function_fqdn_rotate") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_fqdn_rotate([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_fqdn_rotate([]) }.to( raise_error(Puppet::ParseError)) end it "should rotate a string and the result should be the same size" do scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1") result = scope.function_fqdn_rotate(["asdf"]) - result.size.should(eq(4)) + expect(result.size).to(eq(4)) end it "should rotate a string to give the same results for one host" do scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1").twice - scope.function_fqdn_rotate(["abcdefg"]).should eql(scope.function_fqdn_rotate(["abcdefg"])) + expect(scope.function_fqdn_rotate(["abcdefg"])).to eql(scope.function_fqdn_rotate(["abcdefg"])) end it "should rotate a string to give different values on different hosts" do @@ -28,6 +28,6 @@ describe "the fqdn_rotate function" do val1 = scope.function_fqdn_rotate(["abcdefghijklmnopqrstuvwxyz01234567890987654321"]) scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.2") val2 = scope.function_fqdn_rotate(["abcdefghijklmnopqrstuvwxyz01234567890987654321"]) - val1.should_not eql(val2) + expect(val1).not_to eql(val2) end end diff --git a/spec/functions/get_module_path_spec.rb b/spec/functions/get_module_path_spec.rb index 486bef6..38ce645 100755 --- a/spec/functions/get_module_path_spec.rb +++ b/spec/functions/get_module_path_spec.rb @@ -29,18 +29,18 @@ describe Puppet::Parser::Functions.function(:get_module_path) do it 'should be able to find module paths from the modulepath setting' do Puppet::Module.expects(:find).with('foo', 'production').returns(path_of_module_foo) - scope.function_get_module_path(['foo']).should == path_of_module_foo.path + expect(scope.function_get_module_path(['foo'])).to eq(path_of_module_foo.path) end it 'should be able to find module paths when the modulepath is a list' do Puppet[:modulepath] = modulepath + ":/tmp" Puppet::Module.expects(:find).with('foo', 'production').returns(path_of_module_foo) - scope.function_get_module_path(['foo']).should == path_of_module_foo.path + expect(scope.function_get_module_path(['foo'])).to eq(path_of_module_foo.path) end it 'should respect the environment' do - pending("Disabled on Puppet 2.6.x") if Puppet.version =~ /^2\.6\b/ + skip("Disabled on Puppet 2.6.x") if Puppet.version =~ /^2\.6\b/ Puppet.settings[:environment] = 'danstestenv' Puppet::Module.expects(:find).with('foo', 'danstestenv').returns(path_of_module_foo) - scope('danstestenv').function_get_module_path(['foo']).should == path_of_module_foo.path + expect(scope('danstestenv').function_get_module_path(['foo'])).to eq(path_of_module_foo.path) end end end diff --git a/spec/functions/getparam_spec.rb b/spec/functions/getparam_spec.rb index bf024af..833c4d4 100755 --- a/spec/functions/getparam_spec.rb +++ b/spec/functions/getparam_spec.rb @@ -25,7 +25,7 @@ describe 'getparam' do end it "should exist" do - Puppet::Parser::Functions.function("getparam").should == "function_getparam" + expect(Puppet::Parser::Functions.function("getparam")).to eq("function_getparam") end describe 'when a resource is not specified' do diff --git a/spec/functions/getvar_spec.rb b/spec/functions/getvar_spec.rb index 5ff834e..87ab9b5 100755 --- a/spec/functions/getvar_spec.rb +++ b/spec/functions/getvar_spec.rb @@ -6,7 +6,7 @@ describe Puppet::Parser::Functions.function(:getvar) do describe 'when calling getvar from puppet' do it "should not compile when no arguments are passed" do - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ Puppet[:code] = '$foo = getvar()' expect { scope.compiler.compile @@ -14,7 +14,7 @@ describe Puppet::Parser::Functions.function(:getvar) do end it "should not compile when too many arguments are passed" do - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ Puppet[:code] = '$foo = getvar("foo::bar", "baz")' expect { scope.compiler.compile @@ -22,7 +22,7 @@ describe Puppet::Parser::Functions.function(:getvar) do end it "should lookup variables in other namespaces" do - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ Puppet[:code] = <<-'ENDofPUPPETcode' class site::data { $foo = 'baz' } include site::data diff --git a/spec/functions/grep_spec.rb b/spec/functions/grep_spec.rb index a93b842..9c671dd 100755 --- a/spec/functions/grep_spec.rb +++ b/spec/functions/grep_spec.rb @@ -5,15 +5,15 @@ describe "the grep function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("grep").should == "function_grep" + expect(Puppet::Parser::Functions.function("grep")).to eq("function_grep") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_grep([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_grep([]) }.to( raise_error(Puppet::ParseError)) end it "should grep contents from an array" do result = scope.function_grep([["aaabbb","bbbccc","dddeee"], "bbb"]) - result.should(eq(["aaabbb","bbbccc"])) + expect(result).to(eq(["aaabbb","bbbccc"])) end end diff --git a/spec/functions/has_interface_with_spec.rb b/spec/functions/has_interface_with_spec.rb index c5264e4..23e09a9 100755 --- a/spec/functions/has_interface_with_spec.rb +++ b/spec/functions/has_interface_with_spec.rb @@ -20,10 +20,10 @@ describe Puppet::Parser::Functions.function(:has_interface_with) do scope.stubs(:lookupvar).with("interfaces").returns('lo0,gif0,stf0,en1,p2p0,fw0,en0,vmnet1,vmnet8,utun0') end it 'should have loopback (lo0)' do - subject.call(['lo0']).should be_true + expect(subject.call(['lo0'])).to be_truthy end it 'should not have loopback (lo)' do - subject.call(['lo']).should be_false + expect(subject.call(['lo'])).to be_falsey end end context "On Linux Systems" do @@ -37,28 +37,28 @@ describe Puppet::Parser::Functions.function(:has_interface_with) do scope.stubs(:lookupvar).with('muppet_eth0').returns('kermit') end it 'should have loopback (lo)' do - subject.call(['lo']).should be_true + expect(subject.call(['lo'])).to be_truthy end it 'should not have loopback (lo0)' do - subject.call(['lo0']).should be_false + expect(subject.call(['lo0'])).to be_falsey end it 'should have ipaddress with 127.0.0.1' do - subject.call(['ipaddress', '127.0.0.1']).should be_true + expect(subject.call(['ipaddress', '127.0.0.1'])).to be_truthy end it 'should have ipaddress with 10.0.0.1' do - subject.call(['ipaddress', '10.0.0.1']).should be_true + expect(subject.call(['ipaddress', '10.0.0.1'])).to be_truthy end it 'should not have ipaddress with 10.0.0.2' do - subject.call(['ipaddress', '10.0.0.2']).should be_false + expect(subject.call(['ipaddress', '10.0.0.2'])).to be_falsey end it 'should have muppet named kermit' do - subject.call(['muppet', 'kermit']).should be_true + expect(subject.call(['muppet', 'kermit'])).to be_truthy end it 'should have muppet named mspiggy' do - subject.call(['muppet', 'mspiggy']).should be_true + expect(subject.call(['muppet', 'mspiggy'])).to be_truthy end it 'should not have muppet named bigbird' do - subject.call(['muppet', 'bigbird']).should be_false + expect(subject.call(['muppet', 'bigbird'])).to be_falsey end end end diff --git a/spec/functions/has_ip_address_spec.rb b/spec/functions/has_ip_address_spec.rb index 5a68460..0df12a7 100755 --- a/spec/functions/has_ip_address_spec.rb +++ b/spec/functions/has_ip_address_spec.rb @@ -21,19 +21,19 @@ describe Puppet::Parser::Functions.function(:has_ip_address) do end it 'should have primary address (10.0.2.15)' do - subject.call(['10.0.2.15']).should be_true + expect(subject.call(['10.0.2.15'])).to be_truthy end it 'should have lookupback address (127.0.0.1)' do - subject.call(['127.0.0.1']).should be_true + expect(subject.call(['127.0.0.1'])).to be_truthy end it 'should not have other address' do - subject.call(['192.1681.1.1']).should be_false + expect(subject.call(['192.1681.1.1'])).to be_falsey end it 'should not have "mspiggy" on an interface' do - subject.call(['mspiggy']).should be_false + expect(subject.call(['mspiggy'])).to be_falsey end end end diff --git a/spec/functions/has_ip_network_spec.rb b/spec/functions/has_ip_network_spec.rb index c3a289e..2a2578e 100755 --- a/spec/functions/has_ip_network_spec.rb +++ b/spec/functions/has_ip_network_spec.rb @@ -21,15 +21,15 @@ describe Puppet::Parser::Functions.function(:has_ip_network) do end it 'should have primary network (10.0.2.0)' do - subject.call(['10.0.2.0']).should be_true + expect(subject.call(['10.0.2.0'])).to be_truthy end it 'should have loopback network (127.0.0.0)' do - subject.call(['127.0.0.1']).should be_true + expect(subject.call(['127.0.0.1'])).to be_truthy end it 'should not have other network' do - subject.call(['192.168.1.0']).should be_false + expect(subject.call(['192.168.1.0'])).to be_falsey end end end diff --git a/spec/functions/has_key_spec.rb b/spec/functions/has_key_spec.rb index 490daea..6b71800 100755 --- a/spec/functions/has_key_spec.rb +++ b/spec/functions/has_key_spec.rb @@ -6,7 +6,7 @@ describe Puppet::Parser::Functions.function(:has_key) do describe 'when calling has_key from puppet' do it "should not compile when no arguments are passed" do - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ Puppet[:code] = '$x = has_key()' expect { scope.compiler.compile @@ -14,7 +14,7 @@ describe Puppet::Parser::Functions.function(:has_key) do end it "should not compile when 1 argument is passed" do - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ Puppet[:code] = "$x = has_key('foo')" expect { scope.compiler.compile @@ -22,7 +22,7 @@ describe Puppet::Parser::Functions.function(:has_key) do end it "should require the first value to be a Hash" do - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ Puppet[:code] = "$x = has_key('foo', 'bar')" expect { scope.compiler.compile @@ -32,11 +32,11 @@ describe Puppet::Parser::Functions.function(:has_key) do describe 'when calling the function has_key from a scope instance' do it 'should detect existing keys' do - scope.function_has_key([{'one' => 1}, 'one']).should be_true + expect(scope.function_has_key([{'one' => 1}, 'one'])).to be_truthy end it 'should detect existing keys' do - scope.function_has_key([{'one' => 1}, 'two']).should be_false + expect(scope.function_has_key([{'one' => 1}, 'two'])).to be_falsey end end end diff --git a/spec/functions/hash_spec.rb b/spec/functions/hash_spec.rb index 7c91be9..ec2988b 100755 --- a/spec/functions/hash_spec.rb +++ b/spec/functions/hash_spec.rb @@ -5,15 +5,15 @@ describe "the hash function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("hash").should == "function_hash" + expect(Puppet::Parser::Functions.function("hash")).to eq("function_hash") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_hash([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_hash([]) }.to( raise_error(Puppet::ParseError)) end it "should convert an array to a hash" do result = scope.function_hash([['a',1,'b',2,'c',3]]) - result.should(eq({'a'=>1,'b'=>2,'c'=>3})) + expect(result).to(eq({'a'=>1,'b'=>2,'c'=>3})) end end diff --git a/spec/functions/intersection_spec.rb b/spec/functions/intersection_spec.rb index fd44f7f..6361304 100755 --- a/spec/functions/intersection_spec.rb +++ b/spec/functions/intersection_spec.rb @@ -5,15 +5,15 @@ describe "the intersection function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("intersection").should == "function_intersection" + expect(Puppet::Parser::Functions.function("intersection")).to eq("function_intersection") end it "should raise a ParseError if there are fewer than 2 arguments" do - lambda { scope.function_intersection([]) }.should( raise_error(Puppet::ParseError) ) + expect { scope.function_intersection([]) }.to( raise_error(Puppet::ParseError) ) end it "should return the intersection of two arrays" do result = scope.function_intersection([["a","b","c"],["b","c","d"]]) - result.should(eq(["b","c"])) + expect(result).to(eq(["b","c"])) end end diff --git a/spec/functions/is_array_spec.rb b/spec/functions/is_array_spec.rb index e7f4bcd..94920a4 100755 --- a/spec/functions/is_array_spec.rb +++ b/spec/functions/is_array_spec.rb @@ -5,25 +5,25 @@ describe "the is_array function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("is_array").should == "function_is_array" + expect(Puppet::Parser::Functions.function("is_array")).to eq("function_is_array") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_array([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_is_array([]) }.to( raise_error(Puppet::ParseError)) end it "should return true if passed an array" do result = scope.function_is_array([[1,2,3]]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if passed a hash" do result = scope.function_is_array([{'a'=>1}]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if passed a string" do result = scope.function_is_array(["asdf"]) - result.should(eq(false)) + expect(result).to(eq(false)) end end diff --git a/spec/functions/is_bool_spec.rb b/spec/functions/is_bool_spec.rb index c94e83a..4a342ba 100755 --- a/spec/functions/is_bool_spec.rb +++ b/spec/functions/is_bool_spec.rb @@ -5,40 +5,40 @@ describe "the is_bool function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("is_bool").should == "function_is_bool" + expect(Puppet::Parser::Functions.function("is_bool")).to eq("function_is_bool") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_bool([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_is_bool([]) }.to( raise_error(Puppet::ParseError)) end it "should return true if passed a TrueClass" do result = scope.function_is_bool([true]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return true if passed a FalseClass" do result = scope.function_is_bool([false]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if passed the string 'true'" do result = scope.function_is_bool(['true']) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if passed the string 'false'" do result = scope.function_is_bool(['false']) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if passed an array" do result = scope.function_is_bool([["a","b"]]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if passed a hash" do result = scope.function_is_bool([{"a" => "b"}]) - result.should(eq(false)) + expect(result).to(eq(false)) end end diff --git a/spec/functions/is_domain_name_spec.rb b/spec/functions/is_domain_name_spec.rb index f2ea76d..4d05f5c 100755 --- a/spec/functions/is_domain_name_spec.rb +++ b/spec/functions/is_domain_name_spec.rb @@ -5,60 +5,60 @@ describe "the is_domain_name function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("is_domain_name").should == "function_is_domain_name" + expect(Puppet::Parser::Functions.function("is_domain_name")).to eq("function_is_domain_name") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_domain_name([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_is_domain_name([]) }.to( raise_error(Puppet::ParseError)) end it "should return true if a valid short domain name" do result = scope.function_is_domain_name(["x.com"]) - result.should(be_true) + expect(result).to(be_truthy) end it "should return true if the domain is ." do result = scope.function_is_domain_name(["."]) - result.should(be_true) + expect(result).to(be_truthy) end it "should return true if the domain is x.com." do result = scope.function_is_domain_name(["x.com."]) - result.should(be_true) + expect(result).to(be_truthy) end it "should return true if a valid domain name" do result = scope.function_is_domain_name(["foo.bar.com"]) - result.should(be_true) + expect(result).to(be_truthy) end it "should allow domain parts to start with numbers" do result = scope.function_is_domain_name(["3foo.2bar.com"]) - result.should(be_true) + expect(result).to(be_truthy) end it "should allow domain to end with a dot" do result = scope.function_is_domain_name(["3foo.2bar.com."]) - result.should(be_true) + expect(result).to(be_truthy) end it "should allow a single part domain" do result = scope.function_is_domain_name(["orange"]) - result.should(be_true) + expect(result).to(be_truthy) end it "should return false if domain parts start with hyphens" do result = scope.function_is_domain_name(["-3foo.2bar.com"]) - result.should(be_false) + expect(result).to(be_falsey) end it "should return true if domain contains hyphens" do result = scope.function_is_domain_name(["3foo-bar.2bar-fuzz.com"]) - result.should(be_true) + expect(result).to(be_truthy) end it "should return false if domain name contains spaces" do result = scope.function_is_domain_name(["not valid"]) - result.should(be_false) + expect(result).to(be_falsey) end end diff --git a/spec/functions/is_float_spec.rb b/spec/functions/is_float_spec.rb index b7d73b0..d926634 100755 --- a/spec/functions/is_float_spec.rb +++ b/spec/functions/is_float_spec.rb @@ -5,29 +5,29 @@ describe "the is_float function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("is_float").should == "function_is_float" + expect(Puppet::Parser::Functions.function("is_float")).to eq("function_is_float") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_float([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_is_float([]) }.to( raise_error(Puppet::ParseError)) end it "should return true if a float" do result = scope.function_is_float(["0.12"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if a string" do result = scope.function_is_float(["asdf"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if an integer" do result = scope.function_is_float(["3"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return true if a float is created from an arithmetical operation" do result = scope.function_is_float([3.2*2]) - result.should(eq(true)) + expect(result).to(eq(true)) end end diff --git a/spec/functions/is_function_available.rb b/spec/functions/is_function_available.rb index d5669a7..3a9aa1b 100755 --- a/spec/functions/is_function_available.rb +++ b/spec/functions/is_function_available.rb @@ -11,21 +11,21 @@ describe "the is_function_available function" do end it "should exist" do - Puppet::Parser::Functions.function("is_function_available").should == "function_is_function_available" + expect(Puppet::Parser::Functions.function("is_function_available")).to eq("function_is_function_available") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { @scope.function_is_function_available([]) }.should( raise_error(Puppet::ParseError)) + expect { @scope.function_is_function_available([]) }.to( raise_error(Puppet::ParseError)) end it "should return false if a nonexistent function is passed" do result = @scope.function_is_function_available(['jeff_mccunes_left_sock']) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return true if an available function is passed" do result = @scope.function_is_function_available(['require']) - result.should(eq(true)) + expect(result).to(eq(true)) end end diff --git a/spec/functions/is_hash_spec.rb b/spec/functions/is_hash_spec.rb index bbebf39..a849411 100755 --- a/spec/functions/is_hash_spec.rb +++ b/spec/functions/is_hash_spec.rb @@ -5,25 +5,25 @@ describe "the is_hash function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("is_hash").should == "function_is_hash" + expect(Puppet::Parser::Functions.function("is_hash")).to eq("function_is_hash") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_hash([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_is_hash([]) }.to( raise_error(Puppet::ParseError)) end it "should return true if passed a hash" do result = scope.function_is_hash([{"a"=>1,"b"=>2}]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if passed an array" do result = scope.function_is_hash([["a","b"]]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if passed a string" do result = scope.function_is_hash(["asdf"]) - result.should(eq(false)) + expect(result).to(eq(false)) end end diff --git a/spec/functions/is_integer_spec.rb b/spec/functions/is_integer_spec.rb index 24141cc..f0cbca8 100755 --- a/spec/functions/is_integer_spec.rb +++ b/spec/functions/is_integer_spec.rb @@ -5,65 +5,65 @@ describe "the is_integer function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("is_integer").should == "function_is_integer" + expect(Puppet::Parser::Functions.function("is_integer")).to eq("function_is_integer") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_integer([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_is_integer([]) }.to( raise_error(Puppet::ParseError)) end it "should return true if an integer" do result = scope.function_is_integer(["3"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return true if a negative integer" do result = scope.function_is_integer(["-7"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if a float" do result = scope.function_is_integer(["3.2"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if a string" do result = scope.function_is_integer(["asdf"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return true if an integer is created from an arithmetical operation" do result = scope.function_is_integer([3*2]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if an array" do result = scope.function_is_numeric([["asdf"]]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if a hash" do result = scope.function_is_numeric([{"asdf" => false}]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if a boolean" do result = scope.function_is_numeric([true]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if a whitespace is in the string" do result = scope.function_is_numeric([" -1324"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if it is zero prefixed" do result = scope.function_is_numeric(["0001234"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if it is wrapped inside an array" do result = scope.function_is_numeric([[1234]]) - result.should(eq(false)) + expect(result).to(eq(false)) end end diff --git a/spec/functions/is_ip_address_spec.rb b/spec/functions/is_ip_address_spec.rb index c0debb3..c16d12b 100755 --- a/spec/functions/is_ip_address_spec.rb +++ b/spec/functions/is_ip_address_spec.rb @@ -5,35 +5,35 @@ describe "the is_ip_address function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("is_ip_address").should == "function_is_ip_address" + expect(Puppet::Parser::Functions.function("is_ip_address")).to eq("function_is_ip_address") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_ip_address([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_is_ip_address([]) }.to( raise_error(Puppet::ParseError)) end it "should return true if an IPv4 address" do result = scope.function_is_ip_address(["1.2.3.4"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return true if a full IPv6 address" do result = scope.function_is_ip_address(["fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return true if a compressed IPv6 address" do result = scope.function_is_ip_address(["fe00::1"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if not valid" do result = scope.function_is_ip_address(["asdf"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if IP octets out of range" do result = scope.function_is_ip_address(["1.1.1.300"]) - result.should(eq(false)) + expect(result).to(eq(false)) end end diff --git a/spec/functions/is_mac_address_spec.rb b/spec/functions/is_mac_address_spec.rb index ca9c590..66edd19 100755 --- a/spec/functions/is_mac_address_spec.rb +++ b/spec/functions/is_mac_address_spec.rb @@ -5,25 +5,25 @@ describe "the is_mac_address function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("is_mac_address").should == "function_is_mac_address" + expect(Puppet::Parser::Functions.function("is_mac_address")).to eq("function_is_mac_address") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_mac_address([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_is_mac_address([]) }.to( raise_error(Puppet::ParseError)) end it "should return true if a valid mac address" do result = scope.function_is_mac_address(["00:a0:1f:12:7f:a0"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if octets are out of range" do result = scope.function_is_mac_address(["00:a0:1f:12:7f:g0"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if not valid" do result = scope.function_is_mac_address(["not valid"]) - result.should(eq(false)) + expect(result).to(eq(false)) end end diff --git a/spec/functions/is_numeric_spec.rb b/spec/functions/is_numeric_spec.rb index 1df1497..4176961 100755 --- a/spec/functions/is_numeric_spec.rb +++ b/spec/functions/is_numeric_spec.rb @@ -5,71 +5,71 @@ describe "the is_numeric function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("is_numeric").should == "function_is_numeric" + expect(Puppet::Parser::Functions.function("is_numeric")).to eq("function_is_numeric") end it "should raise a ParseError if there is less than 1 argument" do - lambda { scope.function_is_numeric([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_is_numeric([]) }.to( raise_error(Puppet::ParseError)) end it "should return true if an integer" do result = scope.function_is_numeric(["3"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return true if a float" do result = scope.function_is_numeric(["3.2"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return true if an integer is created from an arithmetical operation" do result = scope.function_is_numeric([3*2]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return true if a float is created from an arithmetical operation" do result = scope.function_is_numeric([3.2*2]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if a string" do result = scope.function_is_numeric(["asdf"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if an array" do result = scope.function_is_numeric([["asdf"]]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if an array of integers" do result = scope.function_is_numeric([[1,2,3,4]]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if a hash" do result = scope.function_is_numeric([{"asdf" => false}]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if a hash with numbers in it" do result = scope.function_is_numeric([{1 => 2}]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if a boolean" do result = scope.function_is_numeric([true]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return true if a negative float with exponent" do result = scope.function_is_numeric(["-342.2315e-12"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if a negative integer with whitespaces before/after the dash" do result = scope.function_is_numeric([" - 751"]) - result.should(eq(false)) + expect(result).to(eq(false)) end # it "should return true if a hexadecimal" do diff --git a/spec/functions/is_string_spec.rb b/spec/functions/is_string_spec.rb index 3756bea..6a0801a 100755 --- a/spec/functions/is_string_spec.rb +++ b/spec/functions/is_string_spec.rb @@ -5,30 +5,30 @@ describe "the is_string function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("is_string").should == "function_is_string" + expect(Puppet::Parser::Functions.function("is_string")).to eq("function_is_string") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_string([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_is_string([]) }.to( raise_error(Puppet::ParseError)) end it "should return true if a string" do result = scope.function_is_string(["asdf"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if an integer" do result = scope.function_is_string(["3"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if a float" do result = scope.function_is_string(["3.23"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return false if an array" do result = scope.function_is_string([["a","b","c"]]) - result.should(eq(false)) + expect(result).to(eq(false)) end end diff --git a/spec/functions/join_keys_to_values_spec.rb b/spec/functions/join_keys_to_values_spec.rb index a52fb71..4a9ae87 100755 --- a/spec/functions/join_keys_to_values_spec.rb +++ b/spec/functions/join_keys_to_values_spec.rb @@ -5,36 +5,36 @@ describe "the join_keys_to_values function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("join_keys_to_values").should == "function_join_keys_to_values" + expect(Puppet::Parser::Functions.function("join_keys_to_values")).to eq("function_join_keys_to_values") end it "should raise a ParseError if there are fewer than two arguments" do - lambda { scope.function_join_keys_to_values([{}]) }.should raise_error Puppet::ParseError + expect { scope.function_join_keys_to_values([{}]) }.to raise_error Puppet::ParseError end it "should raise a ParseError if there are greater than two arguments" do - lambda { scope.function_join_keys_to_values([{}, 'foo', 'bar']) }.should raise_error Puppet::ParseError + expect { scope.function_join_keys_to_values([{}, 'foo', 'bar']) }.to raise_error Puppet::ParseError end it "should raise a TypeError if the first argument is an array" do - lambda { scope.function_join_keys_to_values([[1,2], ',']) }.should raise_error TypeError + expect { scope.function_join_keys_to_values([[1,2], ',']) }.to raise_error TypeError end it "should raise a TypeError if the second argument is an array" do - lambda { scope.function_join_keys_to_values([{}, [1,2]]) }.should raise_error TypeError + expect { scope.function_join_keys_to_values([{}, [1,2]]) }.to raise_error TypeError end it "should raise a TypeError if the second argument is a number" do - lambda { scope.function_join_keys_to_values([{}, 1]) }.should raise_error TypeError + expect { scope.function_join_keys_to_values([{}, 1]) }.to raise_error TypeError end it "should return an empty array given an empty hash" do result = scope.function_join_keys_to_values([{}, ":"]) - result.should == [] + expect(result).to eq([]) end it "should join hash's keys to its values" do result = scope.function_join_keys_to_values([{'a'=>1,2=>'foo',:b=>nil}, ":"]) - result.should =~ ['a:1','2:foo','b:'] + expect(result).to match_array(['a:1','2:foo','b:']) end end diff --git a/spec/functions/join_spec.rb b/spec/functions/join_spec.rb index aafa1a7..793c36f 100755 --- a/spec/functions/join_spec.rb +++ b/spec/functions/join_spec.rb @@ -5,15 +5,15 @@ describe "the join function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("join").should == "function_join" + expect(Puppet::Parser::Functions.function("join")).to eq("function_join") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_join([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_join([]) }.to( raise_error(Puppet::ParseError)) end it "should join an array into a string" do result = scope.function_join([["a","b","c"], ":"]) - result.should(eq("a:b:c")) + expect(result).to(eq("a:b:c")) end end diff --git a/spec/functions/keys_spec.rb b/spec/functions/keys_spec.rb index fdd7a70..f2e7d42 100755 --- a/spec/functions/keys_spec.rb +++ b/spec/functions/keys_spec.rb @@ -5,17 +5,17 @@ describe "the keys function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("keys").should == "function_keys" + expect(Puppet::Parser::Functions.function("keys")).to eq("function_keys") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_keys([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_keys([]) }.to( raise_error(Puppet::ParseError)) end it "should return an array of keys when given a hash" do result = scope.function_keys([{'a'=>1, 'b'=>2}]) # =~ performs 'array with same elements' (set) matching # For more info see RSpec::Matchers::MatchArray - result.should =~ ['a','b'] + expect(result).to match_array(['a','b']) end end diff --git a/spec/functions/loadyaml_spec.rb b/spec/functions/loadyaml_spec.rb index fe16318..cdc3d6f 100755 --- a/spec/functions/loadyaml_spec.rb +++ b/spec/functions/loadyaml_spec.rb @@ -7,7 +7,7 @@ describe "the loadyaml function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("loadyaml").should == "function_loadyaml" + expect(Puppet::Parser::Functions.function("loadyaml")).to eq("function_loadyaml") end it "should raise a ParseError if there is less than 1 arguments" do @@ -20,6 +20,6 @@ describe "the loadyaml function" do fh.write("---\n aaa: 1\n bbb: 2\n ccc: 3\n ddd: 4\n") end result = scope.function_loadyaml([yaml_file]) - result.should == {"aaa" => 1, "bbb" => 2, "ccc" => 3, "ddd" => 4 } + expect(result).to eq({"aaa" => 1, "bbb" => 2, "ccc" => 3, "ddd" => 4 }) end end diff --git a/spec/functions/lstrip_spec.rb b/spec/functions/lstrip_spec.rb index b280ae7..7025f97 100755 --- a/spec/functions/lstrip_spec.rb +++ b/spec/functions/lstrip_spec.rb @@ -5,15 +5,15 @@ describe "the lstrip function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("lstrip").should == "function_lstrip" + expect(Puppet::Parser::Functions.function("lstrip")).to eq("function_lstrip") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_lstrip([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_lstrip([]) }.to( raise_error(Puppet::ParseError)) end it "should lstrip a string" do result = scope.function_lstrip([" asdf"]) - result.should(eq('asdf')) + expect(result).to(eq('asdf')) end end diff --git a/spec/functions/max_spec.rb b/spec/functions/max_spec.rb index ff6f2b3..c3d8a13 100755 --- a/spec/functions/max_spec.rb +++ b/spec/functions/max_spec.rb @@ -6,22 +6,22 @@ describe "the max function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("max").should == "function_max" + expect(Puppet::Parser::Functions.function("max")).to eq("function_max") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_max([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_max([]) }.to( raise_error(Puppet::ParseError)) end it "should be able to compare strings" do - scope.function_max(["albatross","dog","horse"]).should(eq("horse")) + expect(scope.function_max(["albatross","dog","horse"])).to(eq("horse")) end it "should be able to compare numbers" do - scope.function_max([6,8,4]).should(eq(8)) + expect(scope.function_max([6,8,4])).to(eq(8)) end it "should be able to compare a number with a stringified number" do - scope.function_max([1,"2"]).should(eq("2")) + expect(scope.function_max([1,"2"])).to(eq("2")) end end diff --git a/spec/functions/member_spec.rb b/spec/functions/member_spec.rb index 6e9a023..cee6110 100755 --- a/spec/functions/member_spec.rb +++ b/spec/functions/member_spec.rb @@ -5,20 +5,20 @@ describe "the member function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("member").should == "function_member" + expect(Puppet::Parser::Functions.function("member")).to eq("function_member") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_member([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_member([]) }.to( raise_error(Puppet::ParseError)) end it "should return true if a member is in an array" do result = scope.function_member([["a","b","c"], "a"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should return false if a member is not in an array" do result = scope.function_member([["a","b","c"], "d"]) - result.should(eq(false)) + expect(result).to(eq(false)) end end diff --git a/spec/functions/merge_spec.rb b/spec/functions/merge_spec.rb index 15a5d94..2abf976 100755 --- a/spec/functions/merge_spec.rb +++ b/spec/functions/merge_spec.rb @@ -7,7 +7,7 @@ describe Puppet::Parser::Functions.function(:merge) do describe 'when calling merge from puppet' do it "should not compile when no arguments are passed" do - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ Puppet[:code] = '$x = merge()' expect { scope.compiler.compile @@ -15,7 +15,7 @@ describe Puppet::Parser::Functions.function(:merge) do end it "should not compile when 1 argument is passed" do - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ Puppet[:code] = "$my_hash={'one' => 1}\n$x = merge($my_hash)" expect { scope.compiler.compile @@ -35,18 +35,18 @@ describe Puppet::Parser::Functions.function(:merge) do it 'should be able to merge two hashes' do new_hash = scope.function_merge([{'one' => '1', 'two' => '1'}, {'two' => '2', 'three' => '2'}]) - new_hash['one'].should == '1' - new_hash['two'].should == '2' - new_hash['three'].should == '2' + expect(new_hash['one']).to eq('1') + expect(new_hash['two']).to eq('2') + expect(new_hash['three']).to eq('2') end it 'should merge multiple hashes' do hash = scope.function_merge([{'one' => 1}, {'one' => '2'}, {'one' => '3'}]) - hash['one'].should == '3' + expect(hash['one']).to eq('3') end it 'should accept empty hashes' do - scope.function_merge([{},{},{}]).should == {} + expect(scope.function_merge([{},{},{}])).to eq({}) end end end diff --git a/spec/functions/min_spec.rb b/spec/functions/min_spec.rb index 71d593e..35a0890 100755 --- a/spec/functions/min_spec.rb +++ b/spec/functions/min_spec.rb @@ -6,22 +6,22 @@ describe "the min function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("min").should == "function_min" + expect(Puppet::Parser::Functions.function("min")).to eq("function_min") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_min([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_min([]) }.to( raise_error(Puppet::ParseError)) end it "should be able to compare strings" do - scope.function_min(["albatross","dog","horse"]).should(eq("albatross")) + expect(scope.function_min(["albatross","dog","horse"])).to(eq("albatross")) end it "should be able to compare numbers" do - scope.function_min([6,8,4]).should(eq(4)) + expect(scope.function_min([6,8,4])).to(eq(4)) end it "should be able to compare a number with a stringified number" do - scope.function_min([1,"2"]).should(eq(1)) + expect(scope.function_min([1,"2"])).to(eq(1)) end end diff --git a/spec/functions/num2bool_spec.rb b/spec/functions/num2bool_spec.rb index b56196d..d0ba935 100755 --- a/spec/functions/num2bool_spec.rb +++ b/spec/functions/num2bool_spec.rb @@ -5,63 +5,63 @@ describe "the num2bool function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("num2bool").should == "function_num2bool" + expect(Puppet::Parser::Functions.function("num2bool")).to eq("function_num2bool") end it "should raise a ParseError if there are no arguments" do - lambda { scope.function_num2bool([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_num2bool([]) }.to( raise_error(Puppet::ParseError)) end it "should raise a ParseError if there are more than 1 arguments" do - lambda { scope.function_num2bool(["foo","bar"]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_num2bool(["foo","bar"]) }.to( raise_error(Puppet::ParseError)) end it "should raise a ParseError if passed something non-numeric" do - lambda { scope.function_num2bool(["xyzzy"]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_num2bool(["xyzzy"]) }.to( raise_error(Puppet::ParseError)) end it "should return true if passed string 1" do result = scope.function_num2bool(["1"]) - result.should(be_true) + expect(result).to(be_truthy) end it "should return true if passed string 1.5" do result = scope.function_num2bool(["1.5"]) - result.should(be_true) + expect(result).to(be_truthy) end it "should return true if passed number 1" do result = scope.function_num2bool([1]) - result.should(be_true) + expect(result).to(be_truthy) end it "should return false if passed string 0" do result = scope.function_num2bool(["0"]) - result.should(be_false) + expect(result).to(be_falsey) end it "should return false if passed number 0" do result = scope.function_num2bool([0]) - result.should(be_false) + expect(result).to(be_falsey) end it "should return false if passed string -1" do result = scope.function_num2bool(["-1"]) - result.should(be_false) + expect(result).to(be_falsey) end it "should return false if passed string -1.5" do result = scope.function_num2bool(["-1.5"]) - result.should(be_false) + expect(result).to(be_falsey) end it "should return false if passed number -1" do result = scope.function_num2bool([-1]) - result.should(be_false) + expect(result).to(be_falsey) end it "should return false if passed float -1.5" do result = scope.function_num2bool([-1.5]) - result.should(be_false) + expect(result).to(be_falsey) end end diff --git a/spec/functions/parsejson_spec.rb b/spec/functions/parsejson_spec.rb index f179ac1..1dd41b9 100755 --- a/spec/functions/parsejson_spec.rb +++ b/spec/functions/parsejson_spec.rb @@ -5,11 +5,11 @@ describe "the parsejson function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("parsejson").should == "function_parsejson" + expect(Puppet::Parser::Functions.function("parsejson")).to eq("function_parsejson") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_parsejson([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_parsejson([]) }.to( raise_error(Puppet::ParseError)) end it "should convert JSON to a data structure" do @@ -17,6 +17,6 @@ describe "the parsejson function" do ["aaa","bbb","ccc"] EOS result = scope.function_parsejson([json]) - result.should(eq(['aaa','bbb','ccc'])) + expect(result).to(eq(['aaa','bbb','ccc'])) end end diff --git a/spec/functions/parseyaml_spec.rb b/spec/functions/parseyaml_spec.rb index 0c7aea8..e5f145b 100755 --- a/spec/functions/parseyaml_spec.rb +++ b/spec/functions/parseyaml_spec.rb @@ -5,11 +5,11 @@ describe "the parseyaml function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("parseyaml").should == "function_parseyaml" + expect(Puppet::Parser::Functions.function("parseyaml")).to eq("function_parseyaml") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_parseyaml([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_parseyaml([]) }.to( raise_error(Puppet::ParseError)) end it "should convert YAML to a data structure" do @@ -19,6 +19,6 @@ describe "the parseyaml function" do - ccc EOS result = scope.function_parseyaml([yaml]) - result.should(eq(['aaa','bbb','ccc'])) + expect(result).to(eq(['aaa','bbb','ccc'])) end end diff --git a/spec/functions/pick_default_spec.rb b/spec/functions/pick_default_spec.rb index c9235b5..db10cc3 100755 --- a/spec/functions/pick_default_spec.rb +++ b/spec/functions/pick_default_spec.rb @@ -5,51 +5,51 @@ describe "the pick_default function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("pick_default").should == "function_pick_default" + expect(Puppet::Parser::Functions.function("pick_default")).to eq("function_pick_default") end it 'should return the correct value' do - scope.function_pick_default(['first', 'second']).should == 'first' + expect(scope.function_pick_default(['first', 'second'])).to eq('first') end it 'should return the correct value if the first value is empty' do - scope.function_pick_default(['', 'second']).should == 'second' + expect(scope.function_pick_default(['', 'second'])).to eq('second') end it 'should skip empty string values' do - scope.function_pick_default(['', 'first']).should == 'first' + expect(scope.function_pick_default(['', 'first'])).to eq('first') end it 'should skip :undef values' do - scope.function_pick_default([:undef, 'first']).should == 'first' + expect(scope.function_pick_default([:undef, 'first'])).to eq('first') end it 'should skip :undefined values' do - scope.function_pick_default([:undefined, 'first']).should == 'first' + expect(scope.function_pick_default([:undefined, 'first'])).to eq('first') end it 'should return the empty string if it is the last possibility' do - scope.function_pick_default([:undef, :undefined, '']).should == '' + expect(scope.function_pick_default([:undef, :undefined, ''])).to eq('') end it 'should return :undef if it is the last possibility' do - scope.function_pick_default(['', :undefined, :undef]).should == :undef + expect(scope.function_pick_default(['', :undefined, :undef])).to eq(:undef) end it 'should return :undefined if it is the last possibility' do - scope.function_pick_default([:undef, '', :undefined]).should == :undefined + expect(scope.function_pick_default([:undef, '', :undefined])).to eq(:undefined) end it 'should return the empty string if it is the only possibility' do - scope.function_pick_default(['']).should == '' + expect(scope.function_pick_default([''])).to eq('') end it 'should return :undef if it is the only possibility' do - scope.function_pick_default([:undef]).should == :undef + expect(scope.function_pick_default([:undef])).to eq(:undef) end it 'should return :undefined if it is the only possibility' do - scope.function_pick_default([:undefined]).should == :undefined + expect(scope.function_pick_default([:undefined])).to eq(:undefined) end it 'should error if no values are passed' do diff --git a/spec/functions/pick_spec.rb b/spec/functions/pick_spec.rb index f53fa80..8be8f58 100755 --- a/spec/functions/pick_spec.rb +++ b/spec/functions/pick_spec.rb @@ -5,27 +5,27 @@ describe "the pick function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("pick").should == "function_pick" + expect(Puppet::Parser::Functions.function("pick")).to eq("function_pick") end it 'should return the correct value' do - scope.function_pick(['first', 'second']).should == 'first' + expect(scope.function_pick(['first', 'second'])).to eq('first') end it 'should return the correct value if the first value is empty' do - scope.function_pick(['', 'second']).should == 'second' + expect(scope.function_pick(['', 'second'])).to eq('second') end it 'should remove empty string values' do - scope.function_pick(['', 'first']).should == 'first' + expect(scope.function_pick(['', 'first'])).to eq('first') end it 'should remove :undef values' do - scope.function_pick([:undef, 'first']).should == 'first' + expect(scope.function_pick([:undef, 'first'])).to eq('first') end it 'should remove :undefined values' do - scope.function_pick([:undefined, 'first']).should == 'first' + expect(scope.function_pick([:undefined, 'first'])).to eq('first') end it 'should error if no values are passed' do diff --git a/spec/functions/prefix_spec.rb b/spec/functions/prefix_spec.rb index 6e8ddc5..34cac53 100755 --- a/spec/functions/prefix_spec.rb +++ b/spec/functions/prefix_spec.rb @@ -23,6 +23,6 @@ describe "the prefix function" do it "returns a prefixed array" do result = scope.function_prefix([['a','b','c'], 'p']) - result.should(eq(['pa','pb','pc'])) + expect(result).to(eq(['pa','pb','pc'])) end end diff --git a/spec/functions/range_spec.rb b/spec/functions/range_spec.rb index 0e1ad37..9b9ece0 100755 --- a/spec/functions/range_spec.rb +++ b/spec/functions/range_spec.rb @@ -5,7 +5,7 @@ describe "the range function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "exists" do - Puppet::Parser::Functions.function("range").should == "function_range" + expect(Puppet::Parser::Functions.function("range")).to eq("function_range") end it "raises a ParseError if there is less than 1 arguments" do @@ -15,56 +15,56 @@ describe "the range function" do describe 'with a letter range' do it "returns a letter range" do result = scope.function_range(["a","d"]) - result.should eq ['a','b','c','d'] + expect(result).to eq ['a','b','c','d'] end it "returns a letter range given a step of 1" do result = scope.function_range(["a","d","1"]) - result.should eq ['a','b','c','d'] + expect(result).to eq ['a','b','c','d'] end it "returns a stepped letter range" do result = scope.function_range(["a","d","2"]) - result.should eq ['a','c'] + expect(result).to eq ['a','c'] end it "returns a stepped letter range given a negative step" do result = scope.function_range(["a","d","-2"]) - result.should eq ['a','c'] + expect(result).to eq ['a','c'] end end describe 'with a number range' do it "returns a number range" do result = scope.function_range(["1","4"]) - result.should eq [1,2,3,4] + expect(result).to eq [1,2,3,4] end it "returns a number range given a step of 1" do result = scope.function_range(["1","4","1"]) - result.should eq [1,2,3,4] + expect(result).to eq [1,2,3,4] end it "returns a stepped number range" do result = scope.function_range(["1","4","2"]) - result.should eq [1,3] + expect(result).to eq [1,3] end it "returns a stepped number range given a negative step" do result = scope.function_range(["1","4","-2"]) - result.should eq [1,3] + expect(result).to eq [1,3] end end describe 'with a numeric-like string range' do it "works with padded hostname like strings" do expected = ("host01".."host10").to_a - scope.function_range(["host01","host10"]).should eq expected + expect(scope.function_range(["host01","host10"])).to eq expected end it "coerces zero padded digits to integers" do expected = (0..10).to_a - scope.function_range(["00", "10"]).should eq expected + expect(scope.function_range(["00", "10"])).to eq expected end end end diff --git a/spec/functions/reject_spec.rb b/spec/functions/reject_spec.rb index f2cb741..88a992e 100755 --- a/spec/functions/reject_spec.rb +++ b/spec/functions/reject_spec.rb @@ -6,15 +6,15 @@ describe "the reject function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("reject").should == "function_reject" + expect(Puppet::Parser::Functions.function("reject")).to eq("function_reject") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_reject([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_reject([]) }.to( raise_error(Puppet::ParseError)) end it "should reject contents from an array" do result = scope.function_reject([["1111", "aaabbb","bbbccc","dddeee"], "bbb"]) - result.should(eq(["1111", "dddeee"])) + expect(result).to(eq(["1111", "dddeee"])) end end diff --git a/spec/functions/reverse_spec.rb b/spec/functions/reverse_spec.rb index 1b59206..bfeabfb 100755 --- a/spec/functions/reverse_spec.rb +++ b/spec/functions/reverse_spec.rb @@ -5,15 +5,15 @@ describe "the reverse function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("reverse").should == "function_reverse" + expect(Puppet::Parser::Functions.function("reverse")).to eq("function_reverse") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_reverse([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_reverse([]) }.to( raise_error(Puppet::ParseError)) end it "should reverse a string" do result = scope.function_reverse(["asdfghijkl"]) - result.should(eq('lkjihgfdsa')) + expect(result).to(eq('lkjihgfdsa')) end end diff --git a/spec/functions/rstrip_spec.rb b/spec/functions/rstrip_spec.rb index d90de1d..81321d7 100755 --- a/spec/functions/rstrip_spec.rb +++ b/spec/functions/rstrip_spec.rb @@ -5,20 +5,20 @@ describe "the rstrip function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("rstrip").should == "function_rstrip" + expect(Puppet::Parser::Functions.function("rstrip")).to eq("function_rstrip") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_rstrip([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_rstrip([]) }.to( raise_error(Puppet::ParseError)) end it "should rstrip a string" do result = scope.function_rstrip(["asdf "]) - result.should(eq('asdf')) + expect(result).to(eq('asdf')) end it "should rstrip each element in an array" do result = scope.function_rstrip([["a ","b ", "c "]]) - result.should(eq(['a','b','c'])) + expect(result).to(eq(['a','b','c'])) end end diff --git a/spec/functions/shuffle_spec.rb b/spec/functions/shuffle_spec.rb index 93346d5..ee0e2ff 100755 --- a/spec/functions/shuffle_spec.rb +++ b/spec/functions/shuffle_spec.rb @@ -5,20 +5,20 @@ describe "the shuffle function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("shuffle").should == "function_shuffle" + expect(Puppet::Parser::Functions.function("shuffle")).to eq("function_shuffle") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_shuffle([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_shuffle([]) }.to( raise_error(Puppet::ParseError)) end it "should shuffle a string and the result should be the same size" do result = scope.function_shuffle(["asdf"]) - result.size.should(eq(4)) + expect(result.size).to(eq(4)) end it "should shuffle a string but the sorted contents should still be the same" do result = scope.function_shuffle(["adfs"]) - result.split("").sort.join("").should(eq("adfs")) + expect(result.split("").sort.join("")).to(eq("adfs")) end end diff --git a/spec/functions/size_spec.rb b/spec/functions/size_spec.rb index b1c435a..18eb48f 100755 --- a/spec/functions/size_spec.rb +++ b/spec/functions/size_spec.rb @@ -5,20 +5,20 @@ describe "the size function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("size").should == "function_size" + expect(Puppet::Parser::Functions.function("size")).to eq("function_size") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_size([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_size([]) }.to( raise_error(Puppet::ParseError)) end it "should return the size of a string" do result = scope.function_size(["asdf"]) - result.should(eq(4)) + expect(result).to(eq(4)) end it "should return the size of an array" do result = scope.function_size([["a","b","c"]]) - result.should(eq(3)) + expect(result).to(eq(3)) end end diff --git a/spec/functions/sort_spec.rb b/spec/functions/sort_spec.rb index 3187a5a..4c2a66c 100755 --- a/spec/functions/sort_spec.rb +++ b/spec/functions/sort_spec.rb @@ -5,20 +5,20 @@ describe "the sort function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("sort").should == "function_sort" + expect(Puppet::Parser::Functions.function("sort")).to eq("function_sort") end it "should raise a ParseError if there is not 1 arguments" do - lambda { scope.function_sort(['','']) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_sort(['','']) }.to( raise_error(Puppet::ParseError)) end it "should sort an array" do result = scope.function_sort([["a","c","b"]]) - result.should(eq(['a','b','c'])) + expect(result).to(eq(['a','b','c'])) end it "should sort a string" do result = scope.function_sort(["acb"]) - result.should(eq('abc')) + expect(result).to(eq('abc')) end end diff --git a/spec/functions/squeeze_spec.rb b/spec/functions/squeeze_spec.rb index 60e5a30..cd0eb37 100755 --- a/spec/functions/squeeze_spec.rb +++ b/spec/functions/squeeze_spec.rb @@ -5,20 +5,20 @@ describe "the squeeze function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("squeeze").should == "function_squeeze" + expect(Puppet::Parser::Functions.function("squeeze")).to eq("function_squeeze") end it "should raise a ParseError if there is less than 2 arguments" do - lambda { scope.function_squeeze([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_squeeze([]) }.to( raise_error(Puppet::ParseError)) end it "should squeeze a string" do result = scope.function_squeeze(["aaabbbbcccc"]) - result.should(eq('abc')) + expect(result).to(eq('abc')) end it "should squeeze all elements in an array" do result = scope.function_squeeze([["aaabbbbcccc","dddfff"]]) - result.should(eq(['abc','df'])) + expect(result).to(eq(['abc','df'])) end end diff --git a/spec/functions/str2bool_spec.rb b/spec/functions/str2bool_spec.rb index 73c09c7..1d205d7 100755 --- a/spec/functions/str2bool_spec.rb +++ b/spec/functions/str2bool_spec.rb @@ -5,27 +5,27 @@ describe "the str2bool function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("str2bool").should == "function_str2bool" + expect(Puppet::Parser::Functions.function("str2bool")).to eq("function_str2bool") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_str2bool([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_str2bool([]) }.to( raise_error(Puppet::ParseError)) end it "should convert string 'true' to true" do result = scope.function_str2bool(["true"]) - result.should(eq(true)) + expect(result).to(eq(true)) end it "should convert string 'undef' to false" do result = scope.function_str2bool(["undef"]) - result.should(eq(false)) + expect(result).to(eq(false)) end it "should return the boolean it was called with" do result = scope.function_str2bool([true]) - result.should(eq(true)) + expect(result).to(eq(true)) result = scope.function_str2bool([false]) - result.should(eq(false)) + expect(result).to(eq(false)) end end diff --git a/spec/functions/str2saltedsha512_spec.rb b/spec/functions/str2saltedsha512_spec.rb index df8fb8e..ab7f57f 100755 --- a/spec/functions/str2saltedsha512_spec.rb +++ b/spec/functions/str2saltedsha512_spec.rb @@ -5,7 +5,7 @@ describe "the str2saltedsha512 function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("str2saltedsha512").should == "function_str2saltedsha512" + expect(Puppet::Parser::Functions.function("str2saltedsha512")).to eq("function_str2saltedsha512") end it "should raise a ParseError if there is less than 1 argument" do @@ -18,7 +18,7 @@ describe "the str2saltedsha512 function" do it "should return a salted-sha512 password hash 136 characters in length" do result = scope.function_str2saltedsha512(["password"]) - result.length.should(eq(136)) + expect(result.length).to(eq(136)) end it "should raise an error if you pass a non-string password" do @@ -40,6 +40,6 @@ describe "the str2saltedsha512 function" do # Combine the Binary Salt with 'password' and compare the end result saltedpass = Digest::SHA512.digest(str_salt + 'password') result = (str_salt + saltedpass).unpack('H*')[0] - result.should == password_hash + expect(result).to eq(password_hash) end end diff --git a/spec/functions/strftime_spec.rb b/spec/functions/strftime_spec.rb index df42b6f..ebec54b 100755 --- a/spec/functions/strftime_spec.rb +++ b/spec/functions/strftime_spec.rb @@ -5,25 +5,25 @@ describe "the strftime function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("strftime").should == "function_strftime" + expect(Puppet::Parser::Functions.function("strftime")).to eq("function_strftime") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_strftime([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_strftime([]) }.to( raise_error(Puppet::ParseError)) end it "using %s should be higher then when I wrote this test" do result = scope.function_strftime(["%s"]) - result.to_i.should(be > 1311953157) + expect(result.to_i).to(be > 1311953157) end it "using %s should be lower then 1.5 trillion" do result = scope.function_strftime(["%s"]) - result.to_i.should(be < 1500000000) + expect(result.to_i).to(be < 1500000000) end it "should return a date when given %Y-%m-%d" do result = scope.function_strftime(["%Y-%m-%d"]) - result.should =~ /^\d{4}-\d{2}-\d{2}$/ + expect(result).to match(/^\d{4}-\d{2}-\d{2}$/) end end diff --git a/spec/functions/strip_spec.rb b/spec/functions/strip_spec.rb index fccdd26..e228761 100755 --- a/spec/functions/strip_spec.rb +++ b/spec/functions/strip_spec.rb @@ -4,15 +4,15 @@ require 'spec_helper' describe "the strip function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("strip").should == "function_strip" + expect(Puppet::Parser::Functions.function("strip")).to eq("function_strip") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_strip([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_strip([]) }.to( raise_error(Puppet::ParseError)) end it "should strip a string" do result = scope.function_strip([" ab cd "]) - result.should(eq('ab cd')) + expect(result).to(eq('ab cd')) end end diff --git a/spec/functions/suffix_spec.rb b/spec/functions/suffix_spec.rb index 89ba3b8..c7783c6 100755 --- a/spec/functions/suffix_spec.rb +++ b/spec/functions/suffix_spec.rb @@ -22,6 +22,6 @@ describe "the suffix function" do it "returns a suffixed array" do result = scope.function_suffix([['a','b','c'], 'p']) - result.should(eq(['ap','bp','cp'])) + expect(result).to(eq(['ap','bp','cp'])) end end diff --git a/spec/functions/swapcase_spec.rb b/spec/functions/swapcase_spec.rb index 808b415..c6838ab 100755 --- a/spec/functions/swapcase_spec.rb +++ b/spec/functions/swapcase_spec.rb @@ -5,15 +5,15 @@ describe "the swapcase function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("swapcase").should == "function_swapcase" + expect(Puppet::Parser::Functions.function("swapcase")).to eq("function_swapcase") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_swapcase([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_swapcase([]) }.to( raise_error(Puppet::ParseError)) end it "should swapcase a string" do result = scope.function_swapcase(["aaBBccDD"]) - result.should(eq('AAbbCCdd')) + expect(result).to(eq('AAbbCCdd')) end end diff --git a/spec/functions/time_spec.rb b/spec/functions/time_spec.rb index e9fb76e..6e22515 100755 --- a/spec/functions/time_spec.rb +++ b/spec/functions/time_spec.rb @@ -5,25 +5,25 @@ describe "the time function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("time").should == "function_time" + expect(Puppet::Parser::Functions.function("time")).to eq("function_time") end it "should raise a ParseError if there is more than 2 arguments" do - lambda { scope.function_time(['','']) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_time(['','']) }.to( raise_error(Puppet::ParseError)) end it "should return a number" do result = scope.function_time([]) - result.should be_an(Integer) + expect(result).to be_an(Integer) end it "should be higher then when I wrote this test" do result = scope.function_time([]) - result.should(be > 1311953157) + expect(result).to(be > 1311953157) end it "should be lower then 1.5 trillion" do result = scope.function_time([]) - result.should(be < 1500000000) + expect(result).to(be < 1500000000) end end diff --git a/spec/functions/to_bytes_spec.rb b/spec/functions/to_bytes_spec.rb index d1ea4c8..68a1eb8 100755 --- a/spec/functions/to_bytes_spec.rb +++ b/spec/functions/to_bytes_spec.rb @@ -6,53 +6,53 @@ describe "the to_bytes function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("to_bytes").should == "function_to_bytes" + expect(Puppet::Parser::Functions.function("to_bytes")).to eq("function_to_bytes") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_to_bytes([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_to_bytes([]) }.to( raise_error(Puppet::ParseError)) end it "should convert kB to B" do result = scope.function_to_bytes(["4 kB"]) - result.should(eq(4096)) + expect(result).to(eq(4096)) end it "should work without B in unit" do result = scope.function_to_bytes(["4 k"]) - result.should(eq(4096)) + expect(result).to(eq(4096)) end it "should work without a space before unit" do result = scope.function_to_bytes(["4k"]) - result.should(eq(4096)) + expect(result).to(eq(4096)) end it "should work without a unit" do result = scope.function_to_bytes(["5678"]) - result.should(eq(5678)) + expect(result).to(eq(5678)) end it "should convert fractions" do result = scope.function_to_bytes(["1.5 kB"]) - result.should(eq(1536)) + expect(result).to(eq(1536)) end it "should convert scientific notation" do result = scope.function_to_bytes(["1.5e2 B"]) - result.should(eq(150)) + expect(result).to(eq(150)) end it "should do nothing with a positive number" do result = scope.function_to_bytes([5678]) - result.should(eq(5678)) + expect(result).to(eq(5678)) end it "should should raise a ParseError if input isn't a number" do - lambda { scope.function_to_bytes(["foo"]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_to_bytes(["foo"]) }.to( raise_error(Puppet::ParseError)) end it "should should raise a ParseError if prefix is unknown" do - lambda { scope.function_to_bytes(["5 uB"]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_to_bytes(["5 uB"]) }.to( raise_error(Puppet::ParseError)) end end diff --git a/spec/functions/type_spec.rb b/spec/functions/type_spec.rb index 8fec88f..9dfe9d7 100755 --- a/spec/functions/type_spec.rb +++ b/spec/functions/type_spec.rb @@ -4,40 +4,40 @@ require 'spec_helper' describe "the type function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("type").should == "function_type" + expect(Puppet::Parser::Functions.function("type")).to eq("function_type") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_type([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_type([]) }.to( raise_error(Puppet::ParseError)) end it "should return string when given a string" do result = scope.function_type(["aaabbbbcccc"]) - result.should(eq('string')) + expect(result).to(eq('string')) end it "should return array when given an array" do result = scope.function_type([["aaabbbbcccc","asdf"]]) - result.should(eq('array')) + expect(result).to(eq('array')) end it "should return hash when given a hash" do result = scope.function_type([{"a"=>1,"b"=>2}]) - result.should(eq('hash')) + expect(result).to(eq('hash')) end it "should return integer when given an integer" do result = scope.function_type(["1"]) - result.should(eq('integer')) + expect(result).to(eq('integer')) end it "should return float when given a float" do result = scope.function_type(["1.34"]) - result.should(eq('float')) + expect(result).to(eq('float')) end it "should return boolean when given a boolean" do result = scope.function_type([true]) - result.should(eq('boolean')) + expect(result).to(eq('boolean')) end end diff --git a/spec/functions/union_spec.rb b/spec/functions/union_spec.rb index 0d282ca..706f4cb 100755 --- a/spec/functions/union_spec.rb +++ b/spec/functions/union_spec.rb @@ -5,15 +5,15 @@ describe "the union function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("union").should == "function_union" + expect(Puppet::Parser::Functions.function("union")).to eq("function_union") end it "should raise a ParseError if there are fewer than 2 arguments" do - lambda { scope.function_union([]) }.should( raise_error(Puppet::ParseError) ) + expect { scope.function_union([]) }.to( raise_error(Puppet::ParseError) ) end it "should join two arrays together" do result = scope.function_union([["a","b","c"],["b","c","d"]]) - result.should(eq(["a","b","c","d"])) + expect(result).to(eq(["a","b","c","d"])) end end diff --git a/spec/functions/unique_spec.rb b/spec/functions/unique_spec.rb index 5d48d49..8ec1464 100755 --- a/spec/functions/unique_spec.rb +++ b/spec/functions/unique_spec.rb @@ -5,20 +5,20 @@ describe "the unique function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("unique").should == "function_unique" + expect(Puppet::Parser::Functions.function("unique")).to eq("function_unique") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_unique([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_unique([]) }.to( raise_error(Puppet::ParseError)) end it "should remove duplicate elements in a string" do result = scope.function_unique(["aabbc"]) - result.should(eq('abc')) + expect(result).to(eq('abc')) end it "should remove duplicate elements in an array" do result = scope.function_unique([["a","a","b","b","c"]]) - result.should(eq(['a','b','c'])) + expect(result).to(eq(['a','b','c'])) end end diff --git a/spec/functions/upcase_spec.rb b/spec/functions/upcase_spec.rb index 5db5513..78e55dd 100755 --- a/spec/functions/upcase_spec.rb +++ b/spec/functions/upcase_spec.rb @@ -5,20 +5,20 @@ describe "the upcase function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("upcase").should == "function_upcase" + expect(Puppet::Parser::Functions.function("upcase")).to eq("function_upcase") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_upcase([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_upcase([]) }.to( raise_error(Puppet::ParseError)) end it "should upcase a string" do result = scope.function_upcase(["abc"]) - result.should(eq('ABC')) + expect(result).to(eq('ABC')) end it "should do nothing if a string is already upcase" do result = scope.function_upcase(["ABC"]) - result.should(eq('ABC')) + expect(result).to(eq('ABC')) end end diff --git a/spec/functions/uriescape_spec.rb b/spec/functions/uriescape_spec.rb index 7211c88..c44e9c1 100755 --- a/spec/functions/uriescape_spec.rb +++ b/spec/functions/uriescape_spec.rb @@ -5,20 +5,20 @@ describe "the uriescape function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("uriescape").should == "function_uriescape" + expect(Puppet::Parser::Functions.function("uriescape")).to eq("function_uriescape") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_uriescape([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_uriescape([]) }.to( raise_error(Puppet::ParseError)) end it "should uriescape a string" do result = scope.function_uriescape([":/?#[]@!$&'()*+,;= \"{}"]) - result.should(eq(':/?%23[]@!$&\'()*+,;=%20%22%7B%7D')) + expect(result).to(eq(':/?%23[]@!$&\'()*+,;=%20%22%7B%7D')) end it "should do nothing if a string is already safe" do result = scope.function_uriescape(["ABCdef"]) - result.should(eq('ABCdef')) + expect(result).to(eq('ABCdef')) end end diff --git a/spec/functions/validate_slength_spec.rb b/spec/functions/validate_slength_spec.rb index 851835f..e23f61a 100755 --- a/spec/functions/validate_slength_spec.rb +++ b/spec/functions/validate_slength_spec.rb @@ -6,7 +6,7 @@ describe "the validate_slength function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("validate_slength").should == "function_validate_slength" + expect(Puppet::Parser::Functions.function("validate_slength")).to eq("function_validate_slength") end describe "validating the input argument types" do diff --git a/spec/functions/values_at_spec.rb b/spec/functions/values_at_spec.rb index 08e95a5..86e3c31 100755 --- a/spec/functions/values_at_spec.rb +++ b/spec/functions/values_at_spec.rb @@ -5,34 +5,34 @@ describe "the values_at function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("values_at").should == "function_values_at" + expect(Puppet::Parser::Functions.function("values_at")).to eq("function_values_at") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_values_at([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_values_at([]) }.to( raise_error(Puppet::ParseError)) end it "should raise a ParseError if you try to use a range where stop is greater then start" do - lambda { scope.function_values_at([['a','b'],["3-1"]]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_values_at([['a','b'],["3-1"]]) }.to( raise_error(Puppet::ParseError)) end it "should return a value at from an array" do result = scope.function_values_at([['a','b','c'],"1"]) - result.should(eq(['b'])) + expect(result).to(eq(['b'])) end it "should return a value at from an array when passed a range" do result = scope.function_values_at([['a','b','c'],"0-1"]) - result.should(eq(['a','b'])) + expect(result).to(eq(['a','b'])) end it "should return chosen values from an array when passed number of indexes" do result = scope.function_values_at([['a','b','c'],["0","2"]]) - result.should(eq(['a','c'])) + expect(result).to(eq(['a','c'])) end it "should return chosen values from an array when passed ranges and multiple indexes" do result = scope.function_values_at([['a','b','c','d','e','f','g'],["0","2","4-5"]]) - result.should(eq(['a','c','e','f'])) + expect(result).to(eq(['a','c','e','f'])) end end diff --git a/spec/functions/values_spec.rb b/spec/functions/values_spec.rb index 14ae417..08d21b0 100755 --- a/spec/functions/values_spec.rb +++ b/spec/functions/values_spec.rb @@ -5,27 +5,27 @@ describe "the values function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("values").should == "function_values" + expect(Puppet::Parser::Functions.function("values")).to eq("function_values") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_values([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_values([]) }.to( raise_error(Puppet::ParseError)) end it "should return values from a hash" do result = scope.function_values([{'a'=>'1','b'=>'2','c'=>'3'}]) # =~ is the RSpec::Matchers::MatchArray matcher. # A.K.A. "array with same elements" (multiset) matching - result.should =~ %w{ 1 2 3 } + expect(result).to match_array(%w{ 1 2 3 }) end it "should return a multiset" do result = scope.function_values([{'a'=>'1','b'=>'3','c'=>'3'}]) - result.should =~ %w{ 1 3 3 } - result.should_not =~ %w{ 1 3 } + expect(result).to match_array(%w{ 1 3 3 }) + expect(result).not_to match_array(%w{ 1 3 }) end it "should raise a ParseError unless a Hash is provided" do - lambda { scope.function_values([['a','b','c']]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_values([['a','b','c']]) }.to( raise_error(Puppet::ParseError)) end end diff --git a/spec/functions/zip_spec.rb b/spec/functions/zip_spec.rb index f45ab17..744bdd7 100755 --- a/spec/functions/zip_spec.rb +++ b/spec/functions/zip_spec.rb @@ -5,11 +5,11 @@ describe "the zip function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_zip([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_zip([]) }.to( raise_error(Puppet::ParseError)) end it "should be able to zip an array" do result = scope.function_zip([['1','2','3'],['4','5','6']]) - result.should(eq([["1", "4"], ["2", "5"], ["3", "6"]])) + expect(result).to(eq([["1", "4"], ["2", "5"], ["3", "6"]])) end end diff --git a/spec/unit/facter/facter_dot_d_spec.rb b/spec/unit/facter/facter_dot_d_spec.rb index 2fb72b2..0afadb2 100755 --- a/spec/unit/facter/facter_dot_d_spec.rb +++ b/spec/unit/facter/facter_dot_d_spec.rb @@ -13,7 +13,7 @@ describe Facter::Util::DotD do end it 'should return successfully' do - Facter.fact(:fake_fact).value.should == 'fake fact' + expect(Facter.fact(:fake_fact).value).to eq('fake fact') end end @@ -26,7 +26,7 @@ describe Facter::Util::DotD do end it 'should return successfully' do - Facter.fact(:foo).value.should == '1+1=2' + expect(Facter.fact(:foo).value).to eq('1+1=2') end end end diff --git a/spec/unit/facter/pe_version_spec.rb b/spec/unit/facter/pe_version_spec.rb index 931c6d4..4d0349e 100755 --- a/spec/unit/facter/pe_version_spec.rb +++ b/spec/unit/facter/pe_version_spec.rb @@ -26,23 +26,23 @@ describe "PE Version specs" do (major,minor,patch) = version.split(".") it "Should return true" do - Facter.fact(:is_pe).value.should == true + expect(Facter.fact(:is_pe).value).to eq(true) end it "Should have a version of #{version}" do - Facter.fact(:pe_version).value.should == version + expect(Facter.fact(:pe_version).value).to eq(version) end it "Should have a major version of #{major}" do - Facter.fact(:pe_major_version).value.should == major + expect(Facter.fact(:pe_major_version).value).to eq(major) end it "Should have a minor version of #{minor}" do - Facter.fact(:pe_minor_version).value.should == minor + expect(Facter.fact(:pe_minor_version).value).to eq(minor) end it "Should have a patch version of #{patch}" do - Facter.fact(:pe_patch_version).value.should == patch + expect(Facter.fact(:pe_patch_version).value).to eq(patch) end end end @@ -54,23 +54,23 @@ describe "PE Version specs" do end it "is_pe is false" do - Facter.fact(:is_pe).value.should == false + expect(Facter.fact(:is_pe).value).to eq(false) end it "pe_version is nil" do - Facter.fact(:pe_version).value.should be_nil + expect(Facter.fact(:pe_version).value).to be_nil end it "pe_major_version is nil" do - Facter.fact(:pe_major_version).value.should be_nil + expect(Facter.fact(:pe_major_version).value).to be_nil end it "pe_minor_version is nil" do - Facter.fact(:pe_minor_version).value.should be_nil + expect(Facter.fact(:pe_minor_version).value).to be_nil end it "Should have a patch version" do - Facter.fact(:pe_patch_version).value.should be_nil + expect(Facter.fact(:pe_patch_version).value).to be_nil end end end diff --git a/spec/unit/facter/root_home_spec.rb b/spec/unit/facter/root_home_spec.rb index 73eb3ea..98fe141 100755 --- a/spec/unit/facter/root_home_spec.rb +++ b/spec/unit/facter/root_home_spec.rb @@ -9,7 +9,7 @@ describe Facter::Util::RootHome do it "should return /" do Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent) - Facter::Util::RootHome.get_root_home.should == expected_root_home + expect(Facter::Util::RootHome.get_root_home).to eq(expected_root_home) end end context "linux" do @@ -18,7 +18,7 @@ describe Facter::Util::RootHome do it "should return /root" do Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent) - Facter::Util::RootHome.get_root_home.should == expected_root_home + expect(Facter::Util::RootHome.get_root_home).to eq(expected_root_home) end end context "windows" do @@ -26,7 +26,7 @@ describe Facter::Util::RootHome do Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(nil) end it "should be nil on windows" do - Facter::Util::RootHome.get_root_home.should be_nil + expect(Facter::Util::RootHome.get_root_home).to be_nil end end end @@ -45,7 +45,7 @@ describe 'root_home', :type => :fact do it "should return /var/root" do Facter::Util::Resolution.stubs(:exec).with("dscacheutil -q user -a name root").returns(sample_dscacheutil) - Facter.fact(:root_home).value.should == expected_root_home + expect(Facter.fact(:root_home).value).to eq(expected_root_home) end end diff --git a/spec/unit/facter/util/puppet_settings_spec.rb b/spec/unit/facter/util/puppet_settings_spec.rb index e77779b..c06137d 100755 --- a/spec/unit/facter/util/puppet_settings_spec.rb +++ b/spec/unit/facter/util/puppet_settings_spec.rb @@ -11,11 +11,11 @@ describe Facter::Util::PuppetSettings do end it 'should be nil' do - subject.with_puppet { Puppet[:vardir] }.should be_nil + expect(subject.with_puppet { Puppet[:vardir] }).to be_nil end it 'should not yield to the block' do Puppet.expects(:[]).never - subject.with_puppet { Puppet[:vardir] }.should be_nil + expect(subject.with_puppet { Puppet[:vardir] }).to be_nil end end context "With Puppet loaded" do @@ -29,7 +29,7 @@ describe Facter::Util::PuppetSettings do subject.with_puppet { Puppet[:vardir] } end it 'should return the nodes vardir' do - subject.with_puppet { Puppet[:vardir] }.should eq vardir + expect(subject.with_puppet { Puppet[:vardir] }).to eq vardir end end end diff --git a/spec/unit/puppet/parser/functions/bool2str_spec.rb b/spec/unit/puppet/parser/functions/bool2str_spec.rb index bed7e68..b878891 100755 --- a/spec/unit/puppet/parser/functions/bool2str_spec.rb +++ b/spec/unit/puppet/parser/functions/bool2str_spec.rb @@ -5,42 +5,42 @@ describe "the bool2str function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("bool2str").should == "function_bool2str" + expect(Puppet::Parser::Functions.function("bool2str")).to eq("function_bool2str") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_bool2str([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_bool2str([]) }.to( raise_error(Puppet::ParseError)) end it "should convert true to 'true'" do result = scope.function_bool2str([true]) - result.should(eq('true')) + expect(result).to(eq('true')) end it "should convert true to a string" do result = scope.function_bool2str([true]) - result.class.should(eq(String)) + expect(result.class).to(eq(String)) end it "should convert false to 'false'" do result = scope.function_bool2str([false]) - result.should(eq('false')) + expect(result).to(eq('false')) end it "should convert false to a string" do result = scope.function_bool2str([false]) - result.class.should(eq(String)) + expect(result.class).to(eq(String)) end it "should not accept a string" do - lambda { scope.function_bool2str(["false"]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_bool2str(["false"]) }.to( raise_error(Puppet::ParseError)) end it "should not accept a nil value" do - lambda { scope.function_bool2str([nil]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_bool2str([nil]) }.to( raise_error(Puppet::ParseError)) end it "should not accept an undef" do - lambda { scope.function_bool2str([:undef]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_bool2str([:undef]) }.to( raise_error(Puppet::ParseError)) end end diff --git a/spec/unit/puppet/parser/functions/camelcase_spec.rb b/spec/unit/puppet/parser/functions/camelcase_spec.rb index 3b1f1d0..70382ad 100755 --- a/spec/unit/puppet/parser/functions/camelcase_spec.rb +++ b/spec/unit/puppet/parser/functions/camelcase_spec.rb @@ -5,20 +5,20 @@ describe "the camelcase function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("camelcase").should == "function_camelcase" + expect(Puppet::Parser::Functions.function("camelcase")).to eq("function_camelcase") end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_camelcase([]) }.should( raise_error(Puppet::ParseError)) + expect { scope.function_camelcase([]) }.to( raise_error(Puppet::ParseError)) end it "should capitalize the beginning of a normal string" do result = scope.function_camelcase(["abc"]) - result.should(eq("Abc")) + expect(result).to(eq("Abc")) end it "should camelcase an underscore-delimited string" do result = scope.function_camelcase(["aa_bb_cc"]) - result.should(eq("AaBbCc")) + expect(result).to(eq("AaBbCc")) end end diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb index a016b68..d2a129c 100755 --- a/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb @@ -23,17 +23,17 @@ describe provider_class do File.open(tmpfile, 'w') do |fh| fh.write('foo') end - provider.exists?.should be_true + expect(provider.exists?).to be_truthy end it 'should detect if the line does not exist in the file' do File.open(tmpfile, 'w') do |fh| fh.write('foo1') end - provider.exists?.should be_nil + expect(provider.exists?).to be_nil end it 'should append to an existing file when creating' do provider.create - File.read(tmpfile).chomp.should == 'foo' + expect(File.read(tmpfile).chomp).to eq('foo') end end @@ -61,9 +61,9 @@ describe provider_class do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz") end - @provider.exists?.should be_nil + expect(@provider.exists?).to be_nil expect { @provider.create }.to raise_error(Puppet::Error, /More than one line.*matches/) - File.read(@tmpfile).should eql("foo1\nfoo=blah\nfoo2\nfoo=baz") + expect(File.read(@tmpfile)).to eql("foo1\nfoo=blah\nfoo2\nfoo=baz") end it 'should replace all lines that matches' do @@ -80,9 +80,9 @@ describe provider_class do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz") end - @provider.exists?.should be_nil + expect(@provider.exists?).to be_nil @provider.create - File.read(@tmpfile).chomp.should eql("foo1\nfoo = bar\nfoo2\nfoo = bar") + expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2\nfoo = bar") end it 'should raise an error with invalid values' do @@ -103,25 +103,25 @@ describe provider_class do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo=blah\nfoo2") end - @provider.exists?.should be_nil + expect(@provider.exists?).to be_nil @provider.create - File.read(@tmpfile).chomp.should eql("foo1\nfoo = bar\nfoo2") + expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") end it 'should add a new line if no lines match' do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo2") end - @provider.exists?.should be_nil + expect(@provider.exists?).to be_nil @provider.create - File.read(@tmpfile).should eql("foo1\nfoo2\nfoo = bar\n") + expect(File.read(@tmpfile)).to eql("foo1\nfoo2\nfoo = bar\n") end it 'should do nothing if the exact line already exists' do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo = bar\nfoo2") end - @provider.exists?.should be_true + expect(@provider.exists?).to be_truthy @provider.create - File.read(@tmpfile).chomp.should eql("foo1\nfoo = bar\nfoo2") + expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") end end @@ -150,7 +150,7 @@ describe provider_class do it 'inserts the specified line after the line matching the "after" expression' do provider.create - File.read(@tmpfile).chomp.should eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo = baz") + expect(File.read(@tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo = baz") end end @@ -179,7 +179,7 @@ describe provider_class do it 'appends the specified line to the file' do provider.create - File.read(@tmpfile).should eq(content << resource[:line] << "\n") + expect(File.read(@tmpfile)).to eq(content << resource[:line] << "\n") end end end @@ -203,7 +203,7 @@ describe provider_class do fh.write("foo1\nfoo\nfoo2") end @provider.destroy - File.read(@tmpfile).should eql("foo1\nfoo2") + expect(File.read(@tmpfile)).to eql("foo1\nfoo2") end it 'should remove the line without touching the last new line' do @@ -211,7 +211,7 @@ describe provider_class do fh.write("foo1\nfoo\nfoo2\n") end @provider.destroy - File.read(@tmpfile).should eql("foo1\nfoo2\n") + expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n") end it 'should remove any occurence of the line' do @@ -219,7 +219,7 @@ describe provider_class do fh.write("foo1\nfoo\nfoo2\nfoo\nfoo") end @provider.destroy - File.read(@tmpfile).should eql("foo1\nfoo2\n") + expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n") end end end diff --git a/spec/unit/puppet/type/anchor_spec.rb b/spec/unit/puppet/type/anchor_spec.rb index f92065f..c738a27 100755 --- a/spec/unit/puppet/type/anchor_spec.rb +++ b/spec/unit/puppet/type/anchor_spec.rb @@ -6,6 +6,6 @@ anchor = Puppet::Type.type(:anchor).new(:name => "ntp::begin") describe anchor do it "should stringify normally" do - anchor.to_s.should == "Anchor[ntp::begin]" + expect(anchor.to_s).to eq("Anchor[ntp::begin]") end end diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index ab5b81b..9ef49ef 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -7,13 +7,13 @@ describe Puppet::Type.type(:file_line) do end it 'should accept a line and path' do file_line[:line] = 'my_line' - file_line[:line].should == 'my_line' + expect(file_line[:line]).to eq('my_line') file_line[:path] = '/my/path' - file_line[:path].should == '/my/path' + expect(file_line[:path]).to eq('/my/path') end it 'should accept a match regex' do file_line[:match] = '^foo.*$' - file_line[:match].should == '^foo.*$' + expect(file_line[:match]).to eq('^foo.*$') end it 'should not accept a match regex that does not match the specified line' do expect { @@ -35,7 +35,7 @@ describe Puppet::Type.type(:file_line) do end it 'should accept posix filenames' do file_line[:path] = '/tmp/path' - file_line[:path].should == '/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/) @@ -47,7 +47,7 @@ describe Puppet::Type.type(:file_line) do expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, /Both line and path are required attributes/) end it 'should default to ensure => present' do - file_line[:ensure].should eq :present + expect(file_line[:ensure]).to eq :present end it "should autorequire the file it manages" do @@ -59,12 +59,12 @@ describe Puppet::Type.type(:file_line) do relationship = file_line.autorequire.find do |rel| (rel.source.to_s == "File[/tmp/path]") and (rel.target.to_s == file_line.to_s) end - relationship.should be_a Puppet::Relationship + expect(relationship).to be_a Puppet::Relationship end it "should not autorequire the file it manages if it is not managed" do catalog = Puppet::Resource::Catalog.new catalog.add_resource file_line - file_line.autorequire.should be_empty + expect(file_line.autorequire).to be_empty end end |