Sha256: 01e734f55be0ffe4e6a06d5bc3f1025f8c4a5226352933d2a460881c82c44dc8

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe "Facter::Util::Fact iptables_persistent_version" do
  before { Facter.clear }
  let(:dpkg_cmd) { "dpkg-query -Wf '${Version}' iptables-persistent 2>/dev/null" }

  {
    "Debian" => "0.0.20090701",
    "Ubuntu" => "0.5.3ubuntu2",
  }.each do |os, ver|
    describe "#{os} package installed" do
      before {
        allow(Facter.fact(:operatingsystem)).to receive(:value).and_return(os)
        allow(Facter::Util::Resolution).to receive(:exec).with(dpkg_cmd).
          and_return(ver)
      }
      it { Facter.fact(:iptables_persistent_version).value.should == ver }
    end
  end

  describe 'Ubuntu package not installed' do
    before {
      allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('Ubuntu')
      allow(Facter::Util::Resolution).to receive(:exec).with(dpkg_cmd).
        and_return(nil)
    }
    it { Facter.fact(:iptables_persistent_version).value.should be_nil }
  end

  describe 'CentOS not supported' do
    before { allow(Facter.fact(:operatingsystem)).to receive(:value).
               and_return("CentOS") }
    it { Facter.fact(:iptables_persistent_version).value.should be_nil }
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
freighthop-0.6.1 modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb
freighthop-0.6.0 modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb
freighthop-0.5.2 modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb
freighthop-0.5.1 modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb
freighthop-0.5.0 modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb
freighthop-0.4.1 modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb
freighthop-0.4.0 modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb