Class: Inspec::RunnerRspec

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/runner_rspec.rb

Instance Method Summary collapse

Constructor Details

#initialize(conf) ⇒ RunnerRspec



17
18
19
20
21
# File 'lib/inspec/runner_rspec.rb', line 17

def initialize(conf)
  @conf = conf
  reset_tests
  configure_output
end

Instance Method Details

#add_test(example, rule_id) ⇒ nil

Add an example group to the list of registered tests.



37
38
39
40
# File 'lib/inspec/runner_rspec.rb', line 37

def add_test(example, rule_id)
  set_rspec_ids(example, rule_id)
  @tests.register(example)
end

#example_group(*args, &block) ⇒ RSpecExampleGroup

Create a new RSpec example group from arguments and block.



28
29
30
# File 'lib/inspec/runner_rspec.rb', line 28

def example_group(*args, &block)
  RSpec::Core::ExampleGroup.describe(*args, &block)
end

#reportObject



58
59
60
61
# File 'lib/inspec/runner_rspec.rb', line 58

def report
  reporter = RSpec.configuration.formatters.find { |f| f.is_a? Inspec::RSpecReporter }
  reporter.output_hash
end

#run(with = nil) ⇒ int

Run all registered tests with an optional test runner.



53
54
55
56
# File 'lib/inspec/runner_rspec.rb', line 53

def run(with = nil)
  with ||= RSpec::Core::Runner.new(nil)
  with.run_specs(tests)
end

#testsArray

Retrieve the list of tests that have been added.



45
46
47
# File 'lib/inspec/runner_rspec.rb', line 45

def tests
  @tests.ordered_example_groups
end