Created
September 19, 2012 15:43
-
-
Save thinkerbot/3750370 to your computer and use it in GitHub Desktop.
First attempt to collate cucumber steps into ruby
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
#!/usr/bin/env ruby | |
# Cucumber prints output with the step location, this collates those steps into a script. | |
# It doesn't work fantastic, though -- it doesn't follow nested steps, for instance. | |
# | |
while line = gets | |
next unless line =~ /(.*)\s+# (\/.*)$/ | |
desc = $1.strip | |
file, line = $2.strip.split(':', 2) | |
id = "# #{desc} - #{file}:#{line}" | |
File.open(file) do |io| | |
line.to_i.times { io.gets } | |
while code = io.gets | |
break if code =~ /^end/ | |
puts "%-80s%s" % [code.chomp("\n"), id] | |
id = nil | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment