Skip to content
Browse files

Merge branch '1.6.x'

* 1.6.x:
  (#12831) Add rspec tests to have_which method in Resolution
  (#12831) Fix recursion on first kernel fact resolution
  Update CHANGELOG for Facter 1.6.7
  Updating CHANGELOG and lib/facter.rb for Facter 1.6.7rc1
  • Loading branch information...
2 parents 1e78602 + 656019c commit e6cbe0005b024f00886505c4016c707398594f4b @kbarber kbarber committed Apr 8, 2012
Showing with 44 additions and 3 deletions.
  1. +7 −0 CHANGELOG
  2. +1 −1 lib/facter.rb
  3. +2 −2 lib/facter/util/resolution.rb
  4. +34 −0 spec/unit/util/resolution_spec.rb
View
7 CHANGELOG
@@ -1,3 +1,10 @@
+1.6.7
+===
+ab9e26c Updating CHANGELOG and lib/facter.rb for Facter 1.6.7rc1
+bdbf332 (#12720) Add Solaris CPU info to 'processorN' fact.
+a7f5924 (#12813) Redirect lspci output to /dev/null
+6ec2863 (#12669) Preserve timestamps when installing files
+
1.6.6
===
e046144 Updated CHANGELOG for 1.6.6rc2
View
2 lib/facter.rb
@@ -25,7 +25,7 @@ module Util; end
include Comparable
include Enumerable
- FACTERVERSION = '1.6.6'
+ FACTERVERSION = '1.6.7'
# = Facter
# Functions as a hash of 'facts' you might care about about your
# system, such as mac address, IP address, Video card, etc.
View
4 lib/facter/util/resolution.rb
@@ -16,11 +16,11 @@ class Facter::Util::Resolution
def self.have_which
if ! defined?(@have_which) or @have_which.nil?
- if Facter.value(:kernel) == 'windows'
+ if Facter::Util::Config.is_windows?
@have_which = false
else
%x{which which >/dev/null 2>&1}
- @have_which = ($? == 0)
+ @have_which = $?.success?
end
end
@have_which
View
34 spec/unit/util/resolution_spec.rb
@@ -405,4 +405,38 @@ def handy_method()
end
end
end
+
+ describe "have_which" do
+ before :each do
+ Facter::Util::Resolution.instance_variable_set(:@have_which, nil)
+
+ # we do not execute anything in the following test cases itself
+ # but we rely on $? to be an instance of Process::Status. So
+ # just execute anything here to make sure that $? is not nil
+ %x{echo foo}
+ end
+
+ it "on windows should always return false" do
+ Facter::Util::Config.stubs(:is_windows?).returns(true)
+ Facter::Util::Resolution.expects(:`).
+ with('which which >/dev/null 2>&1').never
+ Facter::Util::Resolution.have_which.should == false
+ end
+
+ it "on other platforms than windows should return true if which exists" do
+ Facter::Util::Config.stubs(:is_windows?).returns(false)
+ Facter::Util::Resolution.expects(:`).
+ with('which which >/dev/null 2>&1').returns('')
+ Process::Status.any_instance.stubs(:success?).returns true
+ Facter::Util::Resolution.have_which.should == true
+ end
+
+ it "on other platforms than windows should return false if which returns non-zero exit code" do
+ Facter::Util::Config.stubs(:is_windows?).returns(false)
+ Facter::Util::Resolution.expects(:`).
+ with('which which >/dev/null 2>&1').returns('')
+ Process::Status.any_instance.stubs(:success?).returns false
+ Facter::Util::Resolution.have_which.should == false
+ end
+ end
end

0 comments on commit e6cbe00

Please sign in to comment.
Something went wrong with that request. Please try again.