Created
March 29, 2016 08:59
-
-
Save threedaymonk/2ecbae0a632c90ed02e7 to your computer and use it in GitHub Desktop.
Annotate failing Cucumber scenarios with @broken
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
failures = {} | |
ARGF.read.split(/\n/).each do |line| | |
matches = line.match(/\Acucumber ([^:]+):(\d+)/) or next | |
(failures[matches[1]] ||= []) << matches[2].to_i - 1 | |
end | |
failures.each do |file, indices| | |
lines = File.readlines(file) | |
indices.reverse.each do |index| | |
indentation = lines[index][/\A\s+/] | |
lines = lines.take(index) + ["#{indentation}@broken\n"] + lines.drop(index) | |
end | |
File.open(file, 'w') do |io| | |
io << lines.join('') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment