Skip to content

Instantly share code, notes, and snippets.

@s2k
Created November 8, 2010 10:14
Show Gist options
  • Save s2k/667546 to your computer and use it in GitHub Desktop.
Save s2k/667546 to your computer and use it in GitHub Desktop.
Find and list the Cucumber step definitions in a project
path = File.join( File.dirname( __FILE__), 'features', 'step_definitions', '**', '*.rb' )
Dir[ path ].each{ | sdf |
puts "In #{ sdf }:"
lines = File.read( sdf )
puts lines
puts "STEPS"
lines.scan( /^\s*(Given|When|Then|And|But)\s+(.+)\s+(do|\{)(\s+\|.+\|)?$/ ).map{ | m |
# pp match
puts "#{ m[0] }: #{ m[ 1 ] }"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment