Class: Inspec::RunnerRspec
- Inherits:
-
Object
- Object
- Inspec::RunnerRspec
- Defined in:
- lib/inspec/runner_rspec.rb
Instance Method Summary collapse
-
#add_profile(profile) ⇒ nil
Add a full profile to the runner.
-
#add_test(example, rule_id, rule) ⇒ nil
Add an example group to the list of registered tests.
-
#example_group(*args, &block) ⇒ RSpecExampleGroup
Create a new RSpec example group from arguments and block.
-
#initialize(conf) ⇒ RunnerRspec
constructor
A new instance of RunnerRspec.
- #report ⇒ Object
-
#run(with = nil) ⇒ int
Run all registered tests with an optional test runner.
-
#tests ⇒ Array
Retrieve the list of tests that have been added.
Constructor Details
#initialize(conf) ⇒ RunnerRspec
Returns a new instance of 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_profile(profile) ⇒ nil
Add a full profile to the runner. Only pulls in metadata
36 37 38 39 40 41 42 |
# File 'lib/inspec/runner_rspec.rb', line 36 def add_profile(profile) RSpec.configuration.formatters .find_all { |c| c.is_a? InspecRspecFormatter } .each do |fmt| fmt.add_profile(profile) end end |
#add_test(example, rule_id, rule) ⇒ nil
Add an example group to the list of registered tests.
49 50 51 52 |
# File 'lib/inspec/runner_rspec.rb', line 49 def add_test(example, rule_id, rule) set_rspec_ids(example, rule_id, rule) @tests.example_groups.push(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 |
#report ⇒ Object
70 71 72 73 |
# File 'lib/inspec/runner_rspec.rb', line 70 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.
65 66 67 68 |
# File 'lib/inspec/runner_rspec.rb', line 65 def run(with = nil) with ||= RSpec::Core::Runner.new(nil) with.run_specs(tests) end |
#tests ⇒ Array
Retrieve the list of tests that have been added.
57 58 59 |
# File 'lib/inspec/runner_rspec.rb', line 57 def tests @tests.ordered_example_groups end |