Class: RSpec::Core::ExampleGroup

Inherits:
Object
  • Object
show all
Includes:
Inspec::DescribeDslLazyLoader, Inspec::TestDslLazyLoader
Defined in:
lib/inspec/rspec_extensions.rb

Instance Method Summary collapse

Methods included from Inspec::DescribeDslLazyLoader

#method_missing

Methods included from Inspec::TestDslLazyLoader

#method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Inspec::DescribeDslLazyLoader

Instance Method Details

#attribute(name, options = {}) ⇒ Object



104
105
106
107
# File 'lib/inspec/rspec_extensions.rb', line 104

def attribute(name, options = {})
  Inspec.deprecate(:attrs_dsl, "Input name: #{name}, Profile: #{self.class.[:profile_id]}")
  input(name, options)
end

#input(input_name, options = {}) ⇒ Object

This DSL method allows us to access the values of inputs within InSpec tests



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/inspec/rspec_extensions.rb', line 85

def input(input_name, options = {})
  profile_id = self.class.[:profile_id]
  if options.empty?
    # Simply an access, no event here
    Inspec::InputRegistry.find_or_register_input(input_name, profile_id).value
  else
    options[:priority] = 20
    options[:provider] = :inline_control_code
    evt = Inspec::Input.infer_event(options)
    Inspec::InputRegistry.find_or_register_input(input_name, profile_id, event: evt).value
  end
end

#input_object(name) ⇒ Object



99
100
101
# File 'lib/inspec/rspec_extensions.rb', line 99

def input_object(name)
  Inspec::InputRegistry.find_or_register_input(name, self.class.[:profile_id])
end