Method: Inspec::DSL.execute_rule

Defined in:
lib/inspec/dsl.rb

.execute_rule(r, profile_id) ⇒ Object

Register a given rule with RSpec and let it run. This happens after everything else is merged in.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/inspec/dsl.rb', line 22

def self.execute_rule(r, profile_id)
  checks = r.instance_variable_get(:@checks)
  fid = InspecBaseRule.full_id(r, profile_id)
  checks.each do |m, a, b|
    # check if the resource is skippable and skipped
    if a.is_a?(Array) && !a.empty? &&
       a[0].respond_to?(:resource_skipped) &&
       !a[0].resource_skipped.nil?
      cres = ::Inspec::Rule.__send__(m, *a) do
        it a[0].resource_skipped
      end
    else
      # execute the method
      cres = ::Inspec::Rule.__send__(m, *a, &b)
    end
    if m == 'describe'
      set_rspec_ids(cres, fid)
    end
  end
end