Class: Inspec::Object::Describe::Test
- Inherits:
-
Struct
- Object
- Struct
- Inspec::Object::Describe::Test
- Defined in:
- lib/inspec/objects/describe.rb
Overview
Internal helper to structure test objects. Should not be exposed to the user as it is hidden behind ‘add_test`, `to_hash`, and `to_ruby` in Inspec::Object::Describe
Instance Attribute Summary collapse
-
#expectation ⇒ Object
Returns the value of attribute expectation.
-
#its ⇒ Object
Returns the value of attribute its.
-
#matcher ⇒ Object
Returns the value of attribute matcher.
-
#negated ⇒ Object
Returns the value of attribute negated.
Instance Method Summary collapse
Instance Attribute Details
#expectation ⇒ Object
Returns the value of attribute expectation
8 9 10 |
# File 'lib/inspec/objects/describe.rb', line 8 def expectation @expectation end |
#its ⇒ Object
Returns the value of attribute its
8 9 10 |
# File 'lib/inspec/objects/describe.rb', line 8 def its @its end |
#matcher ⇒ Object
Returns the value of attribute matcher
8 9 10 |
# File 'lib/inspec/objects/describe.rb', line 8 def matcher @matcher end |
#negated ⇒ Object
Returns the value of attribute negated
8 9 10 |
# File 'lib/inspec/objects/describe.rb', line 8 def negated @negated end |
Instance Method Details
#negate! ⇒ Object
9 10 11 |
# File 'lib/inspec/objects/describe.rb', line 9 def negate! self.negated = !negated end |
#to_ruby ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/inspec/objects/describe.rb', line 13 def to_ruby itsy = "it" unless its.nil? itsy = if its.is_a? Array "its(" + its.inspect + ")" else "its(" + its.to_s.inspect + ")" end end 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 |