summaryrefslogtreecommitdiff
path: root/spec/unit/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/puppet')
-rwxr-xr-xspec/unit/puppet/parser/functions/bool2str_spec.rb18
-rwxr-xr-xspec/unit/puppet/parser/functions/camelcase_spec.rb8
-rwxr-xr-xspec/unit/puppet/provider/file_line/ruby_spec.rb36
-rwxr-xr-xspec/unit/puppet/type/anchor_spec.rb2
-rwxr-xr-xspec/unit/puppet/type/file_line_spec.rb14
5 files changed, 39 insertions, 39 deletions
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