File: have_rule.rb

package info (click to toggle)
ruby-serverspec 2.43.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 984 kB
  • sloc: ruby: 4,847; makefile: 4
file content (25 lines) | stat: -rw-r--r-- 609 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
RSpec::Matchers.define :have_rule do |rule|
  match do |subject|
    if subject.class.name == 'Serverspec::Type::Iptables' || subject.class.name == 'Serverspec::Type::Ip6tables'
      subject.has_rule?(rule, @table, @chain)
    else
      subject.has_rule?(rule)
    end
  end

  description do
    message = %Q{have rule "#{rule}"}
    message << " with table #{@table}" if @table
    message << ' and' if @table && @chain
    message << " with chain #{@chain}" if @chain
    message
  end

  chain :with_table do |table|
    @table = table
  end

  chain :with_chain do |chain|
    @chain = chain
  end
end