From e4ae526eedc7eeeabd21704b884fa4eafcc4d677 Mon Sep 17 00:00:00 2001 From: Dragos Chiriac Date: Wed, 10 May 2017 16:48:35 +0300 Subject: [PATCH 1/2] Do not set a value for the collectd_version fact if collectd is not yet installed --- lib/facter/collectd_version.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/facter/collectd_version.rb b/lib/facter/collectd_version.rb index 75bc589d9..0be02fdab 100644 --- a/lib/facter/collectd_version.rb +++ b/lib/facter/collectd_version.rb @@ -11,8 +11,6 @@ if Facter::Util::Resolution.which('collectd') collectd_help = Facter::Util::Resolution.exec('collectd -h') %r{^collectd ([\w\.]+), http://collectd\.org/}.match(collectd_help)[1] - else - '' end end end From 200fd7963bbda01fa05ce08bb855f8a3fbf7b614 Mon Sep 17 00:00:00 2001 From: Dragos Chiriac Date: Wed, 10 May 2017 19:00:00 +0300 Subject: [PATCH 2/2] Changed the test --- spec/unit/collectd_real_version_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/unit/collectd_real_version_spec.rb b/spec/unit/collectd_real_version_spec.rb index 0b3597dc4..17467b424 100644 --- a/spec/unit/collectd_real_version_spec.rb +++ b/spec/unit/collectd_real_version_spec.rb @@ -18,8 +18,8 @@ expect(Facter.fact(:collectd_version).value).to eq('5.1.0.git') end - it 'is empty string if collectd not installed' do + it 'is not defined if collectd not installed' do Facter::Util::Resolution.stubs(:which).with('collectd').returns(nil) - expect(Facter.fact(:collectd_version).value).to eq('') + expect(Facter.fact(:collectd_version).value).to be_nil end end