-
Notifications
You must be signed in to change notification settings - Fork 74
/
rspec_ext.rb
54 lines (49 loc) · 1.39 KB
/
rspec_ext.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# frozen_string_literal: true
class ::RSpec::Core::ExampleGroup
def self.failure_count
examples.map { |e| e.execution_result.status == 'failed' }.length
end
end
module RSpec::Core
# RSpec 3.2 introduced:
unless Configuration.method_defined?(:with_suite_hooks)
class Configuration
def with_suite_hooks
hook_context = SuiteHookContext.new
hooks.run(:before, :suite, hook_context)
yield
ensure
hooks.run(:after, :suite, hook_context)
end
end
end
class QueueRunner < Runner
def initialize
options = ConfigurationOptions.new(ARGV)
super(options)
end
def run_specs(iterator)
@configuration.reporter.report(0) do |reporter|
@configuration.with_suite_hooks do
iterator.map { |g|
start = Time.now
if g.is_a? ::RSpec::Core::Example
print " #{g.full_description}: "
example = g
g = example.example_group
::RSpec.world.filtered_examples.clear
::RSpec.world.filtered_examples[g] = [example]
else
print " #{g.description}: "
end
ret = g.run(reporter)
diff = Time.now - start
puts(' <%.3f>' % diff)
ret
}.all? ? 0 : @configuration.failure_exit_code
end
end
end
alias run_each run_specs
end
end