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
@@ -1,39 +0,0 @@
1
- require 'cucumber/cli' # Needed in order to run the feature with ruby
2
-
3
- Feature %|Addition
4
- In order to avoid silly mistakes
5
- As a math idiot
6
- I want to be told the sum of two numbers| do
7
-
8
- Scenario "Add two numbers" do
9
- Given "I have entered 50 into the calculator"
10
- And "I have entered 70 into the calculator"
11
- When "I add"
12
- Then "the result should be 120 on the screen"
13
- And "the result class should be Fixnum"
14
- end
15
-
16
- Table do |t|
17
- t | "input_1" | "input_2" | "output" | "class" | t
18
- # This is kind of dumb - but it illustrates how scenarios can be "generated" in code.
19
- 10.times do |n|
20
- t | n | n*2 | n*3 | Fixnum | t
21
- end
22
- end
23
-
24
- ScenarioOutline "Add two numbers" do
25
- Given "I have entered <input_1> into the calculator"
26
- And "I have entered <input_2> into the calculator"
27
- When "I add"
28
- Then "the result should be <output> on the screen"
29
- And "the result class should be <class>"
30
- end
31
-
32
- Table do |t|
33
- t | "input_1" | "input_2" | "output" | "class" | t
34
- 10.times do |n|
35
- t | n | n*2 | n*3 | Fixnum | t
36
- end
37
- end
38
-
39
- end
@@ -1,43 +0,0 @@
1
- require 'spec/expectations'
2
-
3
- class Calculator
4
- def push(n)
5
- @args ||= []
6
- @args << n
7
- end
8
-
9
- def add
10
- @args.inject(0){|n,sum| sum+=n}
11
- end
12
-
13
- def divide
14
- @args[0].to_f / @args[1].to_f
15
- end
16
- end
17
-
18
- Before do
19
- @calc = Calculator.new
20
- end
21
-
22
- After do
23
- end
24
-
25
- Given /I have entered (\d+) into the calculator/ do |n|
26
- @calc.push n.to_i
27
- end
28
-
29
- When 'I add' do
30
- @result = @calc.add
31
- end
32
-
33
- When 'I divide' do
34
- @result = @calc.divide
35
- end
36
-
37
- Then /the result should be (\d*) on the screen/ do |result|
38
- @result.should == result.to_i
39
- end
40
-
41
- Then /the result class should be (\w*)/ do |class_name|
42
- @result.class.name.should == class_name
43
- end
@@ -1,5 +0,0 @@
1
- Run the features with
2
-
3
- rake features
4
-
5
- There is a bug in the calculator. Can you spot it and fix it?
@@ -1,40 +0,0 @@
1
- require 'spec/expectations'
2
- require 'selenium'
3
-
4
- class GoogleSearch
5
- def initialize(browser)
6
- @browser = browser
7
- end
8
-
9
- def goto
10
- @browser.open 'http://www.google.com/'
11
- end
12
-
13
- def search(text)
14
- @browser.type('q',text)
15
- @browser.click 'btnG'
16
- @browser.wait_for_page_to_load
17
- end
18
- end
19
-
20
- Before do
21
- @browser = Selenium::SeleniumDriver.new("localhost", 4444, "*chrome", "http://localhost", 15000)
22
- @browser.start
23
- end
24
-
25
- After do
26
- @browser.stop
27
- end
28
-
29
- Given 'I am on the Google search page' do
30
- @page = GoogleSearch.new(@browser)
31
- @page.goto
32
- end
33
-
34
- When /I search for "(.*)"/ do |query|
35
- @page.search(query)
36
- end
37
-
38
- Then /I should see a link to (.*)/ do |expected_url|
39
- @browser.is_element_present("css=a[href='#{expected_url}']").should be_true
40
- end
@@ -1,41 +0,0 @@
1
- class FeatureCompiler
2
- def initialize
3
- require 'yaml'
4
- require 'erb'
5
-
6
- @tt = RUBY_PLATFORM =~ /mswin|mingw/ ? 'tt.bat' : 'tt'
7
-
8
- @template = ERB.new(IO.read(File.dirname(__FILE__) + '/../lib/cucumber/treetop_parser/feature.treetop.erb'))
9
- @langs = YAML.load_file(File.dirname(__FILE__) + '/../lib/cucumber/languages.yml')
10
- end
11
-
12
- def compile_all
13
- @langs.keys.each do |lang|
14
- compile(lang)
15
- end
16
- end
17
-
18
- def compile(lang)
19
- words = @langs['en'].merge(@langs[lang]) # Use English words if languages.yml is missing a word
20
- grammar_file = File.dirname(__FILE__) + "/../lib/cucumber/treetop_parser/feature_#{lang}.treetop"
21
- ruby_file = File.dirname(__FILE__) + "/../lib/cucumber/treetop_parser/feature_#{lang}.rb"
22
- grammar = @template.result(binding)
23
- File.open(grammar_file, "wb") do |io|
24
- io.write(grammar)
25
- end
26
- sh "#{@tt} #{grammar_file}"
27
- FileUtils.rm(grammar_file)
28
- end
29
- end
30
-
31
- namespace :treetop do
32
- desc 'Compile the grammar for all languages in languages.yml'
33
- task :compile do
34
- FeatureCompiler.new.compile_all
35
- end
36
-
37
- desc 'Compile the English grammar'
38
- task :compile_en do
39
- FeatureCompiler.new.compile('en')
40
- end
41
- end
@@ -1,356 +0,0 @@
1
- require 'optparse'
2
- require 'cucumber'
3
- require 'ostruct'
4
-
5
- module Cucumber
6
- class YmlLoadError < StandardError; end
7
-
8
- class CLI
9
- class << self
10
- attr_writer :step_mother, :executor, :features
11
-
12
- def execute(args)
13
- parse(args).execute!(@step_mother, @executor, @features)
14
- end
15
-
16
- def parse(args)
17
- cli = new
18
- cli.parse_options!(args)
19
- cli
20
- end
21
- end
22
-
23
- attr_reader :options, :paths
24
- FORMATS = %w{pretty profile progress html autotest}
25
- DEFAULT_FORMAT = 'pretty'
26
-
27
- def initialize(out_stream = STDOUT, error_stream = STDERR)
28
- @out_stream = out_stream
29
- @error_stream = error_stream
30
- @paths = []
31
- @options = {
32
- :require => nil,
33
- :lang => 'en',
34
- :dry_run => false,
35
- :source => true,
36
- :snippets => true,
37
- :formats => {},
38
- :excludes => [],
39
- :scenario_names => nil
40
- }
41
- @active_format = DEFAULT_FORMAT
42
- end
43
-
44
- def parse_options!(args)
45
- @args = args
46
- return parse_args_from_profile('default') if args.empty?
47
- args.extend(OptionParser::Arguable)
48
-
49
- args.options do |opts|
50
- opts.banner = ["Usage: cucumber [options] [[FILE[:LINE[:LINE]*]] | [FILES|DIRS]]", "",
51
- "Examples:",
52
- "cucumber examples/i18n/en/features",
53
- "cucumber --language it examples/i18n/it/features/somma.feature:6:98:113", "", ""
54
- ].join("\n")
55
- opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR", "Require files before executing the features.",
56
- "If this option is not specified, all *.rb files that",
57
- "are siblings or below the features will be autorequired",
58
- "This option can be specified multiple times.") do |v|
59
- @options[:require] ||= []
60
- @options[:require] << v
61
- end
62
- opts.on("-s SCENARIO", "--scenario SCENARIO", "Only execute the scenario with the given name.",
63
- "If this option is given more than once, run all",
64
- "the specified scenarios.") do |v|
65
- @options[:scenario_names] ||= []
66
- @options[:scenario_names] << v
67
- end
68
- opts.on("-l LANG", "--language LANG", "Specify language for features (Default: #{@options[:lang]})",
69
- "Available languages: #{Cucumber.languages.join(", ")}",
70
- "Look at #{Cucumber::LANGUAGE_FILE} for keywords") do |v|
71
- @options[:lang] = v
72
- end
73
- opts.on("-f FORMAT", "--format FORMAT", "How to format features (Default: #{DEFAULT_FORMAT})",
74
- "Available formats: #{FORMATS.join(", ")}",
75
- "You can also provide your own formatter classes as long as they have been",
76
- "previously required using --require or if they are in the folder",
77
- "structure such that cucumber will require them automatically.",
78
- "This option can be specified multiple times.") do |v|
79
-
80
- @options[:formats][v] ||= []
81
- @options[:formats][v] << @out_stream
82
- @active_format = v
83
- end
84
- opts.on("-o", "--out FILE", "Write output to a file instead of @out_stream.",
85
- "This option can be specified multiple times, and applies to the previously",
86
- "specified --format.") do |v|
87
- @options[:formats][@active_format] ||= []
88
- if @options[:formats][@active_format].last == @out_stream
89
- @options[:formats][@active_format][-1] = File.open(v, 'w')
90
- else
91
- @options[:formats][@active_format] << File.open(v, 'w')
92
- end
93
- end
94
- opts.on("-c", "--[no-]color", "Use ANSI color in the output, if formatters use it. If",
95
- "these options are given multiple times, the last one is",
96
- "used. If neither --color or --no-color is given cucumber",
97
- "decides based on your platform and the output destination") do |v|
98
- @options[:color] = v
99
- end
100
- opts.on("-e", "--exclude PATTERN", "Don't run features matching a pattern") do |v|
101
- @options[:excludes] << v
102
- end
103
- opts.on("-p", "--profile PROFILE", "Pull commandline arguments from cucumber.yml.") do |v|
104
- parse_args_from_profile(v)
105
- end
106
- opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.") do
107
- @options[:dry_run] = true
108
- end
109
- opts.on("-n", "--no-source", "Don't show the file and line of the step definition with the steps.") do
110
- @options[:source] = false
111
- end
112
- opts.on("-i", "--no-snippets", "Don't show the snippets for pending steps") do
113
- @options[:snippets] = false
114
- end
115
- opts.on("-q", "--quiet", "Don't show any development aid information") do
116
- @options[:snippets] = false
117
- @options[:source] = false
118
- end
119
- opts.on("-b", "--backtrace", "Show full backtrace for all errors") do
120
- Exception.cucumber_full_backtrace = true
121
- end
122
- opts.on("-v", "--verbose", "Show the files and features loaded") do
123
- @options[:verbose] = true
124
- end
125
- opts.on_tail("--version", "Show version") do
126
- @out_stream.puts VERSION::STRING
127
- Kernel.exit
128
- end
129
- opts.on_tail("--help", "You're looking at it") do
130
- @out_stream.puts opts.help
131
- Kernel.exit
132
- end
133
- end.parse!
134
-
135
- if @options[:formats].empty?
136
- @options[:formats][DEFAULT_FORMAT] = [@out_stream]
137
- end
138
-
139
- # Whatever is left after option parsing is the FILE arguments
140
- args = extract_and_store_line_numbers(args)
141
- @paths += args
142
- end
143
-
144
-
145
- def execute!(step_mother, executor, features)
146
- Term::ANSIColor.coloring = @options[:color] unless @options[:color].nil?
147
- Cucumber.load_language(@options[:lang])
148
- require_files
149
- enable_diffing
150
- executor.formatters = build_formatter_broadcaster(step_mother)
151
- load_plain_text_features(features)
152
- executor.lines_for_features = @options[:lines_for_features]
153
- executor.dry_run = @options[:dry_run] if @options[:dry_run]
154
- executor.scenario_names = @options[:scenario_names] if @options[:scenario_names]
155
- executor.visit_features(features)
156
- exit 1 if executor.failed
157
- end
158
-
159
- private
160
-
161
- def extract_and_store_line_numbers(file_arguments)
162
- @options[:lines_for_features] = Hash.new{|k,v| k[v] = []}
163
- file_arguments.map do |arg|
164
- _, file, lines = */^([\w\W]*?):([\d:]+)$/.match(arg)
165
- unless file.nil?
166
- @options[:lines_for_features][file] += lines.split(':').map { |line| line.to_i }
167
- arg = file
168
- end
169
- arg
170
- end
171
- end
172
-
173
- def cucumber_yml
174
- return @cucumber_yml if @cucumber_yml
175
- unless File.exist?('cucumber.yml')
176
- 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")
177
- end
178
-
179
- require 'yaml'
180
- begin
181
- @cucumber_yml = YAML::load(IO.read('cucumber.yml'))
182
- rescue Exception => e
183
- raise(YmlLoadError,"cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentaion on correct profile usage.\n")
184
- end
185
-
186
- if @cucumber_yml.nil? || !@cucumber_yml.is_a?(Hash)
187
- raise(YmlLoadError,"cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentaion on correct profile usage.\n")
188
- end
189
-
190
- return @cucumber_yml
191
- end
192
-
193
- def parse_args_from_profile(profile)
194
- unless cucumber_yml.has_key?(profile)
195
- return(exit_with_error <<-END_OF_ERROR)
196
- Could not find profile: '#{profile}'
197
-
198
- Defined profiles in cucumber.yml:
199
- * #{cucumber_yml.keys.join("\n * ")}
200
- END_OF_ERROR
201
- end
202
-
203
- args_from_yml = cucumber_yml[profile] || ''
204
-
205
- if !args_from_yml.is_a?(String)
206
- exit_with_error "Profiles must be defined as a String. The '#{profile}' profile was #{args_from_yml.inspect} (#{args_from_yml.class}).\n"
207
- elsif args_from_yml =~ /^\s*$/
208
- 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"
209
- else
210
- parse_options!(args_from_yml.split(' '))
211
- end
212
-
213
- rescue YmlLoadError => e
214
- exit_with_error(e.message)
215
- end
216
-
217
-
218
- # Requires files - typically step files and ruby feature files.
219
- def require_files
220
- @args.clear # Shut up RSpec
221
- require "cucumber/treetop_parser/feature_#{@options[:lang]}"
222
- require "cucumber/treetop_parser/feature_parser"
223
-
224
- verbose_log("Ruby files required:")
225
- files_to_require.each do |lib|
226
- begin
227
- require lib
228
- verbose_log(" * #{lib}")
229
- rescue LoadError => e
230
- e.message << "\nFailed to load #{lib}"
231
- raise e
232
- end
233
- end
234
- verbose_log("\n")
235
- end
236
-
237
- def files_to_require
238
- requires = @options[:require] || feature_dirs
239
- files = requires.map do |path|
240
- path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
241
- File.directory?(path) ? Dir["#{path}/**/*.rb"] : path
242
- end.flatten.uniq
243
- files.sort { |a,b| (b =~ %r{/support/} || -1) <=> (a =~ %r{/support/} || -1) }
244
- end
245
-
246
- def feature_files
247
- potential_feature_files = @paths.map do |path|
248
- path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
249
- path = path.chomp('/')
250
- File.directory?(path) ? Dir["#{path}/**/*.feature"] : path
251
- end.flatten.uniq
252
-
253
- @options[:excludes].each do |exclude|
254
- potential_feature_files.reject! do |path|
255
- path =~ /#{Regexp.escape(exclude)}/
256
- end
257
- end
258
-
259
- potential_feature_files
260
- end
261
-
262
- def feature_dirs
263
- feature_files.map{|f| File.directory?(f) ? f : File.dirname(f)}.uniq
264
- end
265
-
266
- def load_plain_text_features(features)
267
- parser = TreetopParser::FeatureParser.new
268
-
269
- verbose_log("Features:")
270
- feature_files.each do |f|
271
- features << parser.parse_feature(f)
272
- verbose_log(" * #{f}")
273
- end
274
- verbose_log("\n"*2)
275
- end
276
-
277
- def build_formatter_broadcaster(step_mother)
278
- formatter_broadcaster = Broadcaster.new
279
- @options[:formats].each do |format, output_list|
280
- output_broadcaster = build_output_broadcaster(output_list)
281
- case format
282
- when 'pretty'
283
- formatter_broadcaster.register(Formatters::PrettyFormatter.new(output_broadcaster, step_mother, @options))
284
- when 'progress'
285
- formatter_broadcaster.register(Formatters::ProgressFormatter.new(output_broadcaster))
286
- when 'profile'
287
- formatter_broadcaster.register(Formatters::ProfileFormatter.new(output_broadcaster, step_mother))
288
- when 'html'
289
- formatter_broadcaster.register(Formatters::HtmlFormatter.new(output_broadcaster, step_mother))
290
- when 'autotest'
291
- formatter_broadcaster.register(Formatters::AutotestFormatter.new(output_broadcaster))
292
- else
293
- begin
294
- formatter_class = constantize(format)
295
- formatter_broadcaster.register(formatter_class.new(output_broadcaster, step_mother, @options))
296
- rescue NameError => e
297
- @error_stream.puts "Invalid format: #{format}\n"
298
- exit_with_help
299
- rescue Exception => e
300
- exit_with_error("Error creating formatter: #{format}\n#{e}\n")
301
- end
302
- end
303
- end
304
- formatter_broadcaster
305
- end
306
-
307
- def build_output_broadcaster(output_list)
308
- output_broadcaster = Broadcaster.new
309
- output_list.each do |output|
310
- output_broadcaster.register(output)
311
- end
312
- output_broadcaster
313
- end
314
-
315
- private
316
-
317
- def constantize(camel_cased_word)
318
- names = camel_cased_word.split('::')
319
- names.shift if names.empty? || names.first.empty?
320
-
321
- constant = Object
322
- names.each do |name|
323
- constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
324
- end
325
- constant
326
- end
327
-
328
- def verbose_log(string)
329
- @out_stream.puts(string) if @options[:verbose]
330
- end
331
-
332
- def exit_with_help
333
- parse_options!(%w{--help})
334
- end
335
-
336
- def exit_with_error(error_message)
337
- @error_stream << error_message
338
- Kernel.exit 1
339
- end
340
-
341
- def enable_diffing
342
- if defined?(::Spec)
343
- require 'spec/expectations/differs/default'
344
- options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
345
- ::Spec::Expectations.differ = ::Spec::Expectations::Differs::Default.new(options)
346
- end
347
- end
348
- end
349
- end
350
-
351
- extend Cucumber::StepMethods
352
- Cucumber::CLI.step_mother = step_mother
353
- Cucumber::CLI.executor = executor
354
-
355
- extend Cucumber::Tree
356
- Cucumber::CLI.features = features