Class: Inspec::Describe
- Inherits:
-
Object
- Object
- Inspec::Describe
- Includes:
- RubyHelper
- Defined in:
- lib/inspec/objects/describe.rb
Defined Under Namespace
Classes: Test
Instance Attribute Summary collapse
-
#qualifier ⇒ Object
A qualifier describing the resource that will be tested.
-
#skip ⇒ Object
Optional method to skip this describe block altogether.
-
#tests ⇒ Object
An array of individual tests for the qualifier.
-
#variables ⇒ Object
Optional variables which are used by tests.
Instance Method Summary collapse
- #add_test(its, matcher, expectation, opts = {}) ⇒ Object
-
#initialize ⇒ Describe
constructor
A new instance of Describe.
- #resource ⇒ Object
- #to_hash ⇒ Object
- #to_ruby ⇒ Object
Methods included from RubyHelper
Constructor Details
#initialize ⇒ Describe
Returns a new instance of Describe.
57 58 59 60 61 62 63 |
# File 'lib/inspec/objects/describe.rb', line 57 def initialize @qualifier = [] @tests = [] @variables = [] Inspec.deprecate(:object_classes, "The Inspec::Describe class is deprecated. Use the Inspec::Object::Describe class from the inspec-objects Ruby library.") end |
Instance Attribute Details
#qualifier ⇒ Object
A qualifier describing the resource that will be tested. It may consist of the resource identification and multiple accessors to pinpoint the data the user wants to test.
41 42 43 |
# File 'lib/inspec/objects/describe.rb', line 41 def qualifier @qualifier end |
#skip ⇒ Object
Optional method to skip this describe block altogether. If ‘skip` is defined it takes precendence and will print the skip statement instead of adding other tests.
53 54 55 |
# File 'lib/inspec/objects/describe.rb', line 53 def skip @skip end |
#tests ⇒ Object
An array of individual tests for the qualifier. Every entry will be translated into an ‘it` or `its` clause.
45 46 47 |
# File 'lib/inspec/objects/describe.rb', line 45 def tests @tests end |
#variables ⇒ Object
Optional variables which are used by tests.
48 49 50 |
# File 'lib/inspec/objects/describe.rb', line 48 def variables @variables end |
Instance Method Details
#add_test(its, matcher, expectation, opts = {}) ⇒ Object
65 66 67 68 69 |
# File 'lib/inspec/objects/describe.rb', line 65 def add_test(its, matcher, expectation, opts = {}) test = Inspec::Describe::Test.new(its, matcher, expectation, opts[:negated]) tests.push(test) test end |
#resource ⇒ Object
81 82 83 84 85 |
# File 'lib/inspec/objects/describe.rb', line 81 def resource return nil if qualifier.empty? || qualifier[0].empty? || qualifier[0][0].empty? qualifier[0][0] end |
#to_hash ⇒ Object
77 78 79 |
# File 'lib/inspec/objects/describe.rb', line 77 def to_hash { qualifier: qualifier, tests: tests.map(&:to_h), variables: variables, skip: skip } end |
#to_ruby ⇒ Object
71 72 73 74 75 |
# File 'lib/inspec/objects/describe.rb', line 71 def to_ruby return rb_skip unless skip.nil? rb_describe end |