Created
September 3, 2009 19:03
-
-
Save gdi/180470 to your computer and use it in GitHub Desktop.
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
# Rake task for listing all Cucumber steps defined | |
namespace :cucumber do | |
task :steps do | |
list = { :given => [], :when => [], :then => [] } | |
files = Dir.glob(File.join(File.dirname(__FILE__),'features','**','*.rb')).each do |f| | |
File.readlines(f).select { |l| l =~ /\s*[^#]?\s*(Given|When|Then)\s\// }.each do |line| | |
line =~ /(Given|When|Then)\s+(\/\^?)?([^$\/]+)(\$?\/)?/ | |
type = $1.downcase.to_sym | |
name = "#{$1} #{$3}".strip | |
list[type] << name | |
end | |
end | |
puts "Looked in files #{files.map { |f| File.basename(f) }.join(", ")}" | |
puts "\nGivens\n====================" | |
puts list[:given].sort.join("\n") | |
puts "\nWhens\n====================" | |
puts list[:when].sort.join("\n") | |
puts "\nThens\n====================" | |
puts list[:then].sort.join("\n") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment