Skip to content

Instantly share code, notes, and snippets.

@jdickey
Created May 26, 2013 16:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdickey/5653262 to your computer and use it in GitHub Desktop.
Save jdickey/5653262 to your computer and use it in GitHub Desktop.
FindBreaks - find and list all spec files that broke due to your world-changing one-liner just now.
#!/usr/bin/env ruby
# findbreaks 0.9
# Script to find all spec files in an `rspec` run that report errors and produce
# a list of all failed spec filenames, with each such listed once. Useful if you
# have numerous specs that break due to a world-changing edit you've just made,
# and you want a nice list of the broken specs without having to read through
# hundreds of lines of RSpec bleeding on your terminal. Pick one; fix it; run
# this again; repeat.
#
# Written 27 May 2013 by jdickey at seven-sigma dot com and released under the
# MIT license. Forks and bug reports welcome.
def findbreaks
tmpf = "/tmp/breaks#{rand 1000}"
system 'rspec --no-colour >' + tmpf
lines = []
File.open(tmpf, 'r') do |file|
while line = file.gets
lines << line
end
end
File.unlink tmpf
lines.
drop_while {|line| !line.match /Failed examples:/}.
reject{|line| !line.match /\Arspec \./}.
collect{|line| line.match(/rspec (.+?)\:\d+? /)[1]}.
uniq.
sort
end
unless ARGV.nil?
puts findbreaks
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment