Skip to content

Instantly share code, notes, and snippets.

@erithmetic
Forked from gdi/gist:180470
Created September 4, 2009 00:34
Show Gist options
  • Save erithmetic/180638 to your computer and use it in GitHub Desktop.
Save erithmetic/180638 to your computer and use it in GitHub Desktop.
# Rake task for listing all Cucumber features defined
namespace :cucumber do
task :features 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