Skip to content

Commit ffe21fc

Browse files
author
Morgan Haskel
committed
Merge pull request redhat-openstack#268 from apenney/rspec3
Rspec3 changes
2 parents f9f6e92 + 6287a20 commit ffe21fc

92 files changed

Lines changed: 510 additions & 510 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

spec/functions/abs_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
77

88
it "should exist" do
9-
Puppet::Parser::Functions.function("abs").should == "function_abs"
9+
expect(Puppet::Parser::Functions.function("abs")).to eq("function_abs")
1010
end
1111

1212
it "should raise a ParseError if there is less than 1 arguments" do
13-
lambda { scope.function_abs([]) }.should( raise_error(Puppet::ParseError))
13+
expect { scope.function_abs([]) }.to( raise_error(Puppet::ParseError))
1414
end
1515

1616
it "should convert a negative number into a positive" do
1717
result = scope.function_abs(["-34"])
18-
result.should(eq(34))
18+
expect(result).to(eq(34))
1919
end
2020

2121
it "should do nothing with a positive number" do
2222
result = scope.function_abs(["5678"])
23-
result.should(eq(5678))
23+
expect(result).to(eq(5678))
2424
end
2525
end

spec/functions/any2array_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,51 @@
55
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
66

77
it "should exist" do
8-
Puppet::Parser::Functions.function("any2array").should == "function_any2array"
8+
expect(Puppet::Parser::Functions.function("any2array")).to eq("function_any2array")
99
end
1010

1111
it "should return an empty array if there is less than 1 argument" do
1212
result = scope.function_any2array([])
13-
result.should(eq([]))
13+
expect(result).to(eq([]))
1414
end
1515

1616
it "should convert boolean true to [ true ] " do
1717
result = scope.function_any2array([true])
18-
result.should(eq([true]))
18+
expect(result).to(eq([true]))
1919
end
2020

2121
it "should convert one object to [object]" do
2222
result = scope.function_any2array(['one'])
23-
result.should(eq(['one']))
23+
expect(result).to(eq(['one']))
2424
end
2525

2626
it "should convert multiple objects to [objects]" do
2727
result = scope.function_any2array(['one', 'two'])
28-
result.should(eq(['one', 'two']))
28+
expect(result).to(eq(['one', 'two']))
2929
end
3030

3131
it "should return empty array it was called with" do
3232
result = scope.function_any2array([[]])
33-
result.should(eq([]))
33+
expect(result).to(eq([]))
3434
end
3535

3636
it "should return one-member array it was called with" do
3737
result = scope.function_any2array([['string']])
38-
result.should(eq(['string']))
38+
expect(result).to(eq(['string']))
3939
end
4040

4141
it "should return multi-member array it was called with" do
4242
result = scope.function_any2array([['one', 'two']])
43-
result.should(eq(['one', 'two']))
43+
expect(result).to(eq(['one', 'two']))
4444
end
4545

4646
it "should return members of a hash it was called with" do
4747
result = scope.function_any2array([{ 'key' => 'value' }])
48-
result.should(eq(['key', 'value']))
48+
expect(result).to(eq(['key', 'value']))
4949
end
5050

5151
it "should return an empty array if it was called with an empty hash" do
5252
result = scope.function_any2array([{ }])
53-
result.should(eq([]))
53+
expect(result).to(eq([]))
5454
end
5555
end

spec/functions/base64_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
77

88
it "should exist" do
9-
Puppet::Parser::Functions.function("base64").should == "function_base64"
9+
expect(Puppet::Parser::Functions.function("base64")).to eq("function_base64")
1010
end
1111

1212
it "should raise a ParseError if there are other than 2 arguments" do
@@ -25,10 +25,10 @@
2525

2626
it "should encode a encoded string" do
2727
result = scope.function_base64(["encode",'thestring'])
28-
result.should =~ /\AdGhlc3RyaW5n\n\Z/
28+
expect(result).to match(/\AdGhlc3RyaW5n\n\Z/)
2929
end
3030
it "should decode a base64 encoded string" do
3131
result = scope.function_base64(["decode",'dGhlc3RyaW5n'])
32-
result.should == 'thestring'
32+
expect(result).to eq('thestring')
3333
end
3434
end

spec/functions/bool2num_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
66

77
it "should exist" do
8-
Puppet::Parser::Functions.function("bool2num").should == "function_bool2num"
8+
expect(Puppet::Parser::Functions.function("bool2num")).to eq("function_bool2num")
99
end
1010

1111
it "should raise a ParseError if there is less than 1 arguments" do
12-
lambda { scope.function_bool2num([]) }.should( raise_error(Puppet::ParseError))
12+
expect { scope.function_bool2num([]) }.to( raise_error(Puppet::ParseError))
1313
end
1414

1515
it "should convert true to 1" do
1616
result = scope.function_bool2num([true])
17-
result.should(eq(1))
17+
expect(result).to(eq(1))
1818
end
1919

2020
it "should convert false to 0" do
2121
result = scope.function_bool2num([false])
22-
result.should(eq(0))
22+
expect(result).to(eq(0))
2323
end
2424
end

spec/functions/capitalize_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
66

77
it "should exist" do
8-
Puppet::Parser::Functions.function("capitalize").should == "function_capitalize"
8+
expect(Puppet::Parser::Functions.function("capitalize")).to eq("function_capitalize")
99
end
1010

1111
it "should raise a ParseError if there is less than 1 arguments" do
12-
lambda { scope.function_capitalize([]) }.should( raise_error(Puppet::ParseError))
12+
expect { scope.function_capitalize([]) }.to( raise_error(Puppet::ParseError))
1313
end
1414

1515
it "should capitalize the beginning of a string" do
1616
result = scope.function_capitalize(["abc"])
17-
result.should(eq("Abc"))
17+
expect(result).to(eq("Abc"))
1818
end
1919
end

spec/functions/chomp_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
66

77
it "should exist" do
8-
Puppet::Parser::Functions.function("chomp").should == "function_chomp"
8+
expect(Puppet::Parser::Functions.function("chomp")).to eq("function_chomp")
99
end
1010

1111
it "should raise a ParseError if there is less than 1 arguments" do
12-
lambda { scope.function_chomp([]) }.should( raise_error(Puppet::ParseError))
12+
expect { scope.function_chomp([]) }.to( raise_error(Puppet::ParseError))
1313
end
1414

1515
it "should chomp the end of a string" do
1616
result = scope.function_chomp(["abc\n"])
17-
result.should(eq("abc"))
17+
expect(result).to(eq("abc"))
1818
end
1919
end

spec/functions/chop_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
66

77
it "should exist" do
8-
Puppet::Parser::Functions.function("chop").should == "function_chop"
8+
expect(Puppet::Parser::Functions.function("chop")).to eq("function_chop")
99
end
1010

1111
it "should raise a ParseError if there is less than 1 arguments" do
12-
lambda { scope.function_chop([]) }.should( raise_error(Puppet::ParseError))
12+
expect { scope.function_chop([]) }.to( raise_error(Puppet::ParseError))
1313
end
1414

1515
it "should chop the end of a string" do
1616
result = scope.function_chop(["asdf\n"])
17-
result.should(eq("asdf"))
17+
expect(result).to(eq("asdf"))
1818
end
1919
end

spec/functions/concat_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
66

77
it "should raise a ParseError if the client does not provide two arguments" do
8-
lambda { scope.function_concat([]) }.should(raise_error(Puppet::ParseError))
8+
expect { scope.function_concat([]) }.to(raise_error(Puppet::ParseError))
99
end
1010

1111
it "should raise a ParseError if the first parameter is not an array" do
12-
lambda { scope.function_concat([1, []])}.should(raise_error(Puppet::ParseError))
12+
expect { scope.function_concat([1, []])}.to(raise_error(Puppet::ParseError))
1313
end
1414

1515
it "should be able to concat an array" do
1616
result = scope.function_concat([['1','2','3'],['4','5','6']])
17-
result.should(eq(['1','2','3','4','5','6']))
17+
expect(result).to(eq(['1','2','3','4','5','6']))
1818
end
1919

2020
it "should be able to concat a primitive to an array" do
2121
result = scope.function_concat([['1','2','3'],'4'])
22-
result.should(eq(['1','2','3','4']))
22+
expect(result).to(eq(['1','2','3','4']))
2323
end
2424

2525
it "should not accidentally flatten nested arrays" do
2626
result = scope.function_concat([['1','2','3'],[['4','5'],'6']])
27-
result.should(eq(['1','2','3',['4','5'],'6']))
27+
expect(result).to(eq(['1','2','3',['4','5'],'6']))
2828
end
2929

3030
end

spec/functions/count_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
77

88
it "should exist" do
9-
Puppet::Parser::Functions.function("count").should == "function_count"
9+
expect(Puppet::Parser::Functions.function("count")).to eq("function_count")
1010
end
1111

1212
it "should raise a ArgumentError if there is more than 2 arguments" do
13-
lambda { scope.function_count(['foo', 'bar', 'baz']) }.should( raise_error(ArgumentError))
13+
expect { scope.function_count(['foo', 'bar', 'baz']) }.to( raise_error(ArgumentError))
1414
end
1515

1616
it "should be able to count arrays" do
17-
scope.function_count([["1","2","3"]]).should(eq(3))
17+
expect(scope.function_count([["1","2","3"]])).to(eq(3))
1818
end
1919

2020
it "should be able to count matching elements in arrays" do
21-
scope.function_count([["1", "2", "2"], "2"]).should(eq(2))
21+
expect(scope.function_count([["1", "2", "2"], "2"])).to(eq(2))
2222
end
2323

2424
it "should not count nil or empty strings" do
25-
scope.function_count([["foo","bar",nil,""]]).should(eq(2))
25+
expect(scope.function_count([["foo","bar",nil,""]])).to(eq(2))
2626
end
2727

2828
it 'does not count an undefined hash key or an out of bound array index (which are both :undef)' do

spec/functions/deep_merge_spec.rb

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
describe 'when calling deep_merge from puppet' do
99
it "should not compile when no arguments are passed" do
10-
pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
10+
skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
1111
Puppet[:code] = '$x = deep_merge()'
1212
expect {
1313
scope.compiler.compile
1414
}.to raise_error(Puppet::ParseError, /wrong number of arguments/)
1515
end
1616

1717
it "should not compile when 1 argument is passed" do
18-
pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
18+
skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
1919
Puppet[:code] = "$my_hash={'one' => 1}\n$x = deep_merge($my_hash)"
2020
expect {
2121
scope.compiler.compile
@@ -35,71 +35,71 @@
3535

3636
it 'should be able to deep_merge two hashes' do
3737
new_hash = scope.function_deep_merge([{'one' => '1', 'two' => '1'}, {'two' => '2', 'three' => '2'}])
38-
new_hash['one'].should == '1'
39-
new_hash['two'].should == '2'
40-
new_hash['three'].should == '2'
38+
expect(new_hash['one']).to eq('1')
39+
expect(new_hash['two']).to eq('2')
40+
expect(new_hash['three']).to eq('2')
4141
end
4242

4343
it 'should deep_merge multiple hashes' do
4444
hash = scope.function_deep_merge([{'one' => 1}, {'one' => '2'}, {'one' => '3'}])
45-
hash['one'].should == '3'
45+
expect(hash['one']).to eq('3')
4646
end
4747

4848
it 'should accept empty hashes' do
49-
scope.function_deep_merge([{},{},{}]).should == {}
49+
expect(scope.function_deep_merge([{},{},{}])).to eq({})
5050
end
5151

5252
it 'should deep_merge subhashes' do
5353
hash = scope.function_deep_merge([{'one' => 1}, {'two' => 2, 'three' => { 'four' => 4 } }])
54-
hash['one'].should == 1
55-
hash['two'].should == 2
56-
hash['three'].should == { 'four' => 4 }
54+
expect(hash['one']).to eq(1)
55+
expect(hash['two']).to eq(2)
56+
expect(hash['three']).to eq({ 'four' => 4 })
5757
end
5858

5959
it 'should append to subhashes' do
6060
hash = scope.function_deep_merge([{'one' => { 'two' => 2 } }, { 'one' => { 'three' => 3 } }])
61-
hash['one'].should == { 'two' => 2, 'three' => 3 }
61+
expect(hash['one']).to eq({ 'two' => 2, 'three' => 3 })
6262
end
6363

6464
it 'should append to subhashes 2' do
6565
hash = scope.function_deep_merge([{'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }, {'two' => 'dos', 'three' => { 'five' => 5 } }])
66-
hash['one'].should == 1
67-
hash['two'].should == 'dos'
68-
hash['three'].should == { 'four' => 4, 'five' => 5 }
66+
expect(hash['one']).to eq(1)
67+
expect(hash['two']).to eq('dos')
68+
expect(hash['three']).to eq({ 'four' => 4, 'five' => 5 })
6969
end
7070

7171
it 'should append to subhashes 3' do
7272
hash = scope.function_deep_merge([{ 'key1' => { 'a' => 1, 'b' => 2 }, 'key2' => { 'c' => 3 } }, { 'key1' => { 'b' => 99 } }])
73-
hash['key1'].should == { 'a' => 1, 'b' => 99 }
74-
hash['key2'].should == { 'c' => 3 }
73+
expect(hash['key1']).to eq({ 'a' => 1, 'b' => 99 })
74+
expect(hash['key2']).to eq({ 'c' => 3 })
7575
end
7676

7777
it 'should not change the original hashes' do
7878
hash1 = {'one' => { 'two' => 2 } }
7979
hash2 = { 'one' => { 'three' => 3 } }
8080
hash = scope.function_deep_merge([hash1, hash2])
81-
hash1.should == {'one' => { 'two' => 2 } }
82-
hash2.should == { 'one' => { 'three' => 3 } }
83-
hash['one'].should == { 'two' => 2, 'three' => 3 }
81+
expect(hash1).to eq({'one' => { 'two' => 2 } })
82+
expect(hash2).to eq({ 'one' => { 'three' => 3 } })
83+
expect(hash['one']).to eq({ 'two' => 2, 'three' => 3 })
8484
end
8585

8686
it 'should not change the original hashes 2' do
8787
hash1 = {'one' => { 'two' => [1,2] } }
8888
hash2 = { 'one' => { 'three' => 3 } }
8989
hash = scope.function_deep_merge([hash1, hash2])
90-
hash1.should == {'one' => { 'two' => [1,2] } }
91-
hash2.should == { 'one' => { 'three' => 3 } }
92-
hash['one'].should == { 'two' => [1,2], 'three' => 3 }
90+
expect(hash1).to eq({'one' => { 'two' => [1,2] } })
91+
expect(hash2).to eq({ 'one' => { 'three' => 3 } })
92+
expect(hash['one']).to eq({ 'two' => [1,2], 'three' => 3 })
9393
end
9494

9595
it 'should not change the original hashes 3' do
9696
hash1 = {'one' => { 'two' => [1,2, {'two' => 2} ] } }
9797
hash2 = { 'one' => { 'three' => 3 } }
9898
hash = scope.function_deep_merge([hash1, hash2])
99-
hash1.should == {'one' => { 'two' => [1,2, {'two' => 2}] } }
100-
hash2.should == { 'one' => { 'three' => 3 } }
101-
hash['one'].should == { 'two' => [1,2, {'two' => 2} ], 'three' => 3 }
102-
hash['one']['two'].should == [1,2, {'two' => 2}]
99+
expect(hash1).to eq({'one' => { 'two' => [1,2, {'two' => 2}] } })
100+
expect(hash2).to eq({ 'one' => { 'three' => 3 } })
101+
expect(hash['one']).to eq({ 'two' => [1,2, {'two' => 2} ], 'three' => 3 })
102+
expect(hash['one']['two']).to eq([1,2, {'two' => 2}])
103103
end
104104
end
105105
end

0 commit comments

Comments
 (0)