Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RSpec 4 support #89

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/test_queue/runner/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
require_relative 'rspec2'
when 3
require_relative 'rspec3'
when 4
require_relative 'rspec4'
else
fail 'requires rspec version 2 or 3'
fail 'requires rspec version 2, 3 or 4'
end

module TestQueue
Expand Down
40 changes: 40 additions & 0 deletions lib/test_queue/runner/rspec4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class ::RSpec::Core::ExampleGroup
def self.failure_count
examples.map {|e| e.execution_result.status == "failed"}.length
end
end

module RSpec::Core
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_method :run_each, :run_specs
end
end