cucumber 0.1.16 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (322) hide show
  1. data/History.txt +111 -5
  2. data/License.txt +1 -1
  3. data/Manifest.txt +141 -83
  4. data/Rakefile +1 -1
  5. data/bin/cucumber +2 -2
  6. data/config/hoe.rb +8 -2
  7. data/examples/cs/features/addition.feature +4 -5
  8. data/examples/cs/features/step_definitons/calculator_steps.rb +1 -5
  9. data/examples/i18n/README.textile +1 -1
  10. data/examples/i18n/Rakefile +5 -5
  11. data/examples/i18n/ar/features/addition.feature +10 -11
  12. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -10
  13. data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +1 -1
  14. data/examples/i18n/de/features/addition.feature +10 -11
  15. data/examples/i18n/de/features/division.feature +0 -1
  16. data/examples/i18n/de/features/step_definitons/calculator_steps.rb +2 -10
  17. data/examples/i18n/en-lol/Rakefile +6 -0
  18. data/examples/i18n/en-lol/features/step_definitions/cucumbrz_steps.rb +16 -0
  19. data/examples/i18n/en-lol/features/stuffing.feature +8 -0
  20. data/examples/i18n/en-lol/features/support/env.rb +8 -0
  21. data/examples/i18n/en-lol/lib/basket.rb +12 -0
  22. data/examples/i18n/en-lol/lib/belly.rb +11 -0
  23. data/examples/i18n/en/features/addition.feature +10 -11
  24. data/examples/i18n/en/features/division.feature +0 -1
  25. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +2 -6
  26. data/examples/i18n/es/features/adicion.feature +11 -12
  27. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +7 -10
  28. data/examples/i18n/es/lib/calculador.rb +4 -1
  29. data/examples/i18n/et/features/jagamine.feature +9 -0
  30. data/examples/i18n/et/features/liitmine.feature +10 -11
  31. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +4 -8
  32. data/examples/i18n/et/lib/kalkulaator.rb +5 -1
  33. data/examples/i18n/fi/Rakefile +6 -0
  34. data/examples/i18n/fi/features/jakolasku.feature +9 -0
  35. data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +24 -0
  36. data/examples/i18n/fi/features/yhteenlasku.feature +16 -0
  37. data/examples/i18n/fi/lib/laskin.rb +14 -0
  38. data/examples/i18n/fr/features/addition.feature +14 -12
  39. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +11 -13
  40. data/examples/i18n/fr/lib/calculatrice.rb +1 -1
  41. data/examples/i18n/id/features/addition.feature +10 -11
  42. data/examples/i18n/id/features/division.feature +0 -1
  43. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +2 -11
  44. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +1 -1
  45. data/examples/i18n/ja/features/addition.feature +10 -11
  46. data/examples/i18n/ja/features/division.feature +2 -3
  47. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +4 -13
  48. data/examples/i18n/ko/features/addition.feature +7 -8
  49. data/examples/i18n/ko/features/division.feature +3 -4
  50. data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -5
  51. data/examples/i18n/lt/features/addition.feature +11 -11
  52. data/examples/i18n/lt/features/division.feature +0 -1
  53. data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +2 -11
  54. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +3 -10
  55. data/examples/i18n/no/features/summering.feature +1 -0
  56. data/examples/i18n/no/features/support/env.rb +6 -0
  57. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +1 -1
  58. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +1 -1
  59. data/examples/i18n/ru/Rakefile +6 -0
  60. data/examples/i18n/ru/features/addition.feature +10 -0
  61. data/examples/i18n/ru/features/consecutive_calculations.feature +16 -0
  62. data/examples/i18n/ru/features/division.feature +15 -0
  63. data/examples/i18n/ru/features/step_definitons/calculator_steps.rb +19 -0
  64. data/examples/i18n/ru/features/support/env.rb +6 -0
  65. data/examples/i18n/ru/features/support/world.rb +7 -0
  66. data/examples/i18n/ru/lib/calculator.rb +24 -0
  67. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +1 -1
  68. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +2 -2
  69. data/examples/i18n/zh-TW/Rakefile +6 -0
  70. data/examples/i18n/zh-TW/features/addition.feature +16 -0
  71. data/examples/i18n/zh-TW/features/division.feature +10 -0
  72. data/examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb +24 -0
  73. data/examples/i18n/zh-TW/lib/calculator.rb +14 -0
  74. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  75. data/examples/jbehave/README.textile +20 -0
  76. data/examples/jbehave/features/support/env.rb +7 -0
  77. data/examples/jbehave/features/trading.feature +28 -0
  78. data/examples/jbehave/pom.xml +53 -0
  79. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java +32 -0
  80. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Stock.java +42 -0
  81. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Trader.java +29 -0
  82. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java +22 -0
  83. data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java +70 -0
  84. data/examples/selenium/features/step_definitons/search_steps.rb +13 -0
  85. data/examples/selenium/features/support/env.rb +19 -0
  86. data/examples/{calculator_ruby_features → selenium_webrat}/Rakefile +0 -0
  87. data/examples/selenium_webrat/features/search.feature +9 -0
  88. data/examples/selenium_webrat/features/step_definitons/search_steps.rb +13 -0
  89. data/examples/selenium_webrat/features/support/env.rb +41 -0
  90. data/examples/self_test/README.textile +4 -1
  91. data/examples/self_test/Rakefile +6 -0
  92. data/examples/self_test/features/background/failing_background.feature +11 -0
  93. data/examples/self_test/features/background/failing_background_after_success.feature +11 -0
  94. data/examples/self_test/features/background/multiline_args_background.feature +32 -0
  95. data/examples/self_test/features/background/passing_background.feature +10 -0
  96. data/examples/self_test/features/background/pending_background.feature +10 -0
  97. data/examples/self_test/features/background/scenario_outline_failing_background.feature +16 -0
  98. data/examples/self_test/features/background/scenario_outline_passing_background.feature +16 -0
  99. data/examples/self_test/features/call_undefined_step_from_step_def.feature +7 -0
  100. data/examples/self_test/features/failing_expectation.feature +4 -0
  101. data/examples/self_test/features/lots_of_undefined.feature +8 -0
  102. data/examples/self_test/features/outline_sample.feature +11 -5
  103. data/examples/self_test/features/sample.feature +8 -3
  104. data/examples/self_test/features/step_definitions/sample_steps.rb +55 -4
  105. data/examples/self_test/features/support/env.rb +1 -0
  106. data/examples/self_test/features/support/tag_count_formatter.rb +25 -0
  107. data/examples/sinatra/Rakefile +6 -0
  108. data/examples/sinatra/app.rb +14 -0
  109. data/examples/sinatra/features/add.feature +11 -0
  110. data/examples/sinatra/features/step_definitions/add_steps.rb +15 -0
  111. data/examples/sinatra/features/support/env.rb +20 -0
  112. data/examples/sinatra/views/add.erb +5 -0
  113. data/examples/sinatra/views/layout.erb +8 -0
  114. data/examples/tickets/Rakefile +13 -8
  115. data/examples/tickets/cucumber.yml +2 -1
  116. data/examples/tickets/features/172.feature +28 -0
  117. data/examples/tickets/features/177/1.feature +29 -0
  118. data/examples/tickets/features/177/2.feature +21 -0
  119. data/examples/tickets/features/177/3.feature +18 -0
  120. data/examples/tickets/features/180.feature +7 -0
  121. data/examples/tickets/features/236.feature +13 -0
  122. data/examples/tickets/features/241.feature +13 -0
  123. data/examples/tickets/features/scenario_outline.feature +6 -1
  124. data/examples/tickets/features/step_definitons/tickets_steps.rb +41 -4
  125. data/examples/tickets/features/tickets.feature +5 -1
  126. data/features/background.feature +221 -0
  127. data/features/cucumber_cli.feature +263 -97
  128. data/features/cucumber_cli_diff_disabled.feature +45 -0
  129. data/features/cucumber_cli_outlines.feature +50 -42
  130. data/features/custom_formatter.feature +11 -0
  131. data/features/report_called_undefined_steps.feature +34 -0
  132. data/features/step_definitions/cucumber_steps.rb +6 -3
  133. data/features/step_definitions/extra_steps.rb +1 -1
  134. data/features/support/env.rb +3 -2
  135. data/gem_tasks/features.rake +1 -1
  136. data/gem_tasks/flog.rake +1 -1
  137. data/gem_tasks/gemspec.rake +2 -2
  138. data/gem_tasks/jar.rake +67 -0
  139. data/gem_tasks/rspec.rake +2 -0
  140. data/lib/autotest/cucumber_mixin.rb +18 -23
  141. data/lib/cucumber.rb +55 -11
  142. data/lib/cucumber/ast.rb +29 -0
  143. data/lib/cucumber/ast/background.rb +50 -0
  144. data/lib/cucumber/ast/comment.rb +26 -0
  145. data/lib/cucumber/ast/examples.rb +38 -0
  146. data/lib/cucumber/ast/feature.rb +62 -0
  147. data/lib/cucumber/ast/feature_element.rb +46 -0
  148. data/lib/cucumber/ast/features.rb +20 -0
  149. data/lib/cucumber/ast/outline_table.rb +81 -0
  150. data/lib/cucumber/ast/py_string.rb +58 -0
  151. data/lib/cucumber/ast/scenario.rb +64 -0
  152. data/lib/cucumber/ast/scenario_outline.rb +90 -0
  153. data/lib/cucumber/ast/step.rb +122 -0
  154. data/lib/cucumber/ast/step_collection.rb +66 -0
  155. data/lib/cucumber/ast/step_invocation.rb +110 -0
  156. data/lib/cucumber/ast/table.rb +318 -0
  157. data/lib/cucumber/ast/tags.rb +33 -0
  158. data/lib/cucumber/ast/visitor.rb +125 -0
  159. data/lib/cucumber/broadcaster.rb +2 -9
  160. data/lib/cucumber/cli/configuration.rb +364 -0
  161. data/lib/cucumber/cli/language_help_formatter.rb +59 -0
  162. data/lib/cucumber/cli/main.rb +109 -0
  163. data/lib/cucumber/core_ext/exception.rb +41 -8
  164. data/lib/cucumber/core_ext/instance_exec.rb +54 -0
  165. data/lib/cucumber/core_ext/proc.rb +29 -65
  166. data/lib/cucumber/core_ext/string.rb +19 -0
  167. data/lib/cucumber/formatter.rb +1 -0
  168. data/lib/cucumber/{formatters → formatter}/ansicolor.rb +13 -16
  169. data/lib/cucumber/formatter/color_io.rb +23 -0
  170. data/lib/cucumber/formatter/console.rb +109 -0
  171. data/lib/cucumber/formatter/cucumber.css +55 -0
  172. data/lib/cucumber/formatter/cucumber.sass +49 -0
  173. data/lib/cucumber/formatter/html.rb +133 -0
  174. data/lib/cucumber/formatter/pretty.rb +179 -0
  175. data/lib/cucumber/formatter/profile.rb +77 -0
  176. data/lib/cucumber/formatter/progress.rb +60 -0
  177. data/lib/cucumber/formatter/rerun.rb +35 -0
  178. data/lib/cucumber/formatter/unicode.rb +35 -0
  179. data/lib/cucumber/formatters/unicode.rb +2 -35
  180. data/lib/cucumber/jbehave.rb +97 -0
  181. data/lib/cucumber/languages.yml +196 -80
  182. data/lib/cucumber/parser.rb +43 -0
  183. data/lib/cucumber/parser/basic.rb +0 -0
  184. data/lib/cucumber/parser/feature.rb +1487 -0
  185. data/lib/cucumber/parser/feature.tt +193 -0
  186. data/lib/cucumber/parser/i18n.tt +31 -0
  187. data/lib/cucumber/parser/table.rb +402 -0
  188. data/lib/cucumber/parser/table.tt +59 -0
  189. data/lib/cucumber/parser/treetop_ext.rb +75 -0
  190. data/lib/cucumber/platform.rb +2 -17
  191. data/lib/cucumber/rails/rspec.rb +5 -9
  192. data/lib/cucumber/rails/world.rb +2 -2
  193. data/lib/cucumber/rake/task.rb +39 -7
  194. data/lib/cucumber/step_definition.rb +103 -0
  195. data/lib/cucumber/step_match.rb +49 -0
  196. data/lib/cucumber/step_mother.rb +183 -67
  197. data/lib/cucumber/version.rb +2 -2
  198. data/lib/cucumber/world.rb +53 -1
  199. data/rails_generators/cucumber/cucumber_generator.rb +22 -3
  200. data/rails_generators/cucumber/templates/cucumber +2 -1
  201. data/rails_generators/cucumber/templates/cucumber.rake +13 -5
  202. data/rails_generators/cucumber/templates/env.rb +4 -3
  203. data/rails_generators/cucumber/templates/paths.rb +18 -11
  204. data/rails_generators/cucumber/templates/webrat_steps.rb +41 -25
  205. data/rails_generators/feature/feature_generator.rb +4 -0
  206. data/rails_generators/feature/templates/steps.erb +0 -4
  207. data/spec/cucumber/ast/background_spec.rb +49 -0
  208. data/spec/cucumber/ast/feature_factory.rb +63 -0
  209. data/spec/cucumber/ast/feature_spec.rb +37 -0
  210. data/spec/cucumber/ast/py_string_spec.rb +47 -0
  211. data/spec/cucumber/ast/scenario_outline_spec.rb +67 -0
  212. data/spec/cucumber/ast/scenario_spec.rb +65 -0
  213. data/spec/cucumber/ast/step_collection_spec.rb +8 -0
  214. data/spec/cucumber/ast/step_spec.rb +66 -0
  215. data/spec/cucumber/ast/table_spec.rb +149 -0
  216. data/spec/cucumber/ast/tags_spec.rb +19 -0
  217. data/spec/cucumber/broadcaster_spec.rb +6 -18
  218. data/spec/cucumber/cli/configuration_spec.rb +275 -0
  219. data/spec/cucumber/cli/main_spec.rb +203 -0
  220. data/spec/cucumber/core_ext/proc_spec.rb +27 -35
  221. data/spec/cucumber/core_ext/string_spec.rb +8 -0
  222. data/spec/cucumber/{formatters → formatter}/ansicolor_spec.rb +2 -2
  223. data/spec/cucumber/formatter/color_io_spec.rb +26 -0
  224. data/spec/cucumber/formatter/html/cucumber.css +37 -0
  225. data/spec/cucumber/formatter/html/cucumber.js +13 -0
  226. data/spec/cucumber/formatter/html/index.html +45 -0
  227. data/spec/cucumber/formatter/html/jquery-1.3.min.js +19 -0
  228. data/spec/cucumber/formatter/html/jquery.uitableedit.js +100 -0
  229. data/spec/cucumber/formatters/profile_formatter_spec.rb +17 -16
  230. data/spec/cucumber/parser/feature_parser_spec.rb +282 -0
  231. data/spec/cucumber/parser/table_parser_spec.rb +48 -0
  232. data/spec/cucumber/step_definition_spec.rb +81 -0
  233. data/spec/cucumber/step_mother_spec.rb +50 -51
  234. data/spec/cucumber/treetop_parser/empty_feature.feature +1 -1
  235. data/spec/cucumber/treetop_parser/multiple_tables.feature +6 -8
  236. data/spec/cucumber/treetop_parser/scenario_outline.feature +1 -1
  237. data/spec/cucumber/treetop_parser/spaces.feature +3 -1
  238. data/spec/cucumber/treetop_parser/with_comments.feature +1 -1
  239. data/spec/cucumber/treetop_parser/with_tags.feature +18 -0
  240. data/spec/cucumber/world/pending_spec.rb +13 -12
  241. data/spec/spec_helper.rb +1 -1
  242. metadata +165 -88
  243. data/examples/calculator_ruby_features/features/addition.rb +0 -39
  244. data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +0 -43
  245. data/examples/i18n/ja/README.txt +0 -5
  246. data/examples/selenium/features/step_definitons/stories_steps.rb +0 -40
  247. data/gem_tasks/treetop.rake +0 -41
  248. data/lib/cucumber/cli.rb +0 -356
  249. data/lib/cucumber/executor.rb +0 -205
  250. data/lib/cucumber/formatters.rb +0 -1
  251. data/lib/cucumber/formatters/autotest_formatter.rb +0 -23
  252. data/lib/cucumber/formatters/cucumber.css +0 -132
  253. data/lib/cucumber/formatters/cucumber.js +0 -11
  254. data/lib/cucumber/formatters/html_formatter.rb +0 -151
  255. data/lib/cucumber/formatters/jquery.js +0 -32
  256. data/lib/cucumber/formatters/pretty_formatter.rb +0 -285
  257. data/lib/cucumber/formatters/profile_formatter.rb +0 -92
  258. data/lib/cucumber/formatters/progress_formatter.rb +0 -61
  259. data/lib/cucumber/model.rb +0 -1
  260. data/lib/cucumber/model/table.rb +0 -32
  261. data/lib/cucumber/step_methods.rb +0 -49
  262. data/lib/cucumber/tree.rb +0 -16
  263. data/lib/cucumber/tree/feature.rb +0 -105
  264. data/lib/cucumber/tree/features.rb +0 -21
  265. data/lib/cucumber/tree/given_scenario.rb +0 -13
  266. data/lib/cucumber/tree/scenario.rb +0 -240
  267. data/lib/cucumber/tree/step.rb +0 -173
  268. data/lib/cucumber/tree/table.rb +0 -26
  269. data/lib/cucumber/tree/top_down_visitor.rb +0 -23
  270. data/lib/cucumber/treetop_parser/feature.treetop.erb +0 -254
  271. data/lib/cucumber/treetop_parser/feature_ar.rb +0 -1951
  272. data/lib/cucumber/treetop_parser/feature_cy.rb +0 -1951
  273. data/lib/cucumber/treetop_parser/feature_da.rb +0 -1951
  274. data/lib/cucumber/treetop_parser/feature_de.rb +0 -1951
  275. data/lib/cucumber/treetop_parser/feature_en-lol.rb +0 -1951
  276. data/lib/cucumber/treetop_parser/feature_en-tx.rb +0 -1951
  277. data/lib/cucumber/treetop_parser/feature_en.rb +0 -1951
  278. data/lib/cucumber/treetop_parser/feature_es.rb +0 -1951
  279. data/lib/cucumber/treetop_parser/feature_et.rb +0 -1951
  280. data/lib/cucumber/treetop_parser/feature_fr.rb +0 -1951
  281. data/lib/cucumber/treetop_parser/feature_id.rb +0 -1951
  282. data/lib/cucumber/treetop_parser/feature_it.rb +0 -1951
  283. data/lib/cucumber/treetop_parser/feature_ja.rb +0 -1951
  284. data/lib/cucumber/treetop_parser/feature_ko.rb +0 -1951
  285. data/lib/cucumber/treetop_parser/feature_lt.rb +0 -1951
  286. data/lib/cucumber/treetop_parser/feature_nl.rb +0 -1951
  287. data/lib/cucumber/treetop_parser/feature_no.rb +0 -1951
  288. data/lib/cucumber/treetop_parser/feature_parser.rb +0 -36
  289. data/lib/cucumber/treetop_parser/feature_pl.rb +0 -1951
  290. data/lib/cucumber/treetop_parser/feature_pt.rb +0 -1951
  291. data/lib/cucumber/treetop_parser/feature_ro.rb +0 -1951
  292. data/lib/cucumber/treetop_parser/feature_ro2.rb +0 -1951
  293. data/lib/cucumber/treetop_parser/feature_ru.rb +0 -1951
  294. data/lib/cucumber/treetop_parser/feature_se.rb +0 -1951
  295. data/lib/cucumber/treetop_parser/feature_zh-CN.rb +0 -1951
  296. data/lib/cucumber/world/pending.rb +0 -22
  297. data/script/console +0 -10
  298. data/script/console.cmd +0 -1
  299. data/script/destroy +0 -14
  300. data/script/destroy.cmd +0 -1
  301. data/script/generate +0 -14
  302. data/script/generate.cmd +0 -1
  303. data/script/txt2html +0 -74
  304. data/script/txt2html.cmd +0 -1
  305. data/setup.rb +0 -1585
  306. data/spec/cucumber/cli_spec.rb +0 -521
  307. data/spec/cucumber/executor_spec.rb +0 -382
  308. data/spec/cucumber/formatters/autotest_formatter_spec.rb +0 -26
  309. data/spec/cucumber/formatters/features.html +0 -269
  310. data/spec/cucumber/formatters/html_formatter_spec.rb +0 -104
  311. data/spec/cucumber/formatters/pretty_formatter_spec.rb +0 -410
  312. data/spec/cucumber/formatters/progress_formatter_spec.rb +0 -81
  313. data/spec/cucumber/model/table_spec.rb +0 -32
  314. data/spec/cucumber/tree/feature_spec.rb +0 -122
  315. data/spec/cucumber/tree/row_scenario_outline_spec.rb +0 -73
  316. data/spec/cucumber/tree/row_scenario_spec.rb +0 -55
  317. data/spec/cucumber/tree/row_step_outline_spec.rb +0 -38
  318. data/spec/cucumber/tree/scenario_outline_spec.rb +0 -50
  319. data/spec/cucumber/tree/scenario_spec.rb +0 -134
  320. data/spec/cucumber/tree/step_outline_spec.rb +0 -17
  321. data/spec/cucumber/tree/step_spec.rb +0 -59
  322. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +0 -120
@@ -0,0 +1,193 @@
1
+ module Cucumber
2
+ module Parser
3
+ # TIP: When you hack on the grammar, just delete feature.rb in this directory.
4
+ # Also make sure you have uninstalled all cucumber gems (don't forget xxx-cucumber
5
+ # github gems).
6
+ #
7
+ # Treetop will then generate the parser in-memory. When you're happy, just generate
8
+ # the rb file with tt feature.tt
9
+ grammar Feature
10
+ include I18n
11
+ include Table
12
+
13
+ rule feature
14
+ white
15
+ comment
16
+ white
17
+ tags
18
+ white
19
+ header:(!(scenario_outline / scenario / background) .)*
20
+ bg:background?
21
+ feature_elements
22
+ comment? {
23
+ def build
24
+ background = bg.respond_to?(:build) ? bg.build : nil
25
+ Ast::Feature.new(
26
+ background,
27
+ comment.build,
28
+ tags.build,
29
+ header.text_value,
30
+ feature_elements.build(background)
31
+ )
32
+ end
33
+ }
34
+ end
35
+
36
+ rule tags
37
+ white ts:(tag (space/eol)+)* {
38
+ def build
39
+ tag_names = ts.elements.map{|e| e.tag.tag_name.text_value}
40
+ Ast::Tags.new(ts.line, tag_names)
41
+ end
42
+ }
43
+ end
44
+
45
+ rule tag
46
+ '@' tag_name:([^@\r\n\t ])+
47
+ end
48
+
49
+ rule comment
50
+ (comment_line white)* {
51
+ def build
52
+ Ast::Comment.new(text_value)
53
+ end
54
+ }
55
+ end
56
+
57
+ rule comment_line
58
+ '#' line_to_eol
59
+ end
60
+
61
+ rule background
62
+ comment white background_keyword space* (eol+ / eof) steps {
63
+ def build
64
+ Ast::Background.new(
65
+ comment.build,
66
+ background_keyword.line,
67
+ background_keyword.text_value,
68
+ steps.build
69
+ )
70
+ end
71
+ }
72
+ end
73
+
74
+ rule feature_elements
75
+ (scenario / scenario_outline)* {
76
+ def build(background)
77
+ elements.map{|s| s.build(background)}
78
+ end
79
+ }
80
+ end
81
+
82
+ rule scenario
83
+ comment tags white scenario_keyword space* name:line_to_eol white steps white {
84
+ def build(background)
85
+ Ast::Scenario.new(
86
+ background,
87
+ comment.build,
88
+ tags.build,
89
+ scenario_keyword.line,
90
+ scenario_keyword.text_value,
91
+ name.text_value,
92
+ steps.build
93
+ )
94
+ end
95
+ }
96
+ end
97
+
98
+ rule scenario_outline
99
+ comment tags white scenario_outline_keyword space* name:line_to_eol white steps examples_sections white {
100
+ def build(background)
101
+ Ast::ScenarioOutline.new(
102
+ background,
103
+ comment.build,
104
+ tags.build,
105
+ scenario_outline_keyword.line,
106
+ scenario_outline_keyword.text_value,
107
+ name.text_value,
108
+ steps.build,
109
+ examples_sections.build
110
+ )
111
+ end
112
+ }
113
+ end
114
+
115
+ rule steps
116
+ step* {
117
+ def build
118
+ elements.map{|e| e.build}
119
+ end
120
+ }
121
+ end
122
+
123
+ rule step
124
+ comment space* step_keyword space* name:line_to_eol (eol+ / eof) multi:multiline_arg? white {
125
+ def build
126
+ if multi.respond_to?(:build)
127
+ Ast::Step.new(step_keyword.line, step_keyword.text_value, name.text_value.strip, multi.build)
128
+ else
129
+ Ast::Step.new(step_keyword.line, step_keyword.text_value, name.text_value.strip)
130
+ end
131
+ end
132
+ }
133
+ end
134
+
135
+ rule examples_sections
136
+ examples* {
137
+ def build
138
+ elements.map{|e| e.build}
139
+ end
140
+ }
141
+ end
142
+
143
+ rule examples
144
+ space* examples_keyword space* name:line_to_eol? eol table white {
145
+ def build
146
+ [examples_keyword.line, examples_keyword.text_value, name.text_value, table.raw]
147
+ end
148
+ }
149
+ end
150
+
151
+ rule multiline_arg
152
+ table / py_string
153
+ end
154
+
155
+ rule line_to_eol
156
+ (!eol .)*
157
+ end
158
+
159
+ rule py_string
160
+ open_py_string s:(!close_py_string .)* close_py_string {
161
+ def build
162
+ Ast::PyString.new(open_py_string.line, close_py_string.line, s.text_value, open_py_string.indentation)
163
+ end
164
+ }
165
+ end
166
+
167
+ rule open_py_string
168
+ white '"""' space* eol {
169
+ def indentation
170
+ white.text_value.length
171
+ end
172
+
173
+ def line
174
+ white.line
175
+ end
176
+ }
177
+ end
178
+
179
+ rule close_py_string
180
+ eol space* quotes:'"""' white {
181
+ def line
182
+ quotes.line
183
+ end
184
+ }
185
+ end
186
+
187
+ rule white
188
+ (space / eol)*
189
+ end
190
+
191
+ end
192
+ end
193
+ end
@@ -0,0 +1,31 @@
1
+ module Cucumber
2
+ module Parser
3
+ grammar I18n
4
+
5
+ rule background_keyword
6
+ (<%= keywords('background') %>) ':'
7
+ end
8
+
9
+ rule scenario_keyword
10
+ (<%= keywords('scenario') %>) ':'
11
+ end
12
+
13
+ rule scenario_outline_keyword
14
+ (<%= keywords('scenario_outline') %>) ':'
15
+ end
16
+
17
+ rule step_keyword
18
+ (<%= keywords('given') %>) /
19
+ (<%= keywords('when') %>) /
20
+ (<%= keywords('then') %>) /
21
+ (<%= keywords('and') %>) /
22
+ (<%= keywords('but') %>)
23
+ end
24
+
25
+ rule examples_keyword
26
+ (<%= keywords('examples') %>) ':'?
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,402 @@
1
+ module Cucumber
2
+ module Parser
3
+ # TIP: When you hack on the grammar, just delete feature.rb in this directory.
4
+ # Also make sure you have uninstalled all cucumber gems (don't forget xxx-cucumber
5
+ # github gems).
6
+ #
7
+ # Treetop will then generate the parser in-memory. When you're happy, just generate
8
+ # the rb file with tt feature.tt
9
+ module Table
10
+ include Treetop::Runtime
11
+
12
+ def root
13
+ @root || :table
14
+ end
15
+
16
+ module Table0
17
+ def build
18
+ Ast::Table.new(raw)
19
+ end
20
+
21
+ def raw
22
+ elements.map{|e| e.build}
23
+ end
24
+ end
25
+
26
+ def _nt_table
27
+ start_index = index
28
+ if node_cache[:table].has_key?(index)
29
+ cached = node_cache[:table][index]
30
+ @index = cached.interval.end if cached
31
+ return cached
32
+ end
33
+
34
+ s0, i0 = [], index
35
+ loop do
36
+ r1 = _nt_table_row
37
+ if r1
38
+ s0 << r1
39
+ else
40
+ break
41
+ end
42
+ end
43
+ if s0.empty?
44
+ self.index = i0
45
+ r0 = nil
46
+ else
47
+ r0 = SyntaxNode.new(input, i0...index, s0)
48
+ r0.extend(Table0)
49
+ end
50
+
51
+ node_cache[:table][start_index] = r0
52
+
53
+ return r0
54
+ end
55
+
56
+ module TableRow0
57
+ def cell
58
+ elements[0]
59
+ end
60
+
61
+ end
62
+
63
+ module TableRow1
64
+ def cells
65
+ elements[2]
66
+ end
67
+
68
+ end
69
+
70
+ module TableRow2
71
+ def build
72
+ row = cells.elements.map do |elt|
73
+ value = elt.cell.text_value.strip
74
+ value.empty? ? nil : value
75
+ end
76
+
77
+ class << row
78
+ attr_accessor :line
79
+ end
80
+ row.line = cells.line
81
+
82
+ row
83
+ end
84
+ end
85
+
86
+ def _nt_table_row
87
+ start_index = index
88
+ if node_cache[:table_row].has_key?(index)
89
+ cached = node_cache[:table_row][index]
90
+ @index = cached.interval.end if cached
91
+ return cached
92
+ end
93
+
94
+ i0, s0 = index, []
95
+ s1, i1 = [], index
96
+ loop do
97
+ r2 = _nt_space
98
+ if r2
99
+ s1 << r2
100
+ else
101
+ break
102
+ end
103
+ end
104
+ r1 = SyntaxNode.new(input, i1...index, s1)
105
+ s0 << r1
106
+ if r1
107
+ if input.index('|', index) == index
108
+ r3 = (SyntaxNode).new(input, index...(index + 1))
109
+ @index += 1
110
+ else
111
+ terminal_parse_failure('|')
112
+ r3 = nil
113
+ end
114
+ s0 << r3
115
+ if r3
116
+ s4, i4 = [], index
117
+ loop do
118
+ i5, s5 = index, []
119
+ r6 = _nt_cell
120
+ s5 << r6
121
+ if r6
122
+ if input.index('|', index) == index
123
+ r7 = (SyntaxNode).new(input, index...(index + 1))
124
+ @index += 1
125
+ else
126
+ terminal_parse_failure('|')
127
+ r7 = nil
128
+ end
129
+ s5 << r7
130
+ end
131
+ if s5.last
132
+ r5 = (SyntaxNode).new(input, i5...index, s5)
133
+ r5.extend(TableRow0)
134
+ else
135
+ self.index = i5
136
+ r5 = nil
137
+ end
138
+ if r5
139
+ s4 << r5
140
+ else
141
+ break
142
+ end
143
+ end
144
+ if s4.empty?
145
+ self.index = i4
146
+ r4 = nil
147
+ else
148
+ r4 = SyntaxNode.new(input, i4...index, s4)
149
+ end
150
+ s0 << r4
151
+ if r4
152
+ s8, i8 = [], index
153
+ loop do
154
+ r9 = _nt_space
155
+ if r9
156
+ s8 << r9
157
+ else
158
+ break
159
+ end
160
+ end
161
+ r8 = SyntaxNode.new(input, i8...index, s8)
162
+ s0 << r8
163
+ if r8
164
+ i10 = index
165
+ s11, i11 = [], index
166
+ loop do
167
+ r12 = _nt_eol
168
+ if r12
169
+ s11 << r12
170
+ else
171
+ break
172
+ end
173
+ end
174
+ if s11.empty?
175
+ self.index = i11
176
+ r11 = nil
177
+ else
178
+ r11 = SyntaxNode.new(input, i11...index, s11)
179
+ end
180
+ if r11
181
+ r10 = r11
182
+ else
183
+ r13 = _nt_eof
184
+ if r13
185
+ r10 = r13
186
+ else
187
+ self.index = i10
188
+ r10 = nil
189
+ end
190
+ end
191
+ s0 << r10
192
+ end
193
+ end
194
+ end
195
+ end
196
+ if s0.last
197
+ r0 = (SyntaxNode).new(input, i0...index, s0)
198
+ r0.extend(TableRow1)
199
+ r0.extend(TableRow2)
200
+ else
201
+ self.index = i0
202
+ r0 = nil
203
+ end
204
+
205
+ node_cache[:table_row][start_index] = r0
206
+
207
+ return r0
208
+ end
209
+
210
+ module Cell0
211
+ end
212
+
213
+ def _nt_cell
214
+ start_index = index
215
+ if node_cache[:cell].has_key?(index)
216
+ cached = node_cache[:cell][index]
217
+ @index = cached.interval.end if cached
218
+ return cached
219
+ end
220
+
221
+ s0, i0 = [], index
222
+ loop do
223
+ i1, s1 = index, []
224
+ i2 = index
225
+ i3 = index
226
+ if input.index('|', index) == index
227
+ r4 = (SyntaxNode).new(input, index...(index + 1))
228
+ @index += 1
229
+ else
230
+ terminal_parse_failure('|')
231
+ r4 = nil
232
+ end
233
+ if r4
234
+ r3 = r4
235
+ else
236
+ r5 = _nt_eol
237
+ if r5
238
+ r3 = r5
239
+ else
240
+ self.index = i3
241
+ r3 = nil
242
+ end
243
+ end
244
+ if r3
245
+ r2 = nil
246
+ else
247
+ self.index = i2
248
+ r2 = SyntaxNode.new(input, index...index)
249
+ end
250
+ s1 << r2
251
+ if r2
252
+ if index < input_length
253
+ r6 = (SyntaxNode).new(input, index...(index + 1))
254
+ @index += 1
255
+ else
256
+ terminal_parse_failure("any character")
257
+ r6 = nil
258
+ end
259
+ s1 << r6
260
+ end
261
+ if s1.last
262
+ r1 = (SyntaxNode).new(input, i1...index, s1)
263
+ r1.extend(Cell0)
264
+ else
265
+ self.index = i1
266
+ r1 = nil
267
+ end
268
+ if r1
269
+ s0 << r1
270
+ else
271
+ break
272
+ end
273
+ end
274
+ r0 = SyntaxNode.new(input, i0...index, s0)
275
+
276
+ node_cache[:cell][start_index] = r0
277
+
278
+ return r0
279
+ end
280
+
281
+ def _nt_space
282
+ start_index = index
283
+ if node_cache[:space].has_key?(index)
284
+ cached = node_cache[:space][index]
285
+ @index = cached.interval.end if cached
286
+ return cached
287
+ end
288
+
289
+ if input.index(Regexp.new('[ \\t]'), index) == index
290
+ r0 = (SyntaxNode).new(input, index...(index + 1))
291
+ @index += 1
292
+ else
293
+ r0 = nil
294
+ end
295
+
296
+ node_cache[:space][start_index] = r0
297
+
298
+ return r0
299
+ end
300
+
301
+ module Eol0
302
+ end
303
+
304
+ def _nt_eol
305
+ start_index = index
306
+ if node_cache[:eol].has_key?(index)
307
+ cached = node_cache[:eol][index]
308
+ @index = cached.interval.end if cached
309
+ return cached
310
+ end
311
+
312
+ i0 = index
313
+ if input.index("\n", index) == index
314
+ r1 = (SyntaxNode).new(input, index...(index + 1))
315
+ @index += 1
316
+ else
317
+ terminal_parse_failure("\n")
318
+ r1 = nil
319
+ end
320
+ if r1
321
+ r0 = r1
322
+ else
323
+ i2, s2 = index, []
324
+ if input.index("\r", index) == index
325
+ r3 = (SyntaxNode).new(input, index...(index + 1))
326
+ @index += 1
327
+ else
328
+ terminal_parse_failure("\r")
329
+ r3 = nil
330
+ end
331
+ s2 << r3
332
+ if r3
333
+ if input.index("\n", index) == index
334
+ r5 = (SyntaxNode).new(input, index...(index + 1))
335
+ @index += 1
336
+ else
337
+ terminal_parse_failure("\n")
338
+ r5 = nil
339
+ end
340
+ if r5
341
+ r4 = r5
342
+ else
343
+ r4 = SyntaxNode.new(input, index...index)
344
+ end
345
+ s2 << r4
346
+ end
347
+ if s2.last
348
+ r2 = (SyntaxNode).new(input, i2...index, s2)
349
+ r2.extend(Eol0)
350
+ else
351
+ self.index = i2
352
+ r2 = nil
353
+ end
354
+ if r2
355
+ r0 = r2
356
+ else
357
+ self.index = i0
358
+ r0 = nil
359
+ end
360
+ end
361
+
362
+ node_cache[:eol][start_index] = r0
363
+
364
+ return r0
365
+ end
366
+
367
+ def _nt_eof
368
+ start_index = index
369
+ if node_cache[:eof].has_key?(index)
370
+ cached = node_cache[:eof][index]
371
+ @index = cached.interval.end if cached
372
+ return cached
373
+ end
374
+
375
+ i0 = index
376
+ if index < input_length
377
+ r1 = (SyntaxNode).new(input, index...(index + 1))
378
+ @index += 1
379
+ else
380
+ terminal_parse_failure("any character")
381
+ r1 = nil
382
+ end
383
+ if r1
384
+ r0 = nil
385
+ else
386
+ self.index = i0
387
+ r0 = SyntaxNode.new(input, index...index)
388
+ end
389
+
390
+ node_cache[:eof][start_index] = r0
391
+
392
+ return r0
393
+ end
394
+
395
+ end
396
+
397
+ class TableParser < Treetop::Runtime::CompiledParser
398
+ include Table
399
+ end
400
+
401
+ end
402
+ end