Commit 18dcf32e authored by Stefan Schulte's avatar Stefan Schulte
Browse files

Switch to rspec3 matchers

Running the specs with rspec3 leads to the following deprecation
warning:

    Using `should` from rspec-expectations' old `:should` syntax without
    explicitly enabling the syntax is deprecated. Use the new `:expect`
    syntax or explicitly enable `:should` instead

So switch to the new expect syntax
parent d4a81580
...@@ -10,33 +10,33 @@ describe Puppet::Type.type(:rpmkey).provider(:rpm) do ...@@ -10,33 +10,33 @@ describe Puppet::Type.type(:rpmkey).provider(:rpm) do
describe ".instances" do describe ".instances" do
it "should have an instances method" do it "should have an instances method" do
described_class.should respond_to :instances expect(described_class).to respond_to(:instances)
end end
it "should get installed rpm keys by running rpm -q" do it "should get installed rpm keys by running rpm -q" do
described_class.expects(:rpm).with('-q', 'gpg-pubkey').returns File.read(my_fixture('rpm_q')) described_class.expects(:rpm).with('-q', 'gpg-pubkey').returns File.read(my_fixture('rpm_q'))
described_class.instances.map(&:name).should == [ expect(described_class.instances.map(&:name)).to eq([
'DB42A60E', 'DB42A60E',
'4F2A6FD2', '4F2A6FD2',
'23A254D4' '23A254D4'
] ])
end end
it "should return an empty list if no key is installed" do it "should return an empty list if no key is installed" do
described_class.expects(:rpm).with('-q', 'gpg-pubkey').raises Puppet::ExecutionFailure, 'package gpg-pubkey is not installed' described_class.expects(:rpm).with('-q', 'gpg-pubkey').raises Puppet::ExecutionFailure, 'package gpg-pubkey is not installed'
described_class.instances.should be_empty expect(described_class.instances).to be_empty
end end
end end
describe "#exists?" do describe "#exists?" do
it "should return true if the resource is present" do it "should return true if the resource is present" do
provider = described_class.new(:name => 'DB42A60E', :ensure => :present) provider = described_class.new(:name => 'DB42A60E', :ensure => :present)
provider.should be_exists expect(provider).to be_exists
end end
it "should return false if the resource is absent" do it "should return false if the resource is absent" do
provider = described_class.new(:name => 'DB42A60E', :ensure => :absent) provider = described_class.new(:name => 'DB42A60E', :ensure => :absent)
provider.should_not be_exists expect(provider).not_to be_exists
end end
end end
......
...@@ -5,19 +5,19 @@ require 'spec_helper' ...@@ -5,19 +5,19 @@ require 'spec_helper'
describe Puppet::Type.type(:rpmkey) do describe Puppet::Type.type(:rpmkey) do
it "should have :name as its keyattribute" do it "should have :name as its keyattribute" do
described_class.key_attributes.should == [:name] expect(described_class.key_attributes).to eq([:name])
end end
describe "when validating attributes" do describe "when validating attributes" do
[:name, :source, :provider].each do |param| [:name, :source, :provider].each do |param|
it "should have a #{param} parameter" do it "should have a #{param} parameter" do
described_class.attrtype(param).should == :param expect(described_class.attrtype(param)).to eq(:param)
end end
end end
[:ensure].each do |property| [:ensure].each do |property|
it "should have a #{property} property" do it "should have a #{property} property" do
described_class.attrtype(property).should == :property expect(described_class.attrtype(property)).to eq(:property)
end end
end end
end end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment