Method: Inspec::Describe::Test#to_ruby

Defined in:
lib/inspec/objects/describe.rb

#to_rubyObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/inspec/objects/describe.rb', line 13

def to_ruby
  itsy = its.nil? ? 'it' : 'its(' + its.to_s.inspect + ')'
  naughty = negated ? '_not' : ''
  xpect = if expectation.nil?
            ''
          elsif expectation.class == Regexp
            # without this, xpect values like / \/zones\// will not be parsed properly
            "(#{expectation.inspect})"
          else
            ' ' + expectation.inspect
          end
  format('%s { should%s %s%s }', itsy, naughty, matcher, xpect)
end