Skip to content

Instantly share code, notes, and snippets.

@puyo
Last active September 28, 2015 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puyo/98ddc7ea93e7a4b5657e to your computer and use it in GitHub Desktop.
Save puyo/98ddc7ea93e7a4b5657e to your computer and use it in GitHub Desktop.
rspec-blame-filter
#!/usr/bin/ruby
# Annotates RSpec output with contact details of the person who wrote the tests that are failing.
#
# Setup:
#
# gem install colorize
#
# Usage:
#
# rspec | scripts/rspec-blame-filter
#
# or:
#
# scripts/rspec-blame-filter
#
# and paste rspec output, ^D to quit.
#
gem 'colorize'
require 'colorize'
ARGF.each_line do |line|
if m = line.match(/rspec (.*?\.rb):(\d+)/)
path, num = m.captures
cmd = "git blame --date short -e -M -w -L #{num},#{num} -- #{path}"
out = `#{cmd}`
print line.strip
print ' '
print out.strip.white.on_red
puts
else
print line
end
end
@puyo
Copy link
Author

puyo commented Sep 28, 2015

This code is really nice.

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