Sha256: 88f5de1f5368443eb352e356c96a95559aa249feea2777afb31cb32ddf35b2f0
Contents?: true
Size: 1.87 KB
Versions: 9
Compression:
Stored size: 1.87 KB
Contents
#! /usr/bin/env ruby require 'spec_helper' def ifconfig_fixture(filename) File.read(fixtures('ifconfig', filename)) end def netsh_fixture(filename) File.read(fixtures('netsh', filename)) end describe "macaddress fact" do before do Facter::Util::Config.stubs(:is_windows?).returns(false) end describe "when run on Linux" do before :each do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:operatingsystem).stubs(:value).returns("Linux") end it "should return the macaddress of the first interface" do Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig -a 2>/dev/null'). returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces')) Facter.value(:macaddress).should == "00:12:3f:be:22:01" end it "should return nil when no macaddress can be found" do Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig -a 2>/dev/null'). returns(ifconfig_fixture('linux_ifconfig_no_mac')) proc { Facter.value(:macaddress) }.should_not raise_error Facter.value(:macaddress).should be_nil end # some interfaces dont have a real mac addresses (like venet inside a container) it "should return nil when no interface has a real macaddress" do Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig -a 2>/dev/null'). returns(ifconfig_fixture('linux_ifconfig_venet')) proc { Facter.value(:macaddress) }.should_not raise_error Facter.value(:macaddress).should be_nil end end describe "when run on BSD" do it "should return macaddress information" do Facter.fact(:kernel).stubs(:value).returns("FreeBSD") Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig'). returns(ifconfig_fixture('bsd_ifconfig_all_with_multiple_interfaces')) Facter.value(:macaddress).should == "00:0b:db:93:09:67" end end end
Version data entries
9 entries across 9 versions & 2 rubygems