Class: Inspec::Object::Test

Inherits:
Object
  • Object
show all
Includes:
RubyHelper
Defined in:
lib/inspec/objects/test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RubyHelper

#ruby_qualifier

Constructor Details

#initializeTest

Returns a new instance of Test.



6
7
8
9
10
# File 'lib/inspec/objects/test.rb', line 6

def initialize
  @qualifier = []
  @negated = false
  @variables = []
end

Instance Attribute Details

#expectationObject

Returns the value of attribute expectation.



3
4
5
# File 'lib/inspec/objects/test.rb', line 3

def expectation
  @expectation
end

#matcherObject

Returns the value of attribute matcher.



3
4
5
# File 'lib/inspec/objects/test.rb', line 3

def matcher
  @matcher
end

#negatedObject

Returns the value of attribute negated.



3
4
5
# File 'lib/inspec/objects/test.rb', line 3

def negated
  @negated
end

#only_ifObject

Returns the value of attribute only_if.



3
4
5
# File 'lib/inspec/objects/test.rb', line 3

def only_if
  @only_if
end

#qualifierObject

Returns the value of attribute qualifier.



3
4
5
# File 'lib/inspec/objects/test.rb', line 3

def qualifier
  @qualifier
end

#skipObject

Returns the value of attribute skip.



3
4
5
# File 'lib/inspec/objects/test.rb', line 3

def skip
  @skip
end

#variablesObject

Returns the value of attribute variables.



3
4
5
# File 'lib/inspec/objects/test.rb', line 3

def variables
  @variables
end

Instance Method Details

#negate!Object



12
13
14
# File 'lib/inspec/objects/test.rb', line 12

def negate!
  @negated = !@negated
end

#remove_expectationObject



35
36
37
# File 'lib/inspec/objects/test.rb', line 35

def remove_expectation
  remove_instance_variable(:@expectation)
end

#resourceObject



26
27
28
29
30
31
32
33
# File 'lib/inspec/objects/test.rb', line 26

def resource
  @resource ||=
    if qualifier.empty? || qualifier[0].empty? || qualifier[0][0].empty?
      nil
    else
      qualifier[0][0]
    end
end

#to_hashObject



22
23
24
# File 'lib/inspec/objects/test.rb', line 22

def to_hash
  { qualifier: qualifier, matcher: matcher, expectation: expectation, skip: skip, negated: negated }
end

#to_rubyObject



16
17
18
19
20
# File 'lib/inspec/objects/test.rb', line 16

def to_ruby
  return rb_skip unless skip.nil?

  rb_describe
end