cucumber 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. data/History.txt +3 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +152 -0
  4. data/README.txt +42 -0
  5. data/Rakefile +4 -0
  6. data/TODO.txt +26 -0
  7. data/bin/cucumber +4 -0
  8. data/config/hoe.rb +69 -0
  9. data/config/requirements.rb +15 -0
  10. data/cucumber.yml +1 -0
  11. data/examples/calculator/Rakefile +6 -0
  12. data/examples/calculator/cucumber.yml +1 -0
  13. data/examples/calculator/features/addition.feature +16 -0
  14. data/examples/calculator/features/division.feature +10 -0
  15. data/examples/calculator/features/steps/calculator_steps.rb +31 -0
  16. data/examples/calculator/lib/calculator.rb +16 -0
  17. data/examples/calculator_ruby_features/Rakefile +6 -0
  18. data/examples/calculator_ruby_features/features/addition.rb +23 -0
  19. data/examples/calculator_ruby_features/features/steps/calculator_steps.rb +43 -0
  20. data/examples/calculatrice_francaise_avec_soit_scenario/Rakefile +6 -0
  21. data/examples/calculatrice_francaise_avec_soit_scenario/features/addition.feature +13 -0
  22. data/examples/calculatrice_francaise_avec_soit_scenario/features/calculatrice_steps.rb +31 -0
  23. data/examples/cs/README.textile +22 -0
  24. data/examples/cs/Rakefile +12 -0
  25. data/examples/cs/features/hello.feature +11 -0
  26. data/examples/cs/features/steps/hello_steps.rb +25 -0
  27. data/examples/cs/features/steps/tree_steps.rb +14 -0
  28. data/examples/cs/features/tree.feature +9 -0
  29. data/examples/cs/src/Hello.cs +18 -0
  30. data/examples/danish_calculator/Rakefile +6 -0
  31. data/examples/danish_calculator/features/steps/kalkulator_steps.rb +22 -0
  32. data/examples/danish_calculator/features/summering.feature +17 -0
  33. data/examples/danish_calculator/lib/kalkulator.rb +11 -0
  34. data/examples/estonian_calculator/Rakefile +6 -0
  35. data/examples/estonian_calculator/features/kalkulaator_steps.rb +35 -0
  36. data/examples/estonian_calculator/features/liitmine.feature +16 -0
  37. data/examples/java/README.textile +22 -0
  38. data/examples/java/Rakefile +12 -0
  39. data/examples/java/features/hello.feature +11 -0
  40. data/examples/java/features/steps/hello_steps.rb +25 -0
  41. data/examples/java/features/steps/tree_steps.rb +14 -0
  42. data/examples/java/features/tree.feature +9 -0
  43. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  44. data/examples/norwegian_calculator/Rakefile +6 -0
  45. data/examples/norwegian_calculator/features/steps/kalkulator_steps.rb +22 -0
  46. data/examples/norwegian_calculator/features/summering.feature +17 -0
  47. data/examples/norwegian_calculator/lib/kalkulator.rb +11 -0
  48. data/examples/portuguese_calculator/Rakefile +6 -0
  49. data/examples/portuguese_calculator/features/adicao.feature +10 -0
  50. data/examples/portuguese_calculator/features/calculadora_steps.rb +31 -0
  51. data/examples/selenium/Rakefile +6 -0
  52. data/examples/selenium/features/search.feature +9 -0
  53. data/examples/selenium/features/steps/stories_steps.rb +41 -0
  54. data/examples/spanish_calculator/Rakefile +6 -0
  55. data/examples/spanish_calculator/features/adicion.feature +17 -0
  56. data/examples/spanish_calculator/features/steps/calculador_steps.rb +22 -0
  57. data/examples/spanish_calculator/lib/Calculador.rb +11 -0
  58. data/examples/tickets/Rakefile +4 -0
  59. data/examples/tickets/features/steps/tickets_steps.rb +5 -0
  60. data/examples/tickets/features/tickets.feature +7 -0
  61. data/examples/watir/Rakefile +6 -0
  62. data/examples/watir/features/search.feature +9 -0
  63. data/examples/watir/features/steps/stories_steps.rb +51 -0
  64. data/features/see_features.feature +8 -0
  65. data/features/steps/features_steps.rb +9 -0
  66. data/gem_tasks/deployment.rake +34 -0
  67. data/gem_tasks/environment.rake +7 -0
  68. data/gem_tasks/features.rake +6 -0
  69. data/gem_tasks/fix_cr_lf.rake +10 -0
  70. data/gem_tasks/flog.rake +4 -0
  71. data/gem_tasks/gemspec.rake +6 -0
  72. data/gem_tasks/rspec.rake +21 -0
  73. data/gem_tasks/treetop.rake +27 -0
  74. data/generators/cucumber/cucumber_generator.rb +27 -0
  75. data/generators/cucumber/templates/common_webrat.rb +51 -0
  76. data/generators/cucumber/templates/cucumber +2 -0
  77. data/generators/cucumber/templates/cucumber.rake +7 -0
  78. data/generators/cucumber/templates/env.rb +8 -0
  79. data/generators/feature/feature_generator.rb +17 -0
  80. data/generators/feature/templates/feature.erb +27 -0
  81. data/generators/feature/templates/steps.erb +22 -0
  82. data/lib/cucumber.rb +32 -0
  83. data/lib/cucumber/cli.rb +163 -0
  84. data/lib/cucumber/core_ext/proc.rb +43 -0
  85. data/lib/cucumber/core_ext/string.rb +22 -0
  86. data/lib/cucumber/executor.rb +120 -0
  87. data/lib/cucumber/formatters.rb +1 -0
  88. data/lib/cucumber/formatters/ansicolor.rb +90 -0
  89. data/lib/cucumber/formatters/cucumber.css +132 -0
  90. data/lib/cucumber/formatters/cucumber.js +11 -0
  91. data/lib/cucumber/formatters/html_formatter.rb +125 -0
  92. data/lib/cucumber/formatters/jquery.js +32 -0
  93. data/lib/cucumber/formatters/pretty_formatter.rb +126 -0
  94. data/lib/cucumber/formatters/progress_formatter.rb +42 -0
  95. data/lib/cucumber/languages.yml +83 -0
  96. data/lib/cucumber/rails/rspec.rb +12 -0
  97. data/lib/cucumber/rails/world.rb +75 -0
  98. data/lib/cucumber/rake/task.rb +75 -0
  99. data/lib/cucumber/step_methods.rb +45 -0
  100. data/lib/cucumber/step_mother.rb +82 -0
  101. data/lib/cucumber/tree.rb +18 -0
  102. data/lib/cucumber/tree/feature.rb +53 -0
  103. data/lib/cucumber/tree/features.rb +21 -0
  104. data/lib/cucumber/tree/given_scenario.rb +13 -0
  105. data/lib/cucumber/tree/scenario.rb +110 -0
  106. data/lib/cucumber/tree/step.rb +123 -0
  107. data/lib/cucumber/tree/table.rb +26 -0
  108. data/lib/cucumber/tree/top_down_visitor.rb +23 -0
  109. data/lib/cucumber/treetop_parser/feature.treetop.erb +159 -0
  110. data/lib/cucumber/treetop_parser/feature_da.rb +1214 -0
  111. data/lib/cucumber/treetop_parser/feature_de.rb +1214 -0
  112. data/lib/cucumber/treetop_parser/feature_en.rb +1214 -0
  113. data/lib/cucumber/treetop_parser/feature_es.rb +1214 -0
  114. data/lib/cucumber/treetop_parser/feature_et.rb +1214 -0
  115. data/lib/cucumber/treetop_parser/feature_fr.rb +1214 -0
  116. data/lib/cucumber/treetop_parser/feature_no.rb +1214 -0
  117. data/lib/cucumber/treetop_parser/feature_parser.rb +32 -0
  118. data/lib/cucumber/treetop_parser/feature_pt.rb +1214 -0
  119. data/lib/cucumber/treetop_parser/feature_ru.rb +1214 -0
  120. data/lib/cucumber/treetop_parser/feature_se.rb +1214 -0
  121. data/lib/cucumber/version.rb +9 -0
  122. data/script/console +10 -0
  123. data/script/console.cmd +1 -0
  124. data/script/destroy +14 -0
  125. data/script/destroy.cmd +1 -0
  126. data/script/generate +14 -0
  127. data/script/generate.cmd +1 -0
  128. data/script/txt2html +74 -0
  129. data/script/txt2html.cmd +1 -0
  130. data/setup.rb +1585 -0
  131. data/spec/cucumber/cli_spec.rb +36 -0
  132. data/spec/cucumber/core_ext/proc_spec.rb +39 -0
  133. data/spec/cucumber/core_ext/string_spec.rb +34 -0
  134. data/spec/cucumber/executor_spec.rb +131 -0
  135. data/spec/cucumber/formatters/ansicolor_spec.rb +23 -0
  136. data/spec/cucumber/formatters/features.html +269 -0
  137. data/spec/cucumber/formatters/html_formatter_spec.rb +59 -0
  138. data/spec/cucumber/formatters/pretty_formatter_spec.rb +17 -0
  139. data/spec/cucumber/formatters/progress_formatter_spec.rb +44 -0
  140. data/spec/cucumber/sell_cucumbers.feature +9 -0
  141. data/spec/cucumber/step_mother_spec.rb +53 -0
  142. data/spec/cucumber/tree/scenario_spec.rb +15 -0
  143. data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
  144. data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
  145. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +73 -0
  146. data/spec/cucumber/treetop_parser/fit_scenario.feature +7 -0
  147. data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
  148. data/spec/cucumber/treetop_parser/multiple_tables.feature +27 -0
  149. data/spec/cucumber/treetop_parser/spaces.feature +10 -0
  150. data/spec/cucumber/treetop_parser/with_comments.feature +6 -0
  151. data/spec/spec.opts +2 -0
  152. data/spec/spec_helper.rb +23 -0
  153. metadata +259 -0
@@ -0,0 +1,10 @@
1
+ desc 'Make all files use UNIX (\n) line endings'
2
+ task :fix_cr_lf do
3
+ files = FileList['**/*']
4
+ files.each do |f|
5
+ next if File.directory?(f)
6
+ s = IO.read(f)
7
+ s.gsub!(/\r?\n/, "\n")
8
+ File.open(f, "w") { |io| io.write(s) }
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ desc "Run flog over significant files"
2
+ task :flog do
3
+ sh "find lib -name \\*.rb | grep -v feature_..\\.rb | xargs flog"
4
+ end
@@ -0,0 +1,6 @@
1
+ namespace :gemspec do
2
+ desc 'Refresh cucumber.gemspec to include ALL files'
3
+ task :refresh => 'manifest:refresh' do
4
+ File.open('cucumber.gemspec', 'w') {|io| io.write($hoe.spec.to_ruby)}
5
+ end
6
+ end
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
@@ -0,0 +1,27 @@
1
+ class FeatureCompiler
2
+ def compile
3
+ require 'yaml'
4
+ require 'erb'
5
+ tt = PLATFORM =~ /mswin|mingw/ ? 'tt.bat' : 'tt'
6
+
7
+ template = ERB.new(IO.read(File.dirname(__FILE__) + '/../lib/cucumber/treetop_parser/feature.treetop.erb'))
8
+ langs = YAML.load_file(File.dirname(__FILE__) + '/../lib/cucumber/languages.yml')
9
+
10
+ langs.each do |lang, words|
11
+ grammar_file = File.dirname(__FILE__) + "/../lib/cucumber/treetop_parser/feature_#{lang}.treetop"
12
+ grammar = template.result(binding)
13
+ File.open(grammar_file, "wb") do |io|
14
+ io.write(grammar)
15
+ end
16
+ sh "#{tt} #{grammar_file}"
17
+ FileUtils.rm(grammar_file)
18
+ end
19
+ end
20
+ end
21
+
22
+ namespace :treetop do
23
+ desc 'Compile the grammar for all languages in languages.yml'
24
+ task :compile do
25
+ FeatureCompiler.new.compile
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'rbconfig'
2
+
3
+ # This generator bootstraps a Rails project for use with Cucumber
4
+ class CucumberGenerator < Rails::Generator::Base
5
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
6
+ Config::CONFIG['ruby_install_name'])
7
+ def manifest
8
+ record do |m|
9
+ script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
10
+
11
+ m.directory 'features/steps'
12
+ m.file 'env.rb', 'features/steps/env.rb'
13
+ m.file 'common_webrat.rb', 'features/steps/common_webrat.rb'
14
+
15
+ m.directory 'lib/tasks'
16
+ m.file 'cucumber.rake', 'lib/tasks/cucumber.rake'
17
+ m.file 'cucumber', 'script/cucumber', script_options
18
+ end
19
+ end
20
+
21
+ protected
22
+
23
+ def banner
24
+ "Usage: #{$0} cucumber"
25
+ end
26
+
27
+ end
@@ -0,0 +1,51 @@
1
+ # Commonly used webrat steps
2
+ # http://github.com/brynary/webrat
3
+
4
+ When /^I press "(.*)"$/ do |button|
5
+ clicks_button(button)
6
+ end
7
+
8
+ When /^I follow "(.*)"$/ do |link|
9
+ clicks_link(link)
10
+ end
11
+
12
+ When /^I fill in "(.*)" with "(.*)"$/ do |field, value|
13
+ fills_in(field, :with => value)
14
+ end
15
+
16
+ When /^I select "(.*)" from "(.*)"$/ do |field, value|
17
+ selects(field, :with => value)
18
+ end
19
+
20
+ When /^I check "(.*)"$/ do |field|
21
+ checks(field)
22
+ end
23
+
24
+ When /^I uncheck "(.*)"$/ do |field|
25
+ unchecks(field)
26
+ end
27
+
28
+ When /^I choose "(.*)"$/ do |field|
29
+ chooses(field)
30
+ end
31
+
32
+ When /^I attach the file at "(.*)" to "(.*)" $/ do |path, field|
33
+ attaches_file(field, path)
34
+ end
35
+
36
+ When /^I go to (.*)$/ do |page|
37
+ visits case page
38
+ when "the home page"
39
+ "/"
40
+ else
41
+ raise "Can't find mapping from \"#{page}\" to a path"
42
+ end
43
+ end
44
+
45
+ Then /^I should see "(.*)"$/ do |text|
46
+ response.body.should =~ /#{text}/m
47
+ end
48
+
49
+ Then /^I should not see "(.*)"$/ do |text|
50
+ response.body.should_not =~ /#{text}/m
51
+ end
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ load File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/cucumber/bin/cucumber")
@@ -0,0 +1,7 @@
1
+ $:.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
2
+ require 'cucumber/rake/task'
3
+
4
+ Cucumber::Rake::Task.new(:features) do |t|
5
+ t.cucumber_opts = "--format pretty"
6
+ end
7
+ task :features => 'db:test:prepare'
@@ -0,0 +1,8 @@
1
+ # Sets up the Rails environment for Cucumber
2
+ ENV["RAILS_ENV"] = "test"
3
+ require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
4
+ require 'cucumber/rails/world'
5
+ Cucumber::Rails.use_transactional_fixtures
6
+
7
+ # Comment out the next line if you're not using RSpec's matchers (should / should_not) in your steps.
8
+ require 'cucumber/rails/rspec'
@@ -0,0 +1,17 @@
1
+ # This generator bootstraps a Rails project for use with Cucumber
2
+ class FeatureGenerator < Rails::Generator::NamedBase
3
+ def manifest
4
+ record do |m|
5
+ m.directory 'features/steps'
6
+ m.template 'feature.erb', "features/manage_#{plural_name}.feature"
7
+ m.template 'steps.erb', "features/steps/#{singular_name}_steps.rb"
8
+ end
9
+ end
10
+
11
+ protected
12
+
13
+ def banner
14
+ "Usage: #{$0} cucumber"
15
+ end
16
+
17
+ end
@@ -0,0 +1,27 @@
1
+ Feature: Manage <%= plural_name %>
2
+ In order to keep track of <%= plural_name %>
3
+ A <%= singular_name %> mechanic
4
+ Should be able to manage several <%= plural_name %>
5
+
6
+ Scenario: Register new <%= singular_name %>
7
+ Given I am on the new <%= singular_name %> page
8
+ <% keyword = 'When' -%>
9
+ <% args.each do |arg| -%>
10
+ <%= keyword %> I fill in "<%= arg.humanize %>" with "My <%= singular_name %> <%= arg %>"
11
+ <% keyword = 'And' -%>
12
+ <% end -%>
13
+ And I press "Create"
14
+ <% keyword = 'Then' -%>
15
+ <% args.each do |arg| -%>
16
+ <%= keyword %> I should see "My <%= singular_name %> <%= arg %>"
17
+ <% keyword = 'And' -%>
18
+ <% end -%>
19
+
20
+ Scenario: Delete <%= singular_name %>
21
+ Given there are 4 <%= plural_name %>
22
+ When I delete the first <%= singular_name %>
23
+ Then there should be 3 <%= plural_name %> left
24
+
25
+ | initial | after |
26
+ | 100 | 99 |
27
+ | 1 | 0 |
@@ -0,0 +1,22 @@
1
+ Given /I am on the new <%= singular_name %> page/ do
2
+ visits "/<%= plural_name %>/new"
3
+ end
4
+
5
+ Given /there are (\d+) <%= plural_name %>/ do |n|
6
+ <%= class_name %>.transaction do
7
+ <%= class_name %>.destroy_all
8
+ n.to_i.times do |n|
9
+ <%= class_name %>.create! :name => "<%= class_name %> #{n}"
10
+ end
11
+ end
12
+ end
13
+
14
+ When /I delete the first <%= singular_name %>/ do
15
+ visits <%= plural_name %>_url
16
+ clicks_link "Destroy"
17
+ end
18
+
19
+ Then /there should be (\d+) <%= plural_name %> left/ do |n|
20
+ <%= class_name %>.count.should == n.to_i
21
+ response.should have_tag("table tr", n.to_i + 1) # There is a header row too
22
+ end
@@ -0,0 +1,32 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+ require 'rubygems'
4
+ require 'treetop/runtime'
5
+ require 'treetop/ruby_extensions'
6
+ require 'cucumber/version'
7
+ require 'cucumber/step_methods'
8
+ require 'cucumber/tree'
9
+ require 'cucumber/executor'
10
+ require 'cucumber/step_mother'
11
+ require 'cucumber/formatters'
12
+ require 'cucumber/treetop_parser/feature_parser'
13
+ require 'cucumber/cli'
14
+
15
+ module Cucumber
16
+ class << self
17
+ attr_reader :language
18
+
19
+ def load_language(lang)
20
+ @language = config[lang]
21
+ end
22
+
23
+ def languages
24
+ config.keys.sort
25
+ end
26
+
27
+ def config
28
+ require 'yaml'
29
+ @config ||= YAML.load_file(File.dirname(__FILE__) + '/cucumber/languages.yml')
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,163 @@
1
+ require 'optparse'
2
+ require 'cucumber'
3
+
4
+ module Cucumber
5
+ class CLI
6
+ class << self
7
+ attr_writer :step_mother, :features
8
+
9
+ def execute
10
+ @execute_called = true
11
+ parse(ARGV).execute!(@step_mother, @features)
12
+ end
13
+
14
+ def execute_called?
15
+ @execute_called
16
+ end
17
+
18
+ def parse(args)
19
+ cli = new
20
+ cli.parse_options!(args)
21
+ cli
22
+ end
23
+ end
24
+
25
+ attr_reader :options
26
+ FORMATS = %w{pretty progress html}
27
+
28
+ def initialize
29
+ @paths = []
30
+ end
31
+
32
+ def parse_options!(args)
33
+ return parse_args_from_profile('default') if args.empty?
34
+ args.extend(OptionParser::Arguable)
35
+
36
+ @options = { :require => nil, :lang => 'en', :format => 'pretty', :dry_run => false }
37
+ args.options do |opts|
38
+ opts.banner = "Usage: cucumber [options] FILES|DIRS"
39
+ opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR", "Require files before executing the features.",
40
+ "If this option is not specified, all *.rb files that",
41
+ "are siblings or below the features will be autorequired") do |v|
42
+ @options[:require] ||= []
43
+ @options[:require] << v
44
+ end
45
+ opts.on("-l LINE", "--line LINE", "Only execute the scenario at the given line") do |v|
46
+ @options[:line] = v
47
+ end
48
+ opts.on("-a LANG", "--language LANG", "Specify language for features (Default: #{@options[:lang]})",
49
+ "Available languages: #{Cucumber.languages.join(", ")}") do |v|
50
+ @options[:lang] = v
51
+ end
52
+ opts.on("-f FORMAT", "--format FORMAT", "How to format features (Default: #{@options[:format]})",
53
+ "Available formats: #{FORMATS.join(", ")}") do |v|
54
+ unless FORMATS.index(v)
55
+ STDERR.puts "Invalid format: #{v}\n"
56
+ STDERR.puts opts.help
57
+ exit 1
58
+ end
59
+ @options[:format] = v
60
+ end
61
+ opts.on("-p=PROFILE", "--profile=PROFILE", "Pull commandline arguments from cucumber.yml.") do |v|
62
+ parse_args_from_profile(v)
63
+ end
64
+ opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.") do
65
+ @options[:dry_run] = true
66
+ end
67
+ opts.on_tail("--version", "Show version") do
68
+ puts VERSION::STRING
69
+ exit
70
+ end
71
+ opts.on_tail("--help", "You're looking at it") do
72
+ puts opts.help
73
+ exit
74
+ end
75
+ end.parse!
76
+
77
+ # Whatever is left after option parsing is the FILE arguments
78
+ @paths += args
79
+ end
80
+
81
+ def parse_args_from_profile(profile)
82
+ require 'yaml'
83
+ cucumber_yml = YAML::load(IO.read('cucumber.yml'))
84
+ args_from_yml = cucumber_yml[profile]
85
+ raise "Expected to find a String, got #{args_from_yml.inspect}. cucumber.yml:\n#{cucumber_yml}" unless String === args_from_yml
86
+ parse_options!(args_from_yml.split(' '))
87
+ end
88
+
89
+ def execute!(step_mother, features)
90
+ Cucumber.load_language(@options[:lang])
91
+ $executor = Executor.new(formatter(step_mother), step_mother)
92
+ require_files
93
+ load_plain_text_features(features)
94
+ $executor.line = @options[:line].to_i if @options[:line]
95
+ $executor.visit_features(features)
96
+ exit 1 if $executor.failed
97
+ end
98
+
99
+ private
100
+
101
+ # Requires files - typically step files and ruby feature files.
102
+ def require_files
103
+ ARGV.clear # Shut up RSpec
104
+ require "cucumber/treetop_parser/feature_#{@options[:lang]}"
105
+ require "cucumber/treetop_parser/feature_parser"
106
+
107
+ requires = @options[:require] || feature_dirs
108
+ libs = requires.map do |path|
109
+ path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
110
+ File.directory?(path) ? Dir["#{path}/**/*.rb"] : path
111
+ end.flatten.uniq
112
+ libs.each do |lib|
113
+ begin
114
+ require lib
115
+ rescue LoadError => e
116
+ e.message << "\nFailed to load #{lib}"
117
+ raise e
118
+ end
119
+ end
120
+ end
121
+
122
+ def feature_files
123
+ @paths.map do |path|
124
+ path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
125
+ File.directory?(path) ? Dir["#{path}/**/*.feature"] : path
126
+ end.flatten.uniq
127
+ end
128
+
129
+ def feature_dirs
130
+ feature_files.map{|f| File.directory?(f) ? f : File.dirname(f)}.uniq
131
+ end
132
+
133
+ def load_plain_text_features(features)
134
+ parser = TreetopParser::FeatureParser.new
135
+
136
+ feature_files.each do |f|
137
+ features << parser.parse_feature(f)
138
+ end
139
+ end
140
+
141
+ def formatter(step_mother)
142
+ case @options[:format]
143
+ when 'pretty'
144
+ Formatters::PrettyFormatter.new(STDOUT)
145
+ when 'progress'
146
+ Formatters::ProgressFormatter.new(STDOUT)
147
+ when 'html'
148
+ Formatters::HtmlFormatter.new(STDOUT, step_mother)
149
+ end
150
+ end
151
+
152
+ end
153
+ end
154
+
155
+ extend Cucumber::StepMethods
156
+ Cucumber::CLI.step_mother = step_mother
157
+
158
+ extend(Cucumber::Tree)
159
+ Cucumber::CLI.features = features
160
+
161
+ at_exit do
162
+ Cucumber::CLI.execute unless Cucumber::CLI.execute_called?
163
+ end