]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Mock Resolv.getaddress in #host_to_ip
authorDan Carley <dan.carley@gmail.com>
Sat, 23 Feb 2013 14:36:17 +0000 (14:36 +0000)
committerDan Carley <dan.carley@gmail.com>
Sat, 23 Feb 2013 17:52:15 +0000 (17:52 +0000)
Add an expect for Resolv.getaddress in Puppet::Util::Firewall#host_to_ip so
that the test can be run when disconnected from the net. Also isolates it
should should puppetlabs.com move to a different address.

spec/unit/puppet/util/firewall_spec.rb

index 31794a63e6860fcb63d53a6f0e7fa27cae10a118..fc1d6906669c10b2c4be9261a0c88f05cb19f1cb 100644 (file)
@@ -13,7 +13,10 @@ describe 'Puppet::Util::Firewall' do
 
   describe '#host_to_ip' do
     subject { resource }
-    specify { subject.host_to_ip('puppetlabs.com').should == '96.126.112.51/32' }
+    specify {
+      Resolv.expects(:getaddress).with('puppetlabs.com').returns('96.126.112.51')
+      subject.host_to_ip('puppetlabs.com').should == '96.126.112.51/32'
+    }
     specify { subject.host_to_ip('96.126.112.51').should == '96.126.112.51/32' }
     specify { subject.host_to_ip('96.126.112.51/32').should == '96.126.112.51/32' }
     specify { subject.host_to_ip('2001:db8:85a3:0:0:8a2e:370:7334').should == '2001:db8:85a3::8a2e:370:7334/128' }