Skip to content

Commit d65d235

Browse files
author
Ashley Penney
committed
Convert specs to RSpec 2.99.0 syntax with Transpec
This conversion is done by Transpec 2.2.1 with the following command: transpec spec/unit * 53 conversions from: obj.should to: expect(obj).to * 19 conversions from: == expected to: eq(expected) * 5 conversions from: lambda { }.should to: expect { }.to * 2 conversions from: be_true to: be_truthy For more details: https://github.com/yujinakayama/transpec#supported-conversions
1 parent f9f6e92 commit d65d235

9 files changed

Lines changed: 58 additions & 58 deletions

File tree

spec/unit/facter/facter_dot_d_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
end
1414

1515
it 'should return successfully' do
16-
Facter.fact(:fake_fact).value.should == 'fake fact'
16+
expect(Facter.fact(:fake_fact).value).to eq('fake fact')
1717
end
1818
end
1919

@@ -26,7 +26,7 @@
2626
end
2727

2828
it 'should return successfully' do
29-
Facter.fact(:foo).value.should == '1+1=2'
29+
expect(Facter.fact(:foo).value).to eq('1+1=2')
3030
end
3131
end
3232
end

spec/unit/facter/pe_version_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@
2626
(major,minor,patch) = version.split(".")
2727

2828
it "Should return true" do
29-
Facter.fact(:is_pe).value.should == true
29+
expect(Facter.fact(:is_pe).value).to eq(true)
3030
end
3131

3232
it "Should have a version of #{version}" do
33-
Facter.fact(:pe_version).value.should == version
33+
expect(Facter.fact(:pe_version).value).to eq(version)
3434
end
3535

3636
it "Should have a major version of #{major}" do
37-
Facter.fact(:pe_major_version).value.should == major
37+
expect(Facter.fact(:pe_major_version).value).to eq(major)
3838
end
3939

4040
it "Should have a minor version of #{minor}" do
41-
Facter.fact(:pe_minor_version).value.should == minor
41+
expect(Facter.fact(:pe_minor_version).value).to eq(minor)
4242
end
4343

4444
it "Should have a patch version of #{patch}" do
45-
Facter.fact(:pe_patch_version).value.should == patch
45+
expect(Facter.fact(:pe_patch_version).value).to eq(patch)
4646
end
4747
end
4848
end
@@ -54,23 +54,23 @@
5454
end
5555

5656
it "is_pe is false" do
57-
Facter.fact(:is_pe).value.should == false
57+
expect(Facter.fact(:is_pe).value).to eq(false)
5858
end
5959

6060
it "pe_version is nil" do
61-
Facter.fact(:pe_version).value.should be_nil
61+
expect(Facter.fact(:pe_version).value).to be_nil
6262
end
6363

6464
it "pe_major_version is nil" do
65-
Facter.fact(:pe_major_version).value.should be_nil
65+
expect(Facter.fact(:pe_major_version).value).to be_nil
6666
end
6767

6868
it "pe_minor_version is nil" do
69-
Facter.fact(:pe_minor_version).value.should be_nil
69+
expect(Facter.fact(:pe_minor_version).value).to be_nil
7070
end
7171

7272
it "Should have a patch version" do
73-
Facter.fact(:pe_patch_version).value.should be_nil
73+
expect(Facter.fact(:pe_patch_version).value).to be_nil
7474
end
7575
end
7676
end

spec/unit/facter/root_home_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
it "should return /" do
1111
Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
12-
Facter::Util::RootHome.get_root_home.should == expected_root_home
12+
expect(Facter::Util::RootHome.get_root_home).to eq(expected_root_home)
1313
end
1414
end
1515
context "linux" do
@@ -18,15 +18,15 @@
1818

1919
it "should return /root" do
2020
Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
21-
Facter::Util::RootHome.get_root_home.should == expected_root_home
21+
expect(Facter::Util::RootHome.get_root_home).to eq(expected_root_home)
2222
end
2323
end
2424
context "windows" do
2525
before :each do
2626
Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(nil)
2727
end
2828
it "should be nil on windows" do
29-
Facter::Util::RootHome.get_root_home.should be_nil
29+
expect(Facter::Util::RootHome.get_root_home).to be_nil
3030
end
3131
end
3232
end
@@ -45,7 +45,7 @@
4545

4646
it "should return /var/root" do
4747
Facter::Util::Resolution.stubs(:exec).with("dscacheutil -q user -a name root").returns(sample_dscacheutil)
48-
Facter.fact(:root_home).value.should == expected_root_home
48+
expect(Facter.fact(:root_home).value).to eq(expected_root_home)
4949
end
5050
end
5151

spec/unit/facter/util/puppet_settings_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
end
1212

1313
it 'should be nil' do
14-
subject.with_puppet { Puppet[:vardir] }.should be_nil
14+
expect(subject.with_puppet { Puppet[:vardir] }).to be_nil
1515
end
1616
it 'should not yield to the block' do
1717
Puppet.expects(:[]).never
18-
subject.with_puppet { Puppet[:vardir] }.should be_nil
18+
expect(subject.with_puppet { Puppet[:vardir] }).to be_nil
1919
end
2020
end
2121
context "With Puppet loaded" do
@@ -29,7 +29,7 @@ module Puppet; end
2929
subject.with_puppet { Puppet[:vardir] }
3030
end
3131
it 'should return the nodes vardir' do
32-
subject.with_puppet { Puppet[:vardir] }.should eq vardir
32+
expect(subject.with_puppet { Puppet[:vardir] }).to eq vardir
3333
end
3434
end
3535
end

spec/unit/puppet/parser/functions/bool2str_spec.rb

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

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

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

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

2020
it "should convert true to a string" do
2121
result = scope.function_bool2str([true])
22-
result.class.should(eq(String))
22+
expect(result.class).to(eq(String))
2323
end
2424

2525
it "should convert false to 'false'" do
2626
result = scope.function_bool2str([false])
27-
result.should(eq('false'))
27+
expect(result).to(eq('false'))
2828
end
2929

3030
it "should convert false to a string" do
3131
result = scope.function_bool2str([false])
32-
result.class.should(eq(String))
32+
expect(result.class).to(eq(String))
3333
end
3434

3535
it "should not accept a string" do
36-
lambda { scope.function_bool2str(["false"]) }.should( raise_error(Puppet::ParseError))
36+
expect { scope.function_bool2str(["false"]) }.to( raise_error(Puppet::ParseError))
3737
end
3838

3939
it "should not accept a nil value" do
40-
lambda { scope.function_bool2str([nil]) }.should( raise_error(Puppet::ParseError))
40+
expect { scope.function_bool2str([nil]) }.to( raise_error(Puppet::ParseError))
4141
end
4242

4343
it "should not accept an undef" do
44-
lambda { scope.function_bool2str([:undef]) }.should( raise_error(Puppet::ParseError))
44+
expect { scope.function_bool2str([:undef]) }.to( raise_error(Puppet::ParseError))
4545
end
4646
end

spec/unit/puppet/parser/functions/camelcase_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("camelcase").should == "function_camelcase"
8+
expect(Puppet::Parser::Functions.function("camelcase")).to eq("function_camelcase")
99
end
1010

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

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

2020
it "should camelcase an underscore-delimited string" do
2121
result = scope.function_camelcase(["aa_bb_cc"])
22-
result.should(eq("AaBbCc"))
22+
expect(result).to(eq("AaBbCc"))
2323
end
2424
end

spec/unit/puppet/provider/file_line/ruby_spec.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323
File.open(tmpfile, 'w') do |fh|
2424
fh.write('foo')
2525
end
26-
provider.exists?.should be_true
26+
expect(provider.exists?).to be_truthy
2727
end
2828
it 'should detect if the line does not exist in the file' do
2929
File.open(tmpfile, 'w') do |fh|
3030
fh.write('foo1')
3131
end
32-
provider.exists?.should be_nil
32+
expect(provider.exists?).to be_nil
3333
end
3434
it 'should append to an existing file when creating' do
3535
provider.create
36-
File.read(tmpfile).chomp.should == 'foo'
36+
expect(File.read(tmpfile).chomp).to eq('foo')
3737
end
3838
end
3939

@@ -61,9 +61,9 @@
6161
File.open(@tmpfile, 'w') do |fh|
6262
fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz")
6363
end
64-
@provider.exists?.should be_nil
64+
expect(@provider.exists?).to be_nil
6565
expect { @provider.create }.to raise_error(Puppet::Error, /More than one line.*matches/)
66-
File.read(@tmpfile).should eql("foo1\nfoo=blah\nfoo2\nfoo=baz")
66+
expect(File.read(@tmpfile)).to eql("foo1\nfoo=blah\nfoo2\nfoo=baz")
6767
end
6868

6969
it 'should replace all lines that matches' do
@@ -80,9 +80,9 @@
8080
File.open(@tmpfile, 'w') do |fh|
8181
fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz")
8282
end
83-
@provider.exists?.should be_nil
83+
expect(@provider.exists?).to be_nil
8484
@provider.create
85-
File.read(@tmpfile).chomp.should eql("foo1\nfoo = bar\nfoo2\nfoo = bar")
85+
expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2\nfoo = bar")
8686
end
8787

8888
it 'should raise an error with invalid values' do
@@ -103,25 +103,25 @@
103103
File.open(@tmpfile, 'w') do |fh|
104104
fh.write("foo1\nfoo=blah\nfoo2")
105105
end
106-
@provider.exists?.should be_nil
106+
expect(@provider.exists?).to be_nil
107107
@provider.create
108-
File.read(@tmpfile).chomp.should eql("foo1\nfoo = bar\nfoo2")
108+
expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2")
109109
end
110110
it 'should add a new line if no lines match' do
111111
File.open(@tmpfile, 'w') do |fh|
112112
fh.write("foo1\nfoo2")
113113
end
114-
@provider.exists?.should be_nil
114+
expect(@provider.exists?).to be_nil
115115
@provider.create
116-
File.read(@tmpfile).should eql("foo1\nfoo2\nfoo = bar\n")
116+
expect(File.read(@tmpfile)).to eql("foo1\nfoo2\nfoo = bar\n")
117117
end
118118
it 'should do nothing if the exact line already exists' do
119119
File.open(@tmpfile, 'w') do |fh|
120120
fh.write("foo1\nfoo = bar\nfoo2")
121121
end
122-
@provider.exists?.should be_true
122+
expect(@provider.exists?).to be_truthy
123123
@provider.create
124-
File.read(@tmpfile).chomp.should eql("foo1\nfoo = bar\nfoo2")
124+
expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2")
125125
end
126126
end
127127

@@ -150,7 +150,7 @@
150150

151151
it 'inserts the specified line after the line matching the "after" expression' do
152152
provider.create
153-
File.read(@tmpfile).chomp.should eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo = baz")
153+
expect(File.read(@tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo = baz")
154154
end
155155
end
156156

@@ -179,7 +179,7 @@
179179

180180
it 'appends the specified line to the file' do
181181
provider.create
182-
File.read(@tmpfile).should eq(content << resource[:line] << "\n")
182+
expect(File.read(@tmpfile)).to eq(content << resource[:line] << "\n")
183183
end
184184
end
185185
end
@@ -203,23 +203,23 @@
203203
fh.write("foo1\nfoo\nfoo2")
204204
end
205205
@provider.destroy
206-
File.read(@tmpfile).should eql("foo1\nfoo2")
206+
expect(File.read(@tmpfile)).to eql("foo1\nfoo2")
207207
end
208208

209209
it 'should remove the line without touching the last new line' do
210210
File.open(@tmpfile, 'w') do |fh|
211211
fh.write("foo1\nfoo\nfoo2\n")
212212
end
213213
@provider.destroy
214-
File.read(@tmpfile).should eql("foo1\nfoo2\n")
214+
expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n")
215215
end
216216

217217
it 'should remove any occurence of the line' do
218218
File.open(@tmpfile, 'w') do |fh|
219219
fh.write("foo1\nfoo\nfoo2\nfoo\nfoo")
220220
end
221221
@provider.destroy
222-
File.read(@tmpfile).should eql("foo1\nfoo2\n")
222+
expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n")
223223
end
224224
end
225225
end

spec/unit/puppet/type/anchor_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
describe anchor do
88
it "should stringify normally" do
9-
anchor.to_s.should == "Anchor[ntp::begin]"
9+
expect(anchor.to_s).to eq("Anchor[ntp::begin]")
1010
end
1111
end

spec/unit/puppet/type/file_line_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
end
88
it 'should accept a line and path' do
99
file_line[:line] = 'my_line'
10-
file_line[:line].should == 'my_line'
10+
expect(file_line[:line]).to eq('my_line')
1111
file_line[:path] = '/my/path'
12-
file_line[:path].should == '/my/path'
12+
expect(file_line[:path]).to eq('/my/path')
1313
end
1414
it 'should accept a match regex' do
1515
file_line[:match] = '^foo.*$'
16-
file_line[:match].should == '^foo.*$'
16+
expect(file_line[:match]).to eq('^foo.*$')
1717
end
1818
it 'should not accept a match regex that does not match the specified line' do
1919
expect {
@@ -35,7 +35,7 @@
3535
end
3636
it 'should accept posix filenames' do
3737
file_line[:path] = '/tmp/path'
38-
file_line[:path].should == '/tmp/path'
38+
expect(file_line[:path]).to eq('/tmp/path')
3939
end
4040
it 'should not accept unqualified path' do
4141
expect { file_line[:path] = 'file' }.to raise_error(Puppet::Error, /File paths must be fully qualified/)
@@ -47,7 +47,7 @@
4747
expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, /Both line and path are required attributes/)
4848
end
4949
it 'should default to ensure => present' do
50-
file_line[:ensure].should eq :present
50+
expect(file_line[:ensure]).to eq :present
5151
end
5252

5353
it "should autorequire the file it manages" do
@@ -59,12 +59,12 @@
5959
relationship = file_line.autorequire.find do |rel|
6060
(rel.source.to_s == "File[/tmp/path]") and (rel.target.to_s == file_line.to_s)
6161
end
62-
relationship.should be_a Puppet::Relationship
62+
expect(relationship).to be_a Puppet::Relationship
6363
end
6464

6565
it "should not autorequire the file it manages if it is not managed" do
6666
catalog = Puppet::Resource::Catalog.new
6767
catalog.add_resource file_line
68-
file_line.autorequire.should be_empty
68+
expect(file_line.autorequire).to be_empty
6969
end
7070
end

0 commit comments

Comments
 (0)