Improve java_version fact maintainability
This commit is contained in:
@@ -11,9 +11,9 @@
|
||||
#
|
||||
# Notes:
|
||||
# None
|
||||
if Facter::Util::Resolution.which('java')
|
||||
Facter.add(:java_version) do
|
||||
setcode do
|
||||
if Facter::Util::Resolution.which('java')
|
||||
Facter::Util::Resolution.exec('java -Xmx8m -version 2>&1').lines.first.split(/"/)[1].strip
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
|
||||
EOS
|
||||
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.fact(:java_version).value.should == "1.7.0_71"
|
||||
Facter.value(:java_version).should == "1.7.0_71"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
|
||||
it do
|
||||
Facter::Util::Resolution.stubs(:exec)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user