Created
August 15, 2014 09:37
-
-
Save rocknrollMarc/6dc6de955276c2c13a64 to your computer and use it in GitHub Desktop.
ruby Step definition parser cucumber, gherkin
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
step_definition_dir = "../features/step_definitions" | |
steps = [] | |
Dir.glob(File.join(step_definition_dir,'**/*.rb')).each do |step_file| | |
File.new(step_file).read.each_line do |line| | |
next unless line =~ /^\s*(?:Given|When|Then)\s+\// | |
matches = /(Given|When|Then)\s*\/(.*)\/([imxo]*)\s*do\s*(?:$|\|(.*)\|)/.match(line).captures | |
type = matches[0] | |
matches[1] = Regexp.new(matches[1]) | |
step = matches[1].inspect | |
step = step[2..step.length-3] | |
steps << type + " " + step | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment