Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/pr/4050' into stable
Browse files Browse the repository at this point in the history
* upstream/pr/4050:
  (PUP-4758) Update Rspec `raise_error` calls for Rspec 3.3
  • Loading branch information
joshcooper committed Jun 29, 2015
2 parents 02195d6 + 34d10d6 commit 4c0a06c
Show file tree
Hide file tree
Showing 31 changed files with 53 additions and 50 deletions.
4 changes: 3 additions & 1 deletion spec/integration/provider/package_spec.rb
Expand Up @@ -12,7 +12,9 @@
options = {:name => "nosuch#{provider.name}", :provider => provider.name}

pkg = Puppet::Type.newpackage(options)
expect { pkg.provider.install }.to raise_error
expect { pkg.provider.install }.to raise_error { |error|
expect(error).not_to eq("")
}
end

it "should be able to get a list of existing packages" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/application/apply_spec.rb
Expand Up @@ -359,7 +359,7 @@
it "should raise an error if we can't find the facts" do
Puppet::Node::Facts.indirection.expects(:find).returns(nil)

expect { @apply.main }.to raise_error
expect { @apply.main }.to raise_error(RuntimeError, /Could not find facts/)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/application/filebucket_spec.rb
Expand Up @@ -173,7 +173,7 @@
describe "the command backup" do
it "should fail if no arguments are specified" do
@filebucket.stubs(:args).returns([])
expect { @filebucket.backup }.to raise_error
expect { @filebucket.backup }.to raise_error(RuntimeError, /You must specify a file to back up/)
end

it "should call the client backup method for each given parameter" do
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/application_spec.rb
Expand Up @@ -147,7 +147,7 @@ def run_command
# no-op
end
end
}.to raise_error
}.to raise_error(Puppet::Settings::ValidationError, /Invalid run mode/)
end

it "should have a run entry-point" do
Expand Down Expand Up @@ -468,7 +468,7 @@ def run_command
ROUTES
end

expect { @app.configure_indirector_routes }.to raise_error
expect { @app.configure_indirector_routes }.to raise_error(Psych::SyntaxError, /mapping values are not allowed in this context/)
end
end

Expand Down Expand Up @@ -564,7 +564,7 @@ def run_command
raise "I can't believe it, it works!"
end

expect { @app.handle_test2 }.to raise_error
expect { @app.handle_test2 }.to raise_error(RuntimeError, /I can't believe it, it works!/)
end

it "should declare the option to OptionParser" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/face/node_spec.rb
Expand Up @@ -47,7 +47,7 @@
end

it "should not accept a call with no arguments" do
expect { subject.clean() }.to raise_error
expect { subject.clean() }.to raise_error(RuntimeError, /At least one node should be passed/)
end

it "should accept a node name" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/file_serving/configuration_spec.rb
Expand Up @@ -17,7 +17,7 @@
end

it "should make :new a private method" do
expect { Puppet::FileServing::Configuration.new }.to raise_error
expect { Puppet::FileServing::Configuration.new }.to raise_error(NoMethodError, /private method `new' called/)
end

it "should return the same configuration each time 'configuration' is called" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/graph/sequential_prioritizer_spec.rb
Expand Up @@ -27,6 +27,6 @@
it "fails to prioritize a key contained in an unknown container" do
expect do
priorities.generate_priority_contained_in("unknown", "child 1")
end.to raise_error
end.to raise_error(NoMethodError, /`down' for nil/)
end
end
4 changes: 2 additions & 2 deletions spec/unit/indirector/indirection_spec.rb
Expand Up @@ -115,7 +115,7 @@ def authorized?
describe "when initializing" do
# (LAK) I've no idea how to test this, really.
it "should store a reference to itself before it consumes its options" do
expect { @indirection = Puppet::Indirector::Indirection.new(Object.new, :testingness, :not_valid_option) }.to raise_error
expect { @indirection = Puppet::Indirector::Indirection.new(Object.new, :testingness, :not_valid_option) }.to raise_error(NoMethodError, /undefined method/)
expect(Puppet::Indirector::Indirection.instance(:testingness)).to be_instance_of(Puppet::Indirector::Indirection)
Puppet::Indirector::Indirection.instance(:testingness).delete
end
Expand Down Expand Up @@ -509,7 +509,7 @@ def authorized?

@cache.expects(:save).never
@terminus.expects(:save).raises "eh"
expect { @indirection.save(@instance) }.to raise_error
expect { @indirection.save(@instance) }.to raise_error(RuntimeError, /eh/)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/indirector/ssl_file_spec.rb
Expand Up @@ -108,7 +108,7 @@ module Testing; end
"//?/c:/foo",
].each do |input|
it "should resist directory traversal attacks (#{input.inspect})" do
expect { @searcher.path(input) }.to raise_error
expect { @searcher.path(input) }.to raise_error(ArgumentError, /invalid key/)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/indirector/yaml_spec.rb
Expand Up @@ -82,7 +82,7 @@ module MyYaml; end
"//?/c:/foo",
].each do |input|
it "should resist directory traversal attacks (#{input.inspect})" do
expect { @store.path(input) }.to raise_error
expect { @store.path(input) }.to raise_error(ArgumentError)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/module_tool/application_spec.rb
Expand Up @@ -18,7 +18,7 @@

bad_versions.each do |ver|
it "should not accept version string #{ver}" do
expect { app.parse_filename("puppetlabs-ntp-#{ver}") }.to raise_error
expect { app.parse_filename("puppetlabs-ntp-#{ver}") }.to raise_error(ArgumentError, /(Invalid version format|Could not parse filename)/)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/module_tool/applications/builder_spec.rb
Expand Up @@ -319,7 +319,7 @@ def create_symlink_gitignore_file
end

it "give an error about symlinks" do
expect { builder.run }.to raise_error
expect { builder.run }.to raise_error(Puppet::ModuleTool::Errors::ModuleToolError, /Found symlinks/)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/network/authstore_spec.rb
Expand Up @@ -180,7 +180,7 @@
].each { |invalid_ip|
describe "when the pattern is an invalid IPv6 address such as #{invalid_ip}" do
it "should raise an exception" do
expect { Puppet::Network::AuthStore::Declaration.new(:allow,invalid_ip) }.to raise_error
expect { Puppet::Network::AuthStore::Declaration.new(:allow,invalid_ip) }.to raise_error(Puppet::AuthStoreError, /Invalid pattern/)
end
end
}
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/network/http/compression_spec.rb
Expand Up @@ -173,7 +173,7 @@ class HttpUncompressor
it "should raise the error the second time" do
@inflater.stubs(:inflate).raises(Zlib::DataError.new("not a zlib stream"))
Zlib::Inflate.expects(:new).with.returns(@inflater)
expect { @adapter.uncompress("chunk") }.to raise_error
expect { @adapter.uncompress("chunk") }.to raise_error(Zlib::DataError, /not a zlib stream/)
end

it "should finish the stream on close" do
Expand Down
5 changes: 0 additions & 5 deletions spec/unit/network/http/handler_spec.rb
Expand Up @@ -131,11 +131,6 @@ def respond(text)
handler.process(request, response)
end

it "should raise an error if the request is formatted in an unknown format" do
handler.stubs(:content_type_header).returns "unknown format"
expect { handler.request_format(request) }.to raise_error
end

it "should still find the correct format if content type contains charset information" do
request = Puppet::Network::HTTP::Request.new({ 'content-type' => "text/plain; charset=UTF-8" },
{}, 'GET', '/', nil)
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/network/rights_spec.rb
Expand Up @@ -29,7 +29,7 @@
end

it "should throw an error if type can't be determined" do
expect { @right.newright("name") }.to raise_error
expect { @right.newright("name") }.to raise_error(ArgumentError, /Unknown right type/)
end

describe "when creating new path ACLs" do
Expand All @@ -40,7 +40,7 @@
end

it "should throw an error if the acl uri path is not absolute" do
expect { @right.newright("name")}.to raise_error
expect { @right.newright("name")}.to raise_error(ArgumentError, /Unknown right type/)
end

it "should create a new ACL with the correct path" do
Expand Down Expand Up @@ -351,7 +351,7 @@
it "should raise an error if the method is already filtered" do
@acl.restrict_method(:save)

expect { @acl.restrict_method(:save) }.to raise_error
expect { @acl.restrict_method(:save) }.to raise_error(ArgumentError, /'save' is already in the '\/path'/)
end

it "should allow setting an environment filters" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/parser/ast/leaf_spec.rb
Expand Up @@ -93,7 +93,7 @@
end

it "should raise an error if hostname is not valid" do
expect { Puppet::Parser::AST::HostName.new( :value => "not a hostname!" ) }.to raise_error
expect { Puppet::Parser::AST::HostName.new( :value => "not a hostname!" ) }.to raise_error(Puppet::DevError, /'not a hostname!' is not a valid hostname/)
end

it "should not raise an error if hostname is a regex" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/property_spec.rb
Expand Up @@ -230,7 +230,7 @@ class << self
it "should fail if the value is not a defined value or alias and does not match a regex" do
subclass.newvalue(:foo)

expect { property.should = "bar" }.to raise_error
expect { property.should = "bar" }.to raise_error(Puppet::Error, /Invalid value "bar"./)
end

it "should succeeed if the value is one of the defined values" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/provider/ssh_authorized_key/parsed_spec.rb
Expand Up @@ -261,7 +261,7 @@ def genkey(key)
@resource = Puppet::Type.type(:ssh_authorized_key).new(:name => "foo", :target => "/tmp/.ssh_dir/place_to_put_authorized_keys")
@provider = provider_class.new(@resource)

expect { @provider.flush }.to raise_error
expect { @provider.flush }.to raise_error(Puppet::Error, /Cannot write SSH authorized keys without user/)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/unit/resource_spec.rb
Expand Up @@ -428,11 +428,11 @@ def ast_leaf(value)
end

it "should fail if invalid parameters are used" do
expect { Puppet::Resource.new("file", "/path", :strict => true, :parameters => {:nosuchparam => "bar"}) }.to raise_error
expect { Puppet::Resource.new("file", "/path", :strict => true, :parameters => {:nosuchparam => "bar"}) }.to raise_error(ArgumentError, /Invalid parameter/)
end

it "should fail if the resource type cannot be resolved" do
expect { Puppet::Resource.new("nosuchtype", "/path", :strict => true) }.to raise_error
expect { Puppet::Resource.new("nosuchtype", "/path", :strict => true) }.to raise_error(ArgumentError, /Invalid resource type/)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/settings_spec.rb
Expand Up @@ -44,7 +44,7 @@ def metadata(setting)
it "should not allow specification of default values associated with a section as an array" do
expect {
@settings.define_settings(:section, :myvalue => ["defaultval", "my description"])
}.to raise_error
}.to raise_error(ArgumentError, /setting definition for 'myvalue' is not a hash!/)
end

it "should not allow duplicate parameter specifications" do
Expand Down
8 changes: 5 additions & 3 deletions spec/unit/ssl/certificate_authority_spec.rb
Expand Up @@ -777,7 +777,7 @@ def stub_ca_host
it "should raise an error if the certificate or CSR cannot be found" do
Puppet::SSL::Certificate.indirection.expects(:find).with("myhost").returns nil
Puppet::SSL::CertificateRequest.indirection.expects(:find).with("myhost").returns nil
expect { @ca.fingerprint("myhost") }.to raise_error
expect { @ca.fingerprint("myhost") }.to raise_error(ArgumentError, /Could not find a certificate/)
end

it "should try to find a CSR if no certificate can be found" do
Expand Down Expand Up @@ -863,8 +863,10 @@ def stub_ca_host
@cert.expects(:content).returns "mycert"

@store.expects(:verify).with("mycert").returns false
@store.expects(:error)
@store.expects(:error_string)

expect { @ca.verify("me") }.to raise_error
expect { @ca.verify("me") }.to raise_error(Puppet::SSL::CertificateAuthority::CertificateVerificationError)
end

describe "certificate_is_alive?" do
Expand Down Expand Up @@ -963,7 +965,7 @@ def stub_ca_host
@ca.inventory.expects(:serials).with("host").returns []

@ca.crl.expects(:revoke).never
expect { @ca.revoke('host') }.to raise_error
expect { @ca.revoke('host') }.to raise_error(ArgumentError, /Could not find a serial number for host/)
end

context "revocation by serial number (#16798)" do
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/ssl/host_spec.rb
Expand Up @@ -422,7 +422,7 @@ def base_pson_comparison(result, pson_hash)
@key.stubs(:generate)
Puppet::SSL::Key.indirection.expects(:save).raises "eh"

expect { @host.generate_key }.to raise_error
expect { @host.generate_key }.to raise_error(RuntimeError)
expect(@host.key).to be_nil
end

Expand Down Expand Up @@ -496,7 +496,7 @@ def base_pson_comparison(result, pson_hash)
Puppet::SSL::CertificateRequest.indirection.expects(:prepare).returns(terminus)
terminus.expects(:save).with { |req| req.instance == @request && req.key == "myname" }.raises "eh"

expect { @host.generate_certificate_request }.to raise_error
expect { @host.generate_certificate_request }.to raise_error(RuntimeError)

expect(@host.instance_eval { @certificate_request }).to be_nil
end
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/type/host_spec.rb
Expand Up @@ -68,15 +68,15 @@
end

it "should not accept malformed IPv4 addresses like 192.168.0.300" do
expect { @class.new(:name => "foo", :ip => '192.168.0.300') }.to raise_error
expect { @class.new(:name => "foo", :ip => '192.168.0.300') }.to raise_error(Puppet::ResourceError, /Parameter ip failed/)
end

it "should reject over-long IPv4 addresses" do
expect { @class.new(:name => "foo", :ip => '10.10.10.10.10') }.to raise_error
expect { @class.new(:name => "foo", :ip => '10.10.10.10.10') }.to raise_error(Puppet::ResourceError, /Parameter ip failed/)
end

it "should not accept malformed IP addresses like 2001:0dg8:85a3:08d3:1319:8a2e:0370:7344" do
expect { @class.new(:name => "foo", :ip => '2001:0dg8:85a3:08d3:1319:8a2e:0370:7344') }.to raise_error
expect { @class.new(:name => "foo", :ip => '2001:0dg8:85a3:08d3:1319:8a2e:0370:7344') }.to raise_error(Puppet::ResourceError, /Parameter ip failed/)
end

# Assorted, annotated IPv6 passes.
Expand Down Expand Up @@ -598,7 +598,7 @@
"::2222:3333:4444:5555:6666:7777:8888:",
].each do |ip|
it "should reject #{ip.inspect} as an IPv6 address" do
expect { @class.new(:name => "foo", :ip => ip) }.to raise_error
expect { @class.new(:name => "foo", :ip => ip) }.to raise_error(Puppet::ResourceError, /Parameter ip failed/)
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/unit/type/tidy_spec.rb
Expand Up @@ -66,7 +66,7 @@
end

it "should not allow arbitrary values" do
expect { @tidy[:recurse] = "whatever" }.to raise_error
expect { @tidy[:recurse] = "whatever" }.to raise_error(Puppet::ResourceError, /Parameter recurse failed/)
end
end

Expand All @@ -76,13 +76,13 @@
end

it "should object if matches is given with recurse is not specified" do
expect { @tidy[:matches] = '*.doh' }.to raise_error
expect { @tidy[:matches] = '*.doh' }.to raise_error(Puppet::ResourceError, /Parameter matches failed/)
end
it "should object if matches is given and recurse is 0" do
expect { @tidy[:recurse] = 0; @tidy[:matches] = '*.doh' }.to raise_error
expect { @tidy[:recurse] = 0; @tidy[:matches] = '*.doh' }.to raise_error(Puppet::ResourceError, /Parameter matches failed/)
end
it "should object if matches is given and recurse is false" do
expect { @tidy[:recurse] = false; @tidy[:matches] = '*.doh' }.to raise_error
expect { @tidy[:recurse] = false; @tidy[:matches] = '*.doh' }.to raise_error(Puppet::ResourceError, /Parameter matches failed/)
end
it "should not object if matches is given and recurse is > 0" do
expect { @tidy[:recurse] = 1; @tidy[:matches] = '*.doh' }.not_to raise_error
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/type/vlan_spec.rb
Expand Up @@ -38,7 +38,7 @@
end

it "should fail if vlan name is not a number" do
expect { Puppet::Type.type(:vlan).new(:name => "notanumber", :ensure => :present) }.to raise_error
expect { Puppet::Type.type(:vlan).new(:name => "notanumber", :ensure => :present) }.to raise_error(Puppet::ResourceError, /Parameter name failed on Vlan/)
end
end
end
2 changes: 1 addition & 1 deletion spec/unit/util/ldap/generator_spec.rb
Expand Up @@ -9,7 +9,7 @@
end

it "should require a parameter name at initialization" do
expect { Puppet::Util::Ldap::Generator.new }.to raise_error
expect { Puppet::Util::Ldap::Generator.new }.to raise_error(ArgumentError, /wrong number of arguments/)
end

it "should always return its name as a string" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/util/network_device/cisco/device_spec.rb
Expand Up @@ -133,7 +133,7 @@
describe "when entering enable password" do
it "should raise an error if no enable password has been set" do
@cisco.enable_password = nil
expect{ @cisco.enable }.to raise_error
expect{ @cisco.enable }.to raise_error(RuntimeError, /Can't issue "enable" to enter privileged/)
end

it "should send the enable command and expect an enable prompt" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/util/network_device/transport/ssh_spec.rb
Expand Up @@ -65,7 +65,7 @@

it "should raise an error if shell channel creation fails" do
@channel.expects(:send_channel_request).with("shell").yields(@channel, false)
expect { @transport.connect }.to raise_error
expect { @transport.connect }.to raise_error(RuntimeError, /failed to open ssh shell channel/)
end

it "should register an on_data and on_extended_data callback" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/util/network_device_spec.rb
Expand Up @@ -35,7 +35,7 @@ def initialize(device, options)

it "should raise an error if the remote device instance can't be created" do
Puppet::Util::NetworkDevice.stubs(:require).raises("error")
expect { Puppet::Util::NetworkDevice.init(@device) }.to raise_error
expect { Puppet::Util::NetworkDevice.init(@device) }.to raise_error(RuntimeError, /Can't load test for name/)
end

it "should let caller to access the singleton device" do
Expand Down

0 comments on commit 4c0a06c

Please sign in to comment.