Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created September 19, 2012 15:43
Show Gist options
  • Save thinkerbot/3750370 to your computer and use it in GitHub Desktop.
Save thinkerbot/3750370 to your computer and use it in GitHub Desktop.
First attempt to collate cucumber steps into ruby
#!/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