Skip to content

Instantly share code, notes, and snippets.

@jipiboily
Last active December 10, 2015 23:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jipiboily/4510538 to your computer and use it in GitHub Desktop.
Save jipiboily/4510538 to your computer and use it in GitHub Desktop.
RSpec: top failing specs report
------------------------------------------------
Top failing specs
------------------------------------------------
18 | ./spec/models/my_model_spec.rb
4 | ./spec/models/your_failing_model_spec.rb
RSpec.configure do |config|
failed_examples = {}
config.after(:each) do |group|
if group.example.instance_variable_get("@exception")
failed_examples[group.example.metadata[:file_path]] ||= 0
failed_examples[group.example.metadata[:file_path]] = failed_examples[group.example.metadata[:file_path]] + 1
end
end
config.after(:suite) do
if failed_examples != {}
puts '------------------------------------------------'
puts ' Top failing specs '
puts '------------------------------------------------'
failed_examples.sort_by {|k,v| v}.reverse.each do |k,v|
puts "#{v.to_s.rjust(3)} | #{k}"
end
puts '------------------------------------------------'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment