Last active
December 10, 2015 23:38
-
-
Save jipiboily/4510538 to your computer and use it in GitHub Desktop.
RSpec: top failing specs report
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------ | |
Top failing specs | |
------------------------------------------------ | |
18 | ./spec/models/my_model_spec.rb | |
4 | ./spec/models/your_failing_model_spec.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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