summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Nasrat <pnasrat@googlemail.com>2008-08-13 15:55:49 +0100
committerPaul Nasrat <pnasrat@googlemail.com>2008-08-13 15:55:49 +0100
commitaf81fb37853802bf35e0af8f94988547633f538b (patch)
tree45db4c6dd05f2d0357fef85e5fb347d8990dea82
parent2546c5343572c1eeca7f9b6a071971706d1b57c5 (diff)
downloadfacter-af81fb37853802bf35e0af8f94988547633f538b.tar.gz
facter-af81fb37853802bf35e0af8f94988547633f538b.tar.xz
facter-af81fb37853802bf35e0af8f94988547633f538b.zip
Extract ifconfig output to data directory
-rw-r--r--spec/unit/data/linux_ifconfig_all_with_single_interface18
-rw-r--r--spec/unit/util/ip.rb26
2 files changed, 22 insertions, 22 deletions
diff --git a/spec/unit/data/linux_ifconfig_all_with_single_interface b/spec/unit/data/linux_ifconfig_all_with_single_interface
new file mode 100644
index 0000000..e063b77
--- /dev/null
+++ b/spec/unit/data/linux_ifconfig_all_with_single_interface
@@ -0,0 +1,18 @@
+eth0 Link encap:Ethernet HWaddr 00:0c:29:52:15:e9
+ inet addr:172.16.15.133 Bcast:172.16.15.255 Mask:255.255.255.0
+ inet6 addr: fe80::20c:29ff:fe52:15e9/64 Scope:Link
+ UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
+ RX packets:173 errors:173 dropped:0 overruns:0 frame:0
+ TX packets:208 errors:0 dropped:0 overruns:0 carrier:0
+ collisions:0 txqueuelen:1000
+ RX bytes:40970 (40.0 KB) TX bytes:24760 (24.1 KB)
+ Interrupt:16 Base address:0x2024
+
+lo Link encap:Local Loopback
+ inet addr:127.0.0.1 Mask:255.0.0.0
+ inet6 addr: ::1/128 Scope:Host
+ UP LOOPBACK RUNNING MTU:16436 Metric:1
+ RX packets:1630 errors:0 dropped:0 overruns:0 frame:0
+ TX packets:1630 errors:0 dropped:0 overruns:0 carrier:0
+ collisions:0 txqueuelen:0
+ RX bytes:81500 (79.5 KB) TX bytes:81500 (79.5 KB) \ No newline at end of file
diff --git a/spec/unit/util/ip.rb b/spec/unit/util/ip.rb
index b517b4e..47ec951 100644
--- a/spec/unit/util/ip.rb
+++ b/spec/unit/util/ip.rb
@@ -12,32 +12,14 @@ describe Facter::IPAddress do
it "should return an empty list of interfaces on an unknown kernel" do
Facter.stubs(:value).returns("UnknownKernel")
- assert_equal [], Facter::IPAddress.get_interfaces()
+ Facter::IPAddress.get_interfaces().should == []
end
it "should return a list with a single interface on Linux with a single interface" do
- linux_ifconfig = <<EOS
-eth0 Link encap:Ethernet HWaddr 00:0c:29:52:15:e9
- inet addr:172.16.15.133 Bcast:172.16.15.255 Mask:255.255.255.0
- inet6 addr: fe80::20c:29ff:fe52:15e9/64 Scope:Link
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- RX packets:173 errors:173 dropped:0 overruns:0 frame:0
- TX packets:208 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:40970 (40.0 KB) TX bytes:24760 (24.1 KB)
- Interrupt:16 Base address:0x2024
-
-lo Link encap:Local Loopback
- inet addr:127.0.0.1 Mask:255.0.0.0
- inet6 addr: ::1/128 Scope:Host
- UP LOOPBACK RUNNING MTU:16436 Metric:1
- RX packets:1630 errors:0 dropped:0 overruns:0 frame:0
- TX packets:1630 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:0
- RX bytes:81500 (79.5 KB) TX bytes:81500 (79.5 KB)
-EOS
+ sample_output_file = File.dirname(__FILE__) + '/../data/linux_ifconfig_all_with_single_interface'
+ linux_ifconfig = File.new(sample_output_file).read()
Facter::IPAddress.stubs(:get_all_interface_output).returns(linux_ifconfig)
- assert_equal ["eth0"], Facter::IPAddress.get_interfaces()
+ Facter::IPAddress.get_interfaces().should == ["eth0"]
end
it "should return a value for a specific interface" do