[Pkg-puppet-devel] [facter] 25/61: (refactor) Simplify ipaddress fact specs
Stig Sandbeck Mathisen
ssm at debian.org
Mon Nov 4 15:01:52 UTC 2013
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository facter.
commit d85a4c1cd1298cd597227c24f2fb420b1140a4b6
Author: Adrien Thebo <git at somethingsinistral.net>
Date: Wed Jul 24 11:12:27 2013 -0700
(refactor) Simplify ipaddress fact specs
---
spec/unit/ipaddress_spec.rb | 55 ++++++++++++++++++++++---------------------
1 file changed, 28 insertions(+), 27 deletions(-)
diff --git a/spec/unit/ipaddress_spec.rb b/spec/unit/ipaddress_spec.rb
index 969437e..764e43a 100755
--- a/spec/unit/ipaddress_spec.rb
+++ b/spec/unit/ipaddress_spec.rb
@@ -3,36 +3,37 @@
require 'spec_helper'
require 'facter/util/ip'
-shared_examples_for "ifconfig output" do |platform, address, fixture|
- it "correctly on #{platform}" do
- Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read(fixture))
- subject.value.should == address
+describe "ipaddress fact" do
+ before do
+ Facter.collection.internal_loader.load(:ipaddress)
end
-end
-RSpec.configure do |config|
- config.alias_it_should_behave_like_to :example_behavior_for, "parses"
-end
+ context 'using `ifconfig`' do
+ context "on Linux" do
+ before :each do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ end
-describe "The ipaddress fact" do
- subject do
- Facter.collection.internal_loader.load(:ipaddress)
- Facter.fact(:ipaddress)
- end
- context "on Linux" do
- before :each do
- Facter.fact(:kernel).stubs(:value).returns("Linux")
- end
+ def expect_ifconfig_parse(address, fixture)
+ Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read(fixture))
+ Facter.fact(:ipaddress).value.should == address
+ end
+
+ it "parses correctly on Ubuntu 12.04" do
+ expect_ifconfig_parse "10.87.80.110", "ifconfig_ubuntu_1204.txt"
+ end
+
+ it "parses correctly on Fedora 17" do
+ expect_ifconfig_parse "131.252.209.153", "ifconfig_net_tools_1.60.txt"
+ end
- example_behavior_for "ifconfig output",
- "Ubuntu 12.04", "10.87.80.110", "ifconfig_ubuntu_1204.txt"
- example_behavior_for "ifconfig output",
- "Fedora 17", "131.252.209.153", "ifconfig_net_tools_1.60.txt"
- example_behavior_for "ifconfig output",
- "Linux with multiple loopback addresses",
- "10.0.222.20",
- "ifconfig_multiple_127_addresses.txt"
- example_behavior_for "ifconfig output",
- "Linux with non english locale", nil, "ifconfig_non_english_locale.txt"
+ it "parses a real address over multiple loopback addresses" do
+ expect_ifconfig_parse "10.0.222.20", "ifconfig_multiple_127_addresses.txt"
+ end
+
+ it "parses nothing with a non-english locale" do
+ expect_ifconfig_parse nil, "ifconfig_non_english_locale.txt"
+ end
+ end
end
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git
More information about the Pkg-puppet-devel
mailing list