Merge pull request #107 from elyscape/fix/improve_java_version_fact

Improve java_version fact maintainability
This commit is contained in:
Colleen Murphy
2015-02-12 11:51:09 -08:00
2 changed files with 5 additions and 5 deletions

View File

@@ -11,9 +11,9 @@
# #
# Notes: # Notes:
# None # None
if Facter::Util::Resolution.which('java') Facter.add(:java_version) do
Facter.add(:java_version) do setcode do
setcode do if Facter::Util::Resolution.which('java')
Facter::Util::Resolution.exec('java -Xmx8m -version 2>&1').lines.first.split(/"/)[1].strip Facter::Util::Resolution.exec('java -Xmx8m -version 2>&1').lines.first.split(/"/)[1].strip
end end
end end

View File

@@ -15,7 +15,7 @@ Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
EOS EOS
Facter::Util::Resolution.expects(:which).with("java").returns(true) Facter::Util::Resolution.expects(:which).with("java").returns(true)
Facter::Util::Resolution.expects(:exec).with("java -Xmx8m -version 2>&1").returns(java_version_output) Facter::Util::Resolution.expects(:exec).with("java -Xmx8m -version 2>&1").returns(java_version_output)
Facter.fact(:java_version).value.should == "1.7.0_71" Facter.value(:java_version).should == "1.7.0_71"
end end
end end
@@ -23,7 +23,7 @@ Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
it do it do
Facter::Util::Resolution.stubs(:exec) Facter::Util::Resolution.stubs(:exec)
Facter::Util::Resolution.expects(:which).with("java").returns(false) Facter::Util::Resolution.expects(:which).with("java").returns(false)
Facter.fact(:java_version).should be_nil Facter.value(:java_version).should be_nil
end end
end end
end end