Created
May 26, 2013 16:28
-
-
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.
This file contains 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
#!/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