PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/spec/unit/ipaddress6_spec.rb

https://github.com/phantez/facter
Ruby | 36 lines | 26 code | 9 blank | 1 comment | 6 complexity | 6c3fe22860ced836f30700360590db51 MD5 | raw file
  1. #!/usr/bin/env ruby
  2. $basedir = File.expand_path(File.dirname(__FILE__) + '/..')
  3. require File.join($basedir, 'spec_helper')
  4. require 'facter'
  5. def ifconfig_fixture(filename)
  6. ifconfig = File.new(File.join($basedir, 'fixtures', 'ifconfig', filename)).read
  7. end
  8. describe "IPv6 address fact" do
  9. it "should return ipaddress6 information for Darwin" do
  10. Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Darwin')
  11. Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig -a').
  12. returns(ifconfig_fixture('darwin_ifconfig_all_with_multiple_interfaces'))
  13. Facter.value(:ipaddress6).should == "2610:10:20:209:223:32ff:fed5:ee34"
  14. end
  15. it "should return ipaddress6 information for Linux" do
  16. Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Linux')
  17. Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig').
  18. returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces'))
  19. Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201"
  20. end
  21. it "should return ipaddress6 information for Solaris" do
  22. Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS')
  23. Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/ifconfig -a').
  24. returns(ifconfig_fixture('sunos_ifconfig_all_with_multiple_interfaces'))
  25. Facter.value(:ipaddress6).should == "2610:10:20:209:203:baff:fe27:a7c"
  26. end
  27. end