From 54e62472d6ee54d5feae3b9aba9fcaf44682a067 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 7 Nov 2013 15:09:40 -0700 Subject: [PATCH] add mdadm fact --- lib/facter/mdadm.rb | 6 ++++++ spec/unit/facts/mdadm_spec.rb | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 lib/facter/mdadm.rb create mode 100644 spec/unit/facts/mdadm_spec.rb diff --git a/lib/facter/mdadm.rb b/lib/facter/mdadm.rb new file mode 100644 index 0000000..0c8388f --- /dev/null +++ b/lib/facter/mdadm.rb @@ -0,0 +1,6 @@ +Facter.add('mdadm') do + confine :kernel => 'Linux' + setcode do + Facter::Util::Resolution.which('mdadm') + end +end diff --git a/spec/unit/facts/mdadm_spec.rb b/spec/unit/facts/mdadm_spec.rb new file mode 100644 index 0000000..8e278b3 --- /dev/null +++ b/spec/unit/facts/mdadm_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe 'mdadm', :type => :fact do + before(:each) { Facter.clear } + + context 'kernel => Linux' do + it 'should find the executable' do + Facter.fact(:kernel).stubs(:value).returns('Linux') + Facter::Util::Resolution.stubs(:which).with('mdadm').returns('/sbin/mdadm') + + Facter.fact(:mdadm).value.should == '/sbin/mdadm' + end + end +end