class Mutiny::Integration::RSpec::Runner
This code originally based on Markus Schirp’s implementation of Mutant::Integration::Rspec
https://github.com/mbj/mutant/blob/master/lib/mutant/integration/rspec.rb
Public Class Methods
new(test_set, context = Context.new, hooks = [])
click to toggle source
# File lib/mutiny/integration/rspec/runner.rb, line 12 def initialize(test_set, context = Context.new, hooks = []) @test_set = test_set @context = context @hooks = hooks end
Public Instance Methods
call()
click to toggle source
# File lib/mutiny/integration/rspec/runner.rb, line 18 def call reset prepare run end
Private Instance Methods
create_test_run(output, runtime)
click to toggle source
# File lib/mutiny/integration/rspec/runner.rb, line 45 def create_test_run(output, runtime) Tests::TestRun.new( tests: @test_set.generalise, passed_tests: @test_set.subset_for_examples(@passed_examples).generalise, failed_tests: @test_set.subset_for_examples(@failed_examples).generalise, output: output, runtime: runtime ) end
example_failed(notification)
click to toggle source
# File lib/mutiny/integration/rspec/runner.rb, line 74 def example_failed(notification) @failed_examples << notification.example end
example_passed(notification)
click to toggle source
# File lib/mutiny/integration/rspec/runner.rb, line 70 def example_passed(notification) @passed_examples << notification.example end
filter_examples()
click to toggle source
# File lib/mutiny/integration/rspec/runner.rb, line 59 def filter_examples world.filtered_examples.each_value do |example| example.keep_if(&@test_set.examples.method(:include?)) end end
install_hooks()
click to toggle source
# File lib/mutiny/integration/rspec/runner.rb, line 55 def install_hooks @hooks.each { |hook| hook.install(configuration) } end
listen_for_example_results()
click to toggle source
# File lib/mutiny/integration/rspec/runner.rb, line 65 def listen_for_example_results configuration.reporter.register_listener(self, :example_passed) configuration.reporter.register_listener(self, :example_failed) end
prepare()
click to toggle source
# File lib/mutiny/integration/rspec/runner.rb, line 31 def prepare install_hooks filter_examples listen_for_example_results end
reset()
click to toggle source
# File lib/mutiny/integration/rspec/runner.rb, line 26 def reset @passed_examples = [] @failed_examples = [] end
run()
click to toggle source
# File lib/mutiny/integration/rspec/runner.rb, line 37 def run start = Time.now runner.run_specs(world.ordered_example_groups) output.rewind runtime = Time.now - start create_test_run(output.read, runtime) end