summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Paul Searles <daniel@flowboard.com>2014-06-25 12:56:07 -0700
committerDaniel Paul Searles <daniel@flowboard.com>2014-06-25 12:56:07 -0700
commit930e74d4b9f71b3c9246db458a8b9dd47d877473 (patch)
treefcce4953555d523e5be1b2bab6420c8e898cf927
parente5b09da9f589dc4327e962e29673117e7125e961 (diff)
downloadohai-930e74d4b9f71b3c9246db458a8b9dd47d877473.tar.gz
Stub out and test Resolv exceptions for rackspace hostname attribute.
-rw-r--r--spec/unit/plugins/rackspace_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/unit/plugins/rackspace_spec.rb b/spec/unit/plugins/rackspace_spec.rb
index a955b7a0..9dc85ee5 100644
--- a/spec/unit/plugins/rackspace_spec.rb
+++ b/spec/unit/plugins/rackspace_spec.rb
@@ -101,6 +101,16 @@ describe Ohai::System, "plugin rackspace" do
@plugin[:rackspace][:public_hostname].should == "1234.resolved.com"
end
+ it "should return ip address when reverse dns does not resolve" do
+ Resolv.stub(:getname).and_raise(Resolv::ResolvError)
+ @plugin.run
+ @plugin[:rackspace][:public_hostname].should == "1.2.3.4"
+
+ Resolv.stub(:getname).and_raise(Resolv::ResolvTimeout)
+ @plugin.run
+ @plugin[:rackspace][:public_hostname].should == "1.2.3.4"
+ end
+
it "should have correct values for all attributes" do
@plugin.run
@plugin[:rackspace][:public_ip].should == "1.2.3.4"
@@ -130,6 +140,7 @@ OUT
it_should_behave_like "rackspace"
before(:each) do
+ Resolv.stub(:getname).and_raise(Resolv::ResolvError)
File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)