From Ample Moth, 11 Months ago, written in Ruby.
This paste will croak in 1 Second.
Embed
  1. # (3) switch to using a hash for the IP
  2.  
  3. [
  4.   'iptables', '$my_ipv4',
  5.   'ip6tables', '$my_ipv6'
  6. ].each do |iptables, ip|
  7.   describe send(iptables) do
  8.    (other rules)
  9.     it { should have_rule("-A INPUT -d #{ip} -j 51_policy_by_ip") }
  10.     it { should have_rule("-A FORWARD -d #{ip} -j 51_policy_by_ip_forward") }
  11.     it { should have_rule("-A 51_policy_by_ip -d #{ip} -j DROP") }
  12.     it { should have_rule("-A 51_policy_by_ip_forward -d #{ip} -j DROP") }
  13.    (other rules)
  14.   end
  15. end