Skip to content

Instantly share code, notes, and snippets.

@jhawthorn
Created September 4, 2015 21:07
Show Gist options
  • Save jhawthorn/2910761cd64fcc9d8bd8 to your computer and use it in GitHub Desktop.
Save jhawthorn/2910761cd64fcc9d8bd8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
class Example
attr_reader :spec_name, :status
def initialize(example_id, status, run_time, _)
@example_id = example_id
@status = status
@run_time = run_time
end
end
all_examples = ARGV.flat_map do |example_file|
lines = File.read(example_file).lines
lines.shift(2)
lines.map do |line|
Example.new(*line.split(/\s+\|\s+?/, -1))
end
end
counts = Hash.new(0)
total_count = 0
all_examples.each do |example|
counts[example.status] += 1
total_count += 1
end
out = "#{total_count} examples, #{counts['failed']} failures"
out << ", #{counts['pending']} pending" if counts.has_key?('pending')
puts out
exit counts['failed']
@jhawthorn
Copy link
Author

Usage:

$ rspec-report */spec/examples.txt   # combine results of rspec in separate projects
4121 examples, 0 failures, 11 pending
$ echo $?   # return success if none of the examples.txt had any failures
0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment