aslakhellesoy-cucumber 0.1.99.3 → 0.1.99.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) hide show
  1. data/Manifest.txt +6 -0
  2. metadata +1 -1
  3. data/cucumber.yml +0 -1
  4. data/examples/cs/README.textile +0 -1
  5. data/examples/cs/Rakefile +0 -12
  6. data/examples/cs/compile.bat +0 -1
  7. data/examples/cs/features/addition.feature +0 -16
  8. data/examples/cs/features/step_definitons/calculator_steps.rb +0 -19
  9. data/examples/cs/src/demo/Calculator.cs +0 -20
  10. data/examples/dos_line_endings/Rakefile +0 -6
  11. data/examples/dos_line_endings/features/dos_line_endings.feature +0 -9
  12. data/examples/i18n/README.textile +0 -18
  13. data/examples/i18n/Rakefile +0 -32
  14. data/examples/i18n/ar/Rakefile +0 -6
  15. data/examples/i18n/ar/features/addition.feature +0 -17
  16. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +0 -28
  17. data/examples/i18n/ar/lib/calculator.rb +0 -10
  18. data/examples/i18n/da/Rakefile +0 -6
  19. data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +0 -24
  20. data/examples/i18n/da/features/summering.feature +0 -17
  21. data/examples/i18n/da/lib/kalkulator.rb +0 -11
  22. data/examples/i18n/de/Rakefile +0 -6
  23. data/examples/i18n/de/features/addition.feature +0 -16
  24. data/examples/i18n/de/features/division.feature +0 -9
  25. data/examples/i18n/de/features/step_definitons/calculator_steps.rb +0 -24
  26. data/examples/i18n/de/lib/calculator.rb +0 -14
  27. data/examples/i18n/en/Rakefile +0 -6
  28. data/examples/i18n/en/features/addition.feature +0 -16
  29. data/examples/i18n/en/features/division.feature +0 -9
  30. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +0 -24
  31. data/examples/i18n/en/lib/calculator.rb +0 -14
  32. data/examples/i18n/es/Rakefile +0 -6
  33. data/examples/i18n/es/features/adicion.feature +0 -17
  34. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +0 -24
  35. data/examples/i18n/es/lib/calculador.rb +0 -11
  36. data/examples/i18n/et/Rakefile +0 -6
  37. data/examples/i18n/et/features/liitmine.feature +0 -17
  38. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +0 -24
  39. data/examples/i18n/et/lib/kalkulaator.rb +0 -10
  40. data/examples/i18n/fi/Rakefile +0 -6
  41. data/examples/i18n/fi/features/jakolasku.feature +0 -9
  42. data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +0 -24
  43. data/examples/i18n/fi/features/yhteenlasku.feature +0 -16
  44. data/examples/i18n/fi/lib/laskin.rb +0 -14
  45. data/examples/i18n/fr/Rakefile +0 -6
  46. data/examples/i18n/fr/features/addition.feature +0 -15
  47. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +0 -27
  48. data/examples/i18n/fr/lib/calculatrice.rb +0 -10
  49. data/examples/i18n/id/Rakefile +0 -6
  50. data/examples/i18n/id/features/addition.feature +0 -16
  51. data/examples/i18n/id/features/division.feature +0 -9
  52. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +0 -24
  53. data/examples/i18n/id/lib/calculator.rb +0 -14
  54. data/examples/i18n/it/Rakefile +0 -6
  55. data/examples/i18n/it/features/somma.feature +0 -10
  56. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +0 -24
  57. data/examples/i18n/it/lib/calcolatrice.rb +0 -11
  58. data/examples/i18n/ja/README.txt +0 -5
  59. data/examples/i18n/ja/Rakefile +0 -6
  60. data/examples/i18n/ja/features/addition.feature +0 -16
  61. data/examples/i18n/ja/features/division.feature +0 -9
  62. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +0 -24
  63. data/examples/i18n/ja/lib/calculator.rb +0 -14
  64. data/examples/i18n/ko/Rakefile +0 -6
  65. data/examples/i18n/ko/features/addition.feature +0 -16
  66. data/examples/i18n/ko/features/division.feature +0 -10
  67. data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +0 -24
  68. data/examples/i18n/ko/lib/calculator.rb +0 -14
  69. data/examples/i18n/lt/Rakefile +0 -6
  70. data/examples/i18n/lt/features/addition.feature +0 -17
  71. data/examples/i18n/lt/features/division.feature +0 -9
  72. data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +0 -24
  73. data/examples/i18n/lt/lib/calculator.rb +0 -14
  74. data/examples/i18n/no/Rakefile +0 -6
  75. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +0 -24
  76. data/examples/i18n/no/features/summering.feature +0 -18
  77. data/examples/i18n/no/lib/kalkulator.rb +0 -11
  78. data/examples/i18n/pt/Rakefile +0 -6
  79. data/examples/i18n/pt/features/adicao.feature +0 -10
  80. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +0 -24
  81. data/examples/i18n/pt/lib/calculadora.rb +0 -10
  82. data/examples/i18n/ro/Rakefile +0 -6
  83. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +0 -24
  84. data/examples/i18n/ro/features/suma.feature +0 -10
  85. data/examples/i18n/ro/lib/calculator.rb +0 -11
  86. data/examples/i18n/se/Rakefile +0 -6
  87. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +0 -24
  88. data/examples/i18n/se/features/summering.feature +0 -17
  89. data/examples/i18n/se/lib/kalkulator.rb +0 -11
  90. data/examples/i18n/zh-CN/Rakefile +0 -6
  91. data/examples/i18n/zh-CN/features/addition.feature +0 -17
  92. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +0 -26
  93. data/examples/i18n/zh-CN/lib/calculator.rb +0 -10
  94. data/examples/java/README.textile +0 -22
  95. data/examples/java/Rakefile +0 -12
  96. data/examples/java/features/hello.feature +0 -11
  97. data/examples/java/features/step_definitons/hello_steps.rb +0 -25
  98. data/examples/java/features/step_definitons/tree_steps.rb +0 -14
  99. data/examples/java/features/tree.feature +0 -9
  100. data/examples/jbehave/README.textile +0 -17
  101. data/examples/jbehave/features/support/env.rb +0 -7
  102. data/examples/jbehave/features/trading.feature +0 -24
  103. data/examples/jbehave/pom.xml +0 -48
  104. data/examples/selenium/Rakefile +0 -6
  105. data/examples/selenium/features/search.feature +0 -9
  106. data/examples/selenium/features/step_definitons/stories_steps.rb +0 -40
  107. data/examples/self_test/README.textile +0 -6
  108. data/examples/self_test/features/call_undefined_step_from_step_def.feature +0 -7
  109. data/examples/self_test/features/lots_of_undefined.feature +0 -8
  110. data/examples/self_test/features/outline_sample.feature +0 -12
  111. data/examples/self_test/features/sample.feature +0 -16
  112. data/examples/self_test/features/step_definitions/sample_steps.rb +0 -25
  113. data/examples/test_unit/Rakefile +0 -6
  114. data/examples/test_unit/features/step_definitions/test_unit_steps.rb +0 -26
  115. data/examples/test_unit/features/test_unit.feature +0 -9
  116. data/examples/tickets/Rakefile +0 -11
  117. data/examples/tickets/cucumber.yml +0 -2
  118. data/examples/tickets/features/lib/eatting_machine.rb +0 -18
  119. data/examples/tickets/features/lib/pantry.rb +0 -20
  120. data/examples/tickets/features/scenario_outline.feature +0 -90
  121. data/examples/tickets/features/step_definitons/scenario_outline_steps.rb +0 -42
  122. data/examples/tickets/features/step_definitons/tickets_steps.rb +0 -61
  123. data/examples/tickets/features/tickets.feature +0 -28
  124. data/examples/watir/README.textile +0 -16
  125. data/examples/watir/Rakefile +0 -6
  126. data/examples/watir/features/search.feature +0 -9
  127. data/examples/watir/features/step_definitons/search_steps.rb +0 -24
  128. data/examples/watir/features/support/env.rb +0 -32
  129. data/features/cucumber_cli.feature +0 -327
  130. data/features/cucumber_cli_outlines.feature +0 -81
  131. data/features/report_called_undefined_steps.feature +0 -32
  132. data/features/step_definitions/cucumber_steps.rb +0 -31
  133. data/features/step_definitions/extra_steps.rb +0 -2
  134. data/features/support/env.rb +0 -7
  135. data/gem_tasks/deployment.rake +0 -11
  136. data/gem_tasks/environment.rake +0 -7
  137. data/gem_tasks/features.rake +0 -6
  138. data/gem_tasks/fix_cr_lf.rake +0 -10
  139. data/gem_tasks/flog.rake +0 -4
  140. data/gem_tasks/gemspec.rake +0 -10
  141. data/gem_tasks/rspec.rake +0 -35
  142. data/gem_tasks/yard.rake +0 -8
  143. data/lib/autotest/cucumber.rb +0 -6
  144. data/lib/autotest/cucumber_mixin.rb +0 -124
  145. data/lib/autotest/cucumber_rails.rb +0 -6
  146. data/lib/autotest/cucumber_rails_rspec.rb +0 -6
  147. data/lib/autotest/cucumber_rspec.rb +0 -6
  148. data/lib/autotest/discover.rb +0 -9
  149. data/lib/cucumber/ast/comment.rb +0 -26
  150. data/lib/cucumber/ast/examples.rb +0 -22
  151. data/lib/cucumber/ast/feature.rb +0 -60
  152. data/lib/cucumber/ast/features.rb +0 -39
  153. data/lib/cucumber/ast/filter.rb +0 -22
  154. data/lib/cucumber/ast/outline_table.rb +0 -49
  155. data/lib/cucumber/ast/py_string.rb +0 -52
  156. data/lib/cucumber/ast/scenario.rb +0 -95
  157. data/lib/cucumber/ast/scenario_outline.rb +0 -83
  158. data/lib/cucumber/ast/step.rb +0 -139
  159. data/lib/cucumber/ast/table.rb +0 -214
  160. data/lib/cucumber/ast/tags.rb +0 -33
  161. data/lib/cucumber/ast/visitor.rb +0 -93
  162. data/lib/cucumber/ast.rb +0 -27
  163. data/lib/cucumber/broadcaster.rb +0 -15
  164. data/lib/cucumber/cli.rb +0 -410
  165. data/lib/cucumber/core_ext/exception.rb +0 -53
  166. data/lib/cucumber/core_ext/instance_exec.rb +0 -54
  167. data/lib/cucumber/core_ext/proc.rb +0 -33
  168. data/lib/cucumber/core_ext/string.rb +0 -48
  169. data/lib/cucumber/formatter/ansicolor.rb +0 -106
  170. data/lib/cucumber/formatter/console.rb +0 -116
  171. data/lib/cucumber/formatter/pretty.rb +0 -158
  172. data/lib/cucumber/formatter/profile.rb +0 -77
  173. data/lib/cucumber/formatter/progress.rb +0 -68
  174. data/lib/cucumber/formatter/rerun.rb +0 -35
  175. data/lib/cucumber/formatter.rb +0 -1
  176. data/lib/cucumber/formatters/autotest_formatter.rb +0 -21
  177. data/lib/cucumber/formatters/cucumber.css +0 -132
  178. data/lib/cucumber/formatters/cucumber.js +0 -11
  179. data/lib/cucumber/formatters/html_formatter.rb +0 -152
  180. data/lib/cucumber/formatters/jquery.js +0 -32
  181. data/lib/cucumber/formatters/pretty_formatter.rb +0 -285
  182. data/lib/cucumber/formatters/unicode.rb +0 -35
  183. data/lib/cucumber/jbehave.rb +0 -104
  184. data/lib/cucumber/languages.yml +0 -314
  185. data/lib/cucumber/parser/basic.rb +0 -0
  186. data/lib/cucumber/parser/feature.rb +0 -1315
  187. data/lib/cucumber/parser/feature.tt +0 -160
  188. data/lib/cucumber/parser/i18n.tt +0 -27
  189. data/lib/cucumber/parser/table.rb +0 -396
  190. data/lib/cucumber/parser/table.tt +0 -53
  191. data/lib/cucumber/parser/treetop_ext.rb +0 -67
  192. data/lib/cucumber/parser.rb +0 -24
  193. data/lib/cucumber/platform.rb +0 -18
  194. data/lib/cucumber/rails/rspec.rb +0 -5
  195. data/lib/cucumber/rails/world.rb +0 -73
  196. data/lib/cucumber/rake/task.rb +0 -106
  197. data/lib/cucumber/step_definition.rb +0 -87
  198. data/lib/cucumber/step_mother.rb +0 -164
  199. data/lib/cucumber/treetop_parser/feature_fi.rb +0 -1951
  200. data/lib/cucumber/version.rb +0 -10
  201. data/lib/cucumber.rb +0 -72
  202. data/pretty.txt +0 -486
  203. data/rails_generators/cucumber/USAGE +0 -11
  204. data/rails_generators/cucumber/cucumber_generator.rb +0 -31
  205. data/rails_generators/cucumber/templates/cucumber +0 -8
  206. data/rails_generators/cucumber/templates/cucumber.rake +0 -7
  207. data/rails_generators/cucumber/templates/env.rb +0 -16
  208. data/rails_generators/cucumber/templates/paths.rb +0 -12
  209. data/rails_generators/cucumber/templates/webrat_steps.rb +0 -99
  210. data/rails_generators/feature/USAGE +0 -12
  211. data/rails_generators/feature/feature_generator.rb +0 -36
  212. data/rails_generators/feature/templates/feature.erb +0 -31
  213. data/rails_generators/feature/templates/steps.erb +0 -24
  214. data/spec/cucumber/ast/feature_factory.rb +0 -54
  215. data/spec/cucumber/ast/feature_spec.rb +0 -60
  216. data/spec/cucumber/ast/py_string_spec.rb +0 -40
  217. data/spec/cucumber/ast/scenario_outline_spec.rb +0 -64
  218. data/spec/cucumber/ast/scenario_spec.rb +0 -82
  219. data/spec/cucumber/ast/step_spec.rb +0 -45
  220. data/spec/cucumber/ast/table_spec.rb +0 -81
  221. data/spec/cucumber/broadcaster_spec.rb +0 -14
  222. data/spec/cucumber/cli_spec.rb +0 -416
  223. data/spec/cucumber/core_ext/proc_spec.rb +0 -37
  224. data/spec/cucumber/core_ext/string_spec.rb +0 -42
  225. data/spec/cucumber/formatter/ansicolor_spec.rb +0 -35
  226. data/spec/cucumber/formatter/html/cucumber.css +0 -37
  227. data/spec/cucumber/formatter/html/cucumber.js +0 -11
  228. data/spec/cucumber/formatter/html/index.html +0 -45
  229. data/spec/cucumber/formatter/html/jquery-1.3.min.js +0 -19
  230. data/spec/cucumber/formatter/html/jquery.uitableedit.js +0 -100
  231. data/spec/cucumber/formatters/autotest_formatter_spec.rb +0 -27
  232. data/spec/cucumber/formatters/features.html +0 -269
  233. data/spec/cucumber/formatters/profile_formatter_spec.rb +0 -198
  234. data/spec/cucumber/parser/feature_parser_spec.rb +0 -247
  235. data/spec/cucumber/parser/table_parser_spec.rb +0 -48
  236. data/spec/cucumber/rails/stubs/mini_rails.rb +0 -18
  237. data/spec/cucumber/rails/stubs/test_help.rb +0 -1
  238. data/spec/cucumber/rails/world_spec.rb +0 -11
  239. data/spec/cucumber/sell_cucumbers.feature +0 -19
  240. data/spec/cucumber/step_definition_spec.rb +0 -62
  241. data/spec/cucumber/step_mom_spec.rb +0 -49
  242. data/spec/cucumber/treetop_parser/empty_feature.feature +0 -4
  243. data/spec/cucumber/treetop_parser/empty_scenario.feature +0 -9
  244. data/spec/cucumber/treetop_parser/empty_scenario_outline.feature +0 -3
  245. data/spec/cucumber/treetop_parser/fit_scenario.feature +0 -8
  246. data/spec/cucumber/treetop_parser/given_scenario.feature +0 -9
  247. data/spec/cucumber/treetop_parser/invalid_scenario_outlines.feature +0 -7
  248. data/spec/cucumber/treetop_parser/multiline_steps.feature +0 -17
  249. data/spec/cucumber/treetop_parser/multiple_tables.feature +0 -27
  250. data/spec/cucumber/treetop_parser/scenario_outline.feature +0 -16
  251. data/spec/cucumber/treetop_parser/spaces.feature +0 -12
  252. data/spec/cucumber/treetop_parser/test_dos.feature +0 -25
  253. data/spec/cucumber/treetop_parser/with_comments.feature +0 -10
  254. data/spec/cucumber/treetop_parser/with_tags.feature +0 -18
  255. data/spec/cucumber/world/pending_spec.rb +0 -47
  256. data/spec/spec.opts +0 -2
  257. data/spec/spec_helper.rb +0 -21
data/lib/cucumber/cli.rb DELETED
@@ -1,410 +0,0 @@
1
- require 'optparse'
2
- require 'cucumber'
3
- require 'ostruct'
4
- require 'cucumber/parser'
5
- require 'cucumber/formatter'
6
-
7
- module Cucumber
8
- class YmlLoadError < StandardError; end
9
-
10
- class CLI
11
- class << self
12
- def step_mother=(step_mother)
13
- @step_mother = step_mother
14
- @step_mother.extend(StepMother)
15
- @step_mother.snippet_generator = StepDefinition
16
- end
17
-
18
- def execute(args)
19
- parse(args).execute!(@step_mother)
20
- end
21
-
22
- def parse(args)
23
- cli = new
24
- cli.parse_options!(args)
25
- cli
26
- end
27
- end
28
-
29
- attr_reader :options, :paths
30
- FORMATS = %w{pretty profile progress rerun}
31
- DEFAULT_FORMAT = 'pretty'
32
-
33
- def initialize(out_stream = STDOUT, error_stream = STDERR)
34
- @out_stream = out_stream
35
-
36
- @error_stream = error_stream
37
- @paths = []
38
- @options = {
39
- :strict => false,
40
- :require => nil,
41
- :lang => 'en',
42
- :dry_run => false,
43
- :formats => {},
44
- :excludes => [],
45
- :tags => [],
46
- :scenario_names => []
47
- }
48
- @active_format = DEFAULT_FORMAT
49
- end
50
-
51
- def parse_options!(args)
52
- @args = args
53
- return parse_args_from_profile('default') if args.empty?
54
- args.extend(OptionParser::Arguable)
55
-
56
- args.options do |opts|
57
- opts.banner = ["Usage: cucumber [options] [[FILE[:LINE[:LINE]*]] | [FILES|DIRS]]", "",
58
- "Examples:",
59
- "cucumber examples/i18n/en/features",
60
- "cucumber --language it examples/i18n/it/features/somma.feature:6:98:113", "", ""
61
- ].join("\n")
62
- opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR",
63
- "Require files before executing the features. If this",
64
- "option is not specified, all *.rb files that are",
65
- "siblings or below the features will be loaded auto-",
66
- "matically. Automatic loading is disabled when this",
67
- "option is specified, and all loading becomes explicit.",
68
- "Files under directories named \"support\" are always",
69
- "loaded first.",
70
- "This option can be specified multiple times.") do |v|
71
- @options[:require] ||= []
72
- @options[:require] << v
73
- end
74
- opts.on("-l LANG", "--language LANG",
75
- "Specify language for features (Default: #{@options[:lang]})",
76
- %{Run with "--language help" to see all languages},
77
- %{Run with "--language LANG help" to list keywords for LANG}) do |v|
78
- if v == 'help'
79
- list_languages
80
- elsif args==['help']
81
- list_keywords(v)
82
- else
83
- @options[:lang] = v
84
- end
85
- end
86
- opts.on("-f FORMAT", "--format FORMAT",
87
- "How to format features (Default: #{DEFAULT_FORMAT})",
88
- "Available formats: #{FORMATS.join(", ")}",
89
- "You can also provide your own formatter classes as long",
90
- "as they have been previously required using --require or",
91
- "if they are in the folder structure such that cucumber",
92
- "will require them automatically.",
93
- "This option can be specified multiple times.") do |v|
94
- @options[:formats][v] = @out_stream
95
- @active_format = v
96
- end
97
- opts.on("-o", "--out FILE",
98
- "Write output to a file instead of STDOUT. This option",
99
- "applies to the previously specified --format, or the",
100
- "default format if no format is specified.") do |v|
101
- @options[:formats][@active_format] = v
102
- end
103
- opts.on("-t TAGS", "--tags TAGS",
104
- "Only execute the features or scenarios with the specified tags.",
105
- "TAGS must be comma-separated without spaces.") do |v|
106
- @options[:tags] = v.split(",")
107
- end
108
- opts.on("-s SCENARIO", "--scenario SCENARIO",
109
- "Only execute the scenario with the given name. If this option",
110
- "is given more than once, run all the specified scenarios.") do |v|
111
- @options[:scenario_names] << v
112
- end
113
- opts.on("-e", "--exclude PATTERN", "Don't run feature files matching PATTERN") do |v|
114
- @options[:excludes] << v
115
- end
116
- opts.on("-p", "--profile PROFILE", "Pull commandline arguments from cucumber.yml.") do |v|
117
- parse_args_from_profile(v)
118
- end
119
- opts.on("-c", "--[no-]color",
120
- "Whether or not to use ANSI color in the output. Cucumber decides",
121
- "based on your platform and the output destination if not specified.") do |v|
122
- Term::ANSIColor.coloring = v
123
- end
124
- opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.",
125
- "Implies --quiet.") do
126
- @options[:dry_run] = true
127
- @quiet = true
128
- end
129
- opts.on("-a", "--autoformat DIRECTORY",
130
- "Reformats (pretty prints) feature files and write them to DIRECTORY.",
131
- "Be careful if you choose to overwrite the originals.",
132
- "Implies --dry-run --formatter pretty.") do |directory|
133
- @options[:autoformat] = directory
134
- Term::ANSIColor.coloring = false
135
- @options[:dry_run] = true
136
- @quiet = true
137
- end
138
- opts.on("-n", "--[no-]source",
139
- "Don't show the file and line of the step definition with the steps.") do |v|
140
- @options[:source] = v
141
- end
142
- opts.on("-i", "--[no-]snippets", "Don't show the snippets for pending steps.") do |v|
143
- @options[:snippets] = v
144
- end
145
- opts.on("-q", "--quiet", "Alias for --no-snippets --no-source.") do
146
- @quiet = true
147
- end
148
- opts.on("-b", "--backtrace", "Show full backtrace for all errors.") do
149
- Exception.cucumber_full_backtrace = true
150
- end
151
- opts.on("--strict", "Fail if there are any undefined or pending steps.") do
152
- @options[:strict] = true
153
- end
154
- opts.on("-v", "--verbose", "Show the files and features loaded.") do
155
- @options[:verbose] = true
156
- end
157
- opts.on_tail("--version", "Show version.") do
158
- @out_stream.puts VERSION::STRING
159
- Kernel.exit
160
- end
161
- opts.on_tail("--help", "You're looking at it.") do
162
- @out_stream.puts opts.help
163
- Kernel.exit
164
- end
165
- end.parse!
166
-
167
- @options[:formats]['pretty'] = @out_stream if @options[:formats].empty?
168
-
169
- @options[:snippets] = true if !@quiet && @options[:snippets].nil?
170
- @options[:source] = true if !@quiet && @options[:source].nil?
171
-
172
- # Whatever is left after option parsing is the FILE arguments
173
- @paths += args
174
- end
175
-
176
-
177
- def execute!(step_mother)
178
- Cucumber.load_language(@options[:lang])
179
- require_files
180
- enable_diffing
181
- features = load_plain_text_features
182
-
183
- visitor = build_formatter_broadcaster(step_mother)
184
- visitor.options = @options
185
- visitor.visit_features(features)
186
- exit_code = features.steps[:failed].length
187
- exit_code += (features.steps[:undefined].length + features.steps[:pending].length) if @options[:strict]
188
- Kernel.exit(exit_code)
189
- end
190
-
191
- private
192
-
193
- def cucumber_yml
194
- return @cucumber_yml if @cucumber_yml
195
- unless File.exist?('cucumber.yml')
196
- raise(YmlLoadError,"cucumber.yml was not found. Please refer to cucumber's documentaion on defining profiles in cucumber.yml. You must define a 'default' profile to use the cucumber command without any arguments.\nType 'cucumber --help' for usage.\n")
197
- end
198
-
199
- require 'yaml'
200
- begin
201
- @cucumber_yml = YAML::load(IO.read('cucumber.yml'))
202
- rescue Exception => e
203
- raise(YmlLoadError,"cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentaion on correct profile usage.\n")
204
- end
205
-
206
- if @cucumber_yml.nil? || !@cucumber_yml.is_a?(Hash)
207
- raise(YmlLoadError,"cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentaion on correct profile usage.\n")
208
- end
209
-
210
- return @cucumber_yml
211
- end
212
-
213
- def parse_args_from_profile(profile)
214
- unless cucumber_yml.has_key?(profile)
215
- return(exit_with_error <<-END_OF_ERROR)
216
- Could not find profile: '#{profile}'
217
-
218
- Defined profiles in cucumber.yml:
219
- * #{cucumber_yml.keys.join("\n * ")}
220
- END_OF_ERROR
221
- end
222
-
223
- args_from_yml = cucumber_yml[profile] || ''
224
-
225
- if !args_from_yml.is_a?(String)
226
- exit_with_error "Profiles must be defined as a String. The '#{profile}' profile was #{args_from_yml.inspect} (#{args_from_yml.class}).\n"
227
- elsif args_from_yml =~ /^\s*$/
228
- exit_with_error "The 'foo' profile in cucumber.yml was blank. Please define the command line arguments for the 'foo' profile in cucumber.yml.\n"
229
- else
230
- parse_options!(args_from_yml.split(' '))
231
- end
232
-
233
- rescue YmlLoadError => e
234
- exit_with_error(e.message)
235
- end
236
-
237
- # Requires files - typically step files and ruby feature files.
238
- def require_files
239
- verbose_log("Ruby files required:")
240
- files_to_require.each do |lib|
241
- begin
242
- require lib
243
- verbose_log(" * #{lib}")
244
- rescue LoadError => e
245
- e.message << "\nFailed to load #{lib}"
246
- raise e
247
- end
248
- end
249
- verbose_log("\n")
250
- end
251
-
252
- def files_to_require
253
- requires = @options[:require] || feature_dirs
254
- files = requires.map do |path|
255
- path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
256
- File.directory?(path) ? Dir["#{path}/**/*.rb"] : path
257
- end.flatten.uniq
258
- files.sort { |a,b| (b =~ %r{/support/} || -1) <=> (a =~ %r{/support/} || -1) }
259
- end
260
-
261
- def feature_files
262
- potential_feature_files = @paths.map do |path|
263
- path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
264
- path = path.chomp('/')
265
- File.directory?(path) ? Dir["#{path}/**/*.feature"] : path
266
- end.flatten.uniq
267
-
268
- @options[:excludes].each do |exclude|
269
- potential_feature_files.reject! do |path|
270
- path =~ /#{Regexp.escape(exclude)}/
271
- end
272
- end
273
-
274
- potential_feature_files
275
- end
276
-
277
- def feature_dirs
278
- feature_files.map{|f| File.directory?(f) ? f : File.dirname(f)}.uniq
279
- end
280
-
281
- def load_plain_text_features
282
- filter = Ast::Filter.new(@options)
283
- features = Ast::Features.new(filter)
284
- parser = Parser::FeatureParser.new
285
-
286
- verbose_log("Features:")
287
- feature_files.each do |f|
288
- features.add_feature(parser.parse_file(f))
289
- verbose_log(" * #{f}")
290
- end
291
- verbose_log("\n"*2)
292
- features
293
- end
294
-
295
- def build_formatter_broadcaster(step_mother)
296
- return Formatter::Pretty.new(step_mother, nil, @options) if @options[:autoformat]
297
- formatters = @options[:formats].map do |format, out|
298
- if String === out # file name
299
- out = File.open(out, Cucumber.file_mode('w'))
300
- at_exit do
301
- out.flush
302
- out.close
303
- end
304
- end
305
-
306
- case format
307
- when 'pretty'
308
- Formatter::Pretty.new(step_mother, out, @options)
309
- when 'progress'
310
- Formatter::Progress.new(step_mother, out, @options)
311
- when 'profile'
312
- Formatter::Profile.new(step_mother, out, @options)
313
- when 'rerun'
314
- Formatter::Rerun.new(step_mother, out, @options)
315
- else
316
- begin
317
- formatter_class = constantize(format)
318
- formatter_class.new(step_mother, out, @options)
319
- rescue Exception => e
320
- exit_with_error("Error creating formatter: #{format}", e)
321
- end
322
- end
323
- end
324
- Broadcaster.new(formatters)
325
- end
326
-
327
- def constantize(camel_cased_word)
328
- names = camel_cased_word.split('::')
329
- names.shift if names.empty? || names.first.empty?
330
-
331
- constant = Object
332
- names.each do |name|
333
- constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
334
- end
335
- constant
336
- end
337
-
338
- def verbose_log(string)
339
- @out_stream.puts(string) if @options[:verbose]
340
- end
341
-
342
- def exit_with_help
343
- parse_options!(%w{--help})
344
- end
345
-
346
- def exit_with_error(error_message, e=nil)
347
- @error_stream.puts(error_message)
348
- if e
349
- @error_stream.puts("#{e.message} (#{e.class})")
350
- @error_stream.puts(e.backtrace.join("\n"))
351
- end
352
- Kernel.exit 1
353
- end
354
-
355
- def enable_diffing
356
- if defined?(::Spec)
357
- require 'spec/expectations/differs/default'
358
- options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
359
- ::Spec::Expectations.differ = ::Spec::Expectations::Differs::Default.new(options)
360
- end
361
- end
362
-
363
- def list_languages
364
- raw = Cucumber::LANGUAGES.keys.sort.map do |lang|
365
- [lang, Cucumber::LANGUAGES[lang]['name'], Cucumber::LANGUAGES[lang]['native']]
366
- end
367
- print_lang_table(raw, {:check_lang=>true})
368
- end
369
-
370
- def list_keywords(lang)
371
- unless Cucumber::LANGUAGES[lang]
372
- exit_with_error("No language with key #{v}")
373
- end
374
- raw = Cucumber::KEYWORD_KEYS.map do |key|
375
- [key, Cucumber::LANGUAGES[lang][key]]
376
- end
377
- print_lang_table(raw, {})
378
- end
379
-
380
- def print_lang_table(raw, options)
381
- table = Ast::Table.new(raw)
382
- formatter = Formatter::Pretty.new(nil, @out_stream, options, '')
383
-
384
- def formatter.visit_table_row(table_row, status)
385
- @col = 1
386
- super
387
- end
388
-
389
- def formatter.visit_table_cell_value(value, width, status)
390
- if @col == 1
391
- if(@options[:check_lang])
392
- @incomplete = Cucumber.language_complete?(value)
393
- end
394
- status = :comment
395
- elsif @incomplete
396
- status = :failed
397
- end
398
-
399
- @col += 1
400
- super(value, width, status)
401
- end
402
-
403
- formatter.indent = 0
404
- formatter.visit_multiline_arg(table, :passed)
405
- Kernel.exit
406
- end
407
- end
408
- end
409
-
410
- Cucumber::CLI.step_mother = self
@@ -1,53 +0,0 @@
1
- # Exception extension that tweaks Exception backtraces:
2
- #
3
- # * The line of the failing .feature line is appended to the backtrace
4
- # * The line that calls #cucumber_instance_exec is replaced with the StepDefinition's regexp
5
- # * Non intersting lines are stripped out
6
- #
7
- # The result is that backtraces look like this:
8
- #
9
- # features/step_definitions/the_step_definition.rb:in `/some step/'
10
- # features/the_feature_file.feature:41:in `Given some step'
11
- #
12
- # or if the exception is raised in the tested code:
13
- #
14
- # lib/myapp/some_file.rb:in `/some_method/'
15
- # lib/myapp/some_other_file.rb:in `/some_other_method/'
16
- # features/step_definitions/the_step_definition.rb:in `/some step/'
17
- # features/the_feature_file.feature:41:in `Given some step'
18
- #
19
- # All backtrace munging can be turned off with the <tt>--backtrace</tt> switch
20
- #
21
- class Exception
22
- CUCUMBER_FILTER_PATTERNS = [
23
- /vendor\/rails|lib\/cucumber|lib\/rspec|gems\//
24
- ]
25
-
26
- INSTANCE_EXEC_OFFSET = (Cucumber::RUBY_1_9 || Cucumber::JRUBY) ? -3 : -4
27
-
28
- def self.cucumber_full_backtrace=(v)
29
- @@cucumber_full_backtrace = v
30
- end
31
- self.cucumber_full_backtrace = false
32
-
33
- # Strips the backtrace from +line+ and down
34
- def self.cucumber_strip_backtrace!(backtrace, instance_exec_invocation_line, pseudo_method)
35
- return if @@cucumber_full_backtrace
36
-
37
- instance_exec_pos = backtrace.index(instance_exec_invocation_line)
38
- if instance_exec_pos
39
- replacement_line = instance_exec_pos + INSTANCE_EXEC_OFFSET
40
- backtrace[replacement_line].gsub!(/`.*'/, "`#{pseudo_method}'") if pseudo_method
41
- backtrace[replacement_line+1..-1] = nil
42
-
43
- backtrace.compact!
44
- else
45
- # This happens with rails, because they screw up the backtrace
46
- # before we get here (injecting erb stacktrace and such)
47
- end
48
-
49
- backtrace.reject! do |line|
50
- CUCUMBER_FILTER_PATTERNS.detect{|p| line =~ p}
51
- end
52
- end
53
- end
@@ -1,54 +0,0 @@
1
- require 'cucumber/platform'
2
-
3
- module Cucumber
4
- class ArityMismatchError < StandardError
5
- end
6
- end
7
-
8
- class Object
9
- def cucumber_instance_exec(check_arity, pseudo_method, *args, &block)
10
- arity = block.arity
11
- arity = 0 if arity == -1
12
- cucumber_run_with_backtrace_filtering(pseudo_method) do
13
- if check_arity && args.length != arity
14
- instance_exec do
15
- raise Cucumber::ArityMismatchError.new("expected #{arity} block argument(s), got #{args.length}")
16
- end
17
- else
18
- instance_exec(*args, &block)
19
- end
20
- end
21
- end
22
-
23
- def cucumber_run_with_backtrace_filtering(pseudo_method)
24
- begin
25
- yield
26
- rescue Exception => e
27
- instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
28
- Exception.cucumber_strip_backtrace!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
29
- raise e
30
- end
31
- end
32
-
33
- unless defined? instance_exec # 1.9
34
- # http://eigenclass.org/hiki/bounded+space+instance_exec
35
- module InstanceExecHelper; end
36
- include InstanceExecHelper
37
- def instance_exec(*args, &block)
38
- begin
39
- old_critical, Thread.critical = Thread.critical, true
40
- n = 0
41
- n += 1 while respond_to?(mname="__instance_exec#{n}")
42
- InstanceExecHelper.module_eval{ define_method(mname, &block) }
43
- ensure
44
- Thread.critical = old_critical
45
- end
46
- begin
47
- ret = send(mname, *args)
48
- ensure
49
- InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil
50
- end
51
- ret
52
- end
53
- end
54
- end
@@ -1,33 +0,0 @@
1
- # Proc extension to get more location info out of a proc
2
- class Proc
3
- PROC_PATTERN = /[\d\w]+@(.*):(.*)>/
4
-
5
- if Proc.new{}.to_s =~ PROC_PATTERN
6
- def to_backtrace_line(name)
7
- "#{file_colon_line}:in `#{name}'"
8
- end
9
-
10
- def to_comment_line
11
- "# #{file_colon_line}"
12
- end
13
-
14
- def file_colon_line
15
- path, line = *to_s.match(PROC_PATTERN)[1..2]
16
- path = File.expand_path(path)
17
- pwd = Dir.pwd
18
- path = path[pwd.length+1..-1]
19
- "#{path}:#{line}"
20
- end
21
- else
22
- # This Ruby implementation doesn't implement Proc#to_s correctly
23
- STDERR.puts "*** THIS RUBY IMPLEMENTATION DOESN'T REPORT FILE AND LINE FOR PROCS ***"
24
-
25
- def to_backtrace_line
26
- nil
27
- end
28
-
29
- def to_comment_line
30
- ""
31
- end
32
- end
33
- end
@@ -1,48 +0,0 @@
1
- class String
2
- def indent(n)
3
- if n >= 0
4
- gsub(/^/, ' ' * n)
5
- else
6
- gsub(/^ {0,#{-n}}/, "")
7
- end
8
- end
9
-
10
- # re.source.gsub(/\([^)]*\)/, '$var')
11
- # Cumulative #sub
12
- def subs(re, *args)
13
- args.inject(self) do |s,arg|
14
- s.sub(re, arg)
15
- end
16
- end
17
-
18
- # TODO: Use subs instead...
19
- def gzub(regexp, format=nil, &proc)
20
- md = match(regexp)
21
- raise "#{self.inspect} doesn't match #{regexp.inspect}" if md.nil?
22
-
23
- s = dup
24
- pos = 0
25
- md.captures.each_with_index do |m, n|
26
- replacement = if block_given?
27
- proc.call(m)
28
- elsif Proc === format
29
- format.call(m)
30
- else
31
- format % m
32
- end
33
-
34
- if md.offset(n+1)[0]
35
- s[md.offset(n+1)[0] + pos, m.length] = replacement
36
- pos += replacement.length - m.length
37
- end
38
- end
39
- s
40
- end
41
-
42
- if (Cucumber::JRUBY && Cucumber::RAILS) || Cucumber::RUBY_1_9
43
- # Workaround for http://tinyurl.com/55uu3u
44
- alias jlength length
45
- else
46
- require 'jcode'
47
- end
48
- end