From: Dan Carley Date: Sat, 23 Feb 2013 14:36:17 +0000 (+0000) Subject: Mock Resolv.getaddress in #host_to_ip X-Git-Tag: 0.1.0~4^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ed683d97f3c24f263d3f90669d1d9680790b9766;p=puppet-modules%2Fpuppetlabs-firewall.git Mock Resolv.getaddress in #host_to_ip 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. --- diff --git a/spec/unit/puppet/util/firewall_spec.rb b/spec/unit/puppet/util/firewall_spec.rb index 31794a6..fc1d690 100644 --- a/spec/unit/puppet/util/firewall_spec.rb +++ b/spec/unit/puppet/util/firewall_spec.rb @@ -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' }