]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
update spec for host_to_mask to override Resolv
authorPatrick Hemmer <patrick.hemmer@gmail.com>
Fri, 20 Dec 2013 20:30:50 +0000 (15:30 -0500)
committerPatrick Hemmer <patrick.hemmer@gmail.com>
Fri, 20 Dec 2013 23:21:40 +0000 (18:21 -0500)
lib/puppet/provider/firewall/iptables.rb
spec/unit/puppet/util/firewall_spec.rb

index 05cbdfcdf7e8d0f0fdae8c7045ae07419fd03e89..1b9788e656dc3f87a2d6cf92a449f1bf2f2cbc6d 100644 (file)
@@ -167,7 +167,7 @@ Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Fir
     # --tcp-flags takes two values; we cheat by adding " around it
     # so it behaves like --comment
     values = values.sub(/--tcp-flags (\S*) (\S*)/, '--tcp-flags "\1 \2"')
-    # we do a simular thing for negated address masks (source and destination).
+    # we do a similar thing for negated address masks (source and destination).
     values = values.sub(/(-\S+) (!)\s?(\S*)/,'\1 "\2 \3"')
     # the actual rule will have the ! mark before the option.
     values = values.sub(/(!)\s*(-\S+)\s*(\S*)/, '\2 "\1 \3"')
index 2d1ddb0fd1b7a6c74c67a2ee9c86e7459aa2eb2a..ef16be161391b2ff1ec89a09c094d93294922d94 100644 (file)
@@ -27,8 +27,11 @@ describe 'Puppet::Util::Firewall' do
 
   describe '#host_to_mask' do
     subject { resource }
-    specify { subject.host_to_mask('puppetlabs.com').should == '96.126.112.51/32' }
-    specify { subject.host_to_mask('!puppetlabs.com').should == '! 96.126.112.51/32' }
+    specify {
+      expect(Resolv).to receive(:getaddress).any_number_of_times.with('puppetlabs.com').and_return('96.126.112.51')
+      subject.host_to_mask('puppetlabs.com').should == '96.126.112.51/32'
+      subject.host_to_mask('!puppetlabs.com').should == '! 96.126.112.51/32'
+    }
     specify { subject.host_to_mask('96.126.112.51').should == '96.126.112.51/32' }
     specify { subject.host_to_mask('!96.126.112.51').should == '! 96.126.112.51/32' }
     specify { subject.host_to_mask('96.126.112.51/32').should == '96.126.112.51/32' }