Created
June 29, 2013 08:42
-
-
Save eliasp/5890398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/spec/unit/macaddress_spec.rb b/spec/unit/macaddress_spec.rb | |
index 638ef2a..8bc26b1 100755 | |
--- a/spec/unit/macaddress_spec.rb | |
+++ b/spec/unit/macaddress_spec.rb | |
@@ -49,6 +49,15 @@ describe "macaddress fact" do | |
proc { Facter.value(:macaddress) }.should_not raise_error | |
Facter.value(:macaddress).should be_nil | |
end | |
+ | |
+ # when ifconfig isn't installed, nil is returned which should be handled gracefully without any | |
+ # errors raised | |
+ it "should not raise any errors when nil is returned" do | |
+ Facter::Util::IP.stubs(:exec_ifconfig).with(["-a","2>/dev/null"]). | |
+ returns(nil) | |
+ proc { Facter.value(:macaddress) }.should_not raise_error | |
+ Facter.value(:macaddress).should be_nil | |
+ end | |
end | |
describe "when run on BSD" do |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1st attempt at adding tests for puppetlabs/facter#468.
When exec_ifconfig() returns
nil
(e.g. no ifconfig installed), the modules using its output should not raise any error message.Unfortunately, this test obviously doesn't work: running
facter macaddress
showsCould not retrieve macaddress: undefined method
each_line' for nil:NilClass, but running
rspec spec/unit/util/macaddress_spec.rbshows
… 0 failures`.