aslakhellesoy-cucumber 0.1.5 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. data/History.txt +228 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +226 -0
  4. data/README.txt +41 -0
  5. data/Rakefile +9 -0
  6. data/TODO.txt +26 -0
  7. data/bin/cucumber +5 -0
  8. data/config/hoe.rb +69 -0
  9. data/config/requirements.rb +15 -0
  10. data/cucumber.yml +1 -0
  11. data/examples/calculator_ruby_features/Rakefile +6 -0
  12. data/examples/calculator_ruby_features/features/addition.rb +23 -0
  13. data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +43 -0
  14. data/examples/cs/README.textile +22 -0
  15. data/examples/cs/Rakefile +12 -0
  16. data/examples/cs/features/hello.feature +11 -0
  17. data/examples/cs/features/step_definitons/hello_steps.rb +25 -0
  18. data/examples/cs/features/step_definitons/tree_steps.rb +14 -0
  19. data/examples/cs/features/tree.feature +9 -0
  20. data/examples/cs/src/Hello.cs +18 -0
  21. data/examples/dos_line_endings/Rakefile +6 -0
  22. data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
  23. data/examples/i18n/README.textile +18 -0
  24. data/examples/i18n/Rakefile +16 -0
  25. data/examples/i18n/ar/Rakefile +6 -0
  26. data/examples/i18n/ar/features/addition.feature +17 -0
  27. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +31 -0
  28. data/examples/i18n/ar/lib/calculator.rb +10 -0
  29. data/examples/i18n/da/Rakefile +6 -0
  30. data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +22 -0
  31. data/examples/i18n/da/features/summering.feature +17 -0
  32. data/examples/i18n/da/lib/kalkulator.rb +11 -0
  33. data/examples/i18n/en/Rakefile +5 -0
  34. data/examples/i18n/en/features/addition.feature +17 -0
  35. data/examples/i18n/en/features/division.feature +10 -0
  36. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +31 -0
  37. data/examples/i18n/en/lib/calculator.rb +14 -0
  38. data/examples/i18n/es/Rakefile +6 -0
  39. data/examples/i18n/es/features/adicion.feature +17 -0
  40. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +22 -0
  41. data/examples/i18n/es/lib/calculador.rb +11 -0
  42. data/examples/i18n/et/Rakefile +6 -0
  43. data/examples/i18n/et/features/liitmine.feature +17 -0
  44. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +26 -0
  45. data/examples/i18n/et/lib/kalkulaator.rb +10 -0
  46. data/examples/i18n/fr/Rakefile +6 -0
  47. data/examples/i18n/fr/features/addition.feature +13 -0
  48. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +22 -0
  49. data/examples/i18n/fr/lib/calculatrice.rb +10 -0
  50. data/examples/i18n/id/Rakefile +6 -0
  51. data/examples/i18n/id/features/addition.feature +17 -0
  52. data/examples/i18n/id/features/division.feature +10 -0
  53. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +31 -0
  54. data/examples/i18n/id/lib/calculator.rb +14 -0
  55. data/examples/i18n/it/Rakefile +6 -0
  56. data/examples/i18n/it/features/somma.feature +10 -0
  57. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +22 -0
  58. data/examples/i18n/it/lib/calcolatrice.rb +11 -0
  59. data/examples/i18n/ja/README.txt +5 -0
  60. data/examples/i18n/ja/Rakefile +6 -0
  61. data/examples/i18n/ja/features/addition.feature +17 -0
  62. data/examples/i18n/ja/features/division.feature +10 -0
  63. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +30 -0
  64. data/examples/i18n/ja/lib/calculator.rb +14 -0
  65. data/examples/i18n/no/Rakefile +6 -0
  66. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +22 -0
  67. data/examples/i18n/no/features/summering.feature +17 -0
  68. data/examples/i18n/no/lib/kalkulator.rb +11 -0
  69. data/examples/i18n/pt/Rakefile +6 -0
  70. data/examples/i18n/pt/features/adicao.feature +10 -0
  71. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +22 -0
  72. data/examples/i18n/pt/lib/calculadora.rb +10 -0
  73. data/examples/i18n/ro/Rakefile +6 -0
  74. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +22 -0
  75. data/examples/i18n/ro/features/suma.feature +10 -0
  76. data/examples/i18n/ro/lib/calculator.rb +11 -0
  77. data/examples/i18n/se/Rakefile +6 -0
  78. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +22 -0
  79. data/examples/i18n/se/features/summering.feature +17 -0
  80. data/examples/i18n/se/lib/kalkulator.rb +11 -0
  81. data/examples/i18n/zh-CN/Rakefile +6 -0
  82. data/examples/i18n/zh-CN/features/addition.feature +17 -0
  83. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +24 -0
  84. data/examples/i18n/zh-CN/lib/calculator.rb +10 -0
  85. data/examples/java/README.textile +22 -0
  86. data/examples/java/Rakefile +12 -0
  87. data/examples/java/features/hello.feature +11 -0
  88. data/examples/java/features/step_definitons/hello_steps.rb +25 -0
  89. data/examples/java/features/step_definitons/tree_steps.rb +14 -0
  90. data/examples/java/features/tree.feature +9 -0
  91. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  92. data/examples/selenium/Rakefile +6 -0
  93. data/examples/selenium/features/search.feature +9 -0
  94. data/examples/selenium/features/step_definitons/stories_steps.rb +41 -0
  95. data/examples/tickets/Rakefile +11 -0
  96. data/examples/tickets/cucumber.yml +2 -0
  97. data/examples/tickets/features/step_definitons/tickets_steps.rb +32 -0
  98. data/examples/tickets/features/tickets.feature +22 -0
  99. data/examples/watir/Rakefile +6 -0
  100. data/examples/watir/features/search.feature +9 -0
  101. data/examples/watir/features/step_definitons/stories_steps.rb +51 -0
  102. data/features/see_features.feature +8 -0
  103. data/features/steps/features_steps.rb +9 -0
  104. data/gem_tasks/deployment.rake +34 -0
  105. data/gem_tasks/environment.rake +7 -0
  106. data/gem_tasks/features.rake +6 -0
  107. data/gem_tasks/fix_cr_lf.rake +10 -0
  108. data/gem_tasks/flog.rake +4 -0
  109. data/gem_tasks/gemspec.rake +6 -0
  110. data/gem_tasks/rspec.rake +21 -0
  111. data/gem_tasks/treetop.rake +41 -0
  112. data/lib/autotest/cucumber.rb +6 -0
  113. data/lib/autotest/cucumber_mixin.rb +109 -0
  114. data/lib/autotest/cucumber_rails.rb +6 -0
  115. data/lib/autotest/cucumber_rails_rspec.rb +6 -0
  116. data/lib/autotest/cucumber_rspec.rb +6 -0
  117. data/lib/autotest/discover.rb +9 -0
  118. data/lib/cucumber.rb +39 -0
  119. data/lib/cucumber/broadcaster.rb +20 -0
  120. data/lib/cucumber/cli.rb +269 -0
  121. data/lib/cucumber/core_ext/proc.rb +54 -0
  122. data/lib/cucumber/core_ext/string.rb +22 -0
  123. data/lib/cucumber/executor.rb +170 -0
  124. data/lib/cucumber/formatters.rb +1 -0
  125. data/lib/cucumber/formatters/ansicolor.rb +111 -0
  126. data/lib/cucumber/formatters/autotest_formatter.rb +23 -0
  127. data/lib/cucumber/formatters/cucumber.css +132 -0
  128. data/lib/cucumber/formatters/cucumber.js +11 -0
  129. data/lib/cucumber/formatters/html_formatter.rb +128 -0
  130. data/lib/cucumber/formatters/jquery.js +32 -0
  131. data/lib/cucumber/formatters/pretty_formatter.rb +234 -0
  132. data/lib/cucumber/formatters/profile_formatter.rb +92 -0
  133. data/lib/cucumber/formatters/progress_formatter.rb +58 -0
  134. data/lib/cucumber/languages.yml +235 -0
  135. data/lib/cucumber/model.rb +1 -0
  136. data/lib/cucumber/model/table.rb +28 -0
  137. data/lib/cucumber/rails/rspec.rb +12 -0
  138. data/lib/cucumber/rails/world.rb +73 -0
  139. data/lib/cucumber/rake/task.rb +101 -0
  140. data/lib/cucumber/step_methods.rb +49 -0
  141. data/lib/cucumber/step_mother.rb +89 -0
  142. data/lib/cucumber/tree.rb +18 -0
  143. data/lib/cucumber/tree/feature.rb +61 -0
  144. data/lib/cucumber/tree/features.rb +21 -0
  145. data/lib/cucumber/tree/given_scenario.rb +13 -0
  146. data/lib/cucumber/tree/scenario.rb +158 -0
  147. data/lib/cucumber/tree/step.rb +134 -0
  148. data/lib/cucumber/tree/table.rb +26 -0
  149. data/lib/cucumber/tree/top_down_visitor.rb +23 -0
  150. data/lib/cucumber/treetop_parser/feature.treetop.erb +206 -0
  151. data/lib/cucumber/treetop_parser/feature_ar.rb +1591 -0
  152. data/lib/cucumber/treetop_parser/feature_cy.rb +1591 -0
  153. data/lib/cucumber/treetop_parser/feature_da.rb +1591 -0
  154. data/lib/cucumber/treetop_parser/feature_de.rb +1591 -0
  155. data/lib/cucumber/treetop_parser/feature_en-tx.rb +1591 -0
  156. data/lib/cucumber/treetop_parser/feature_en.rb +1591 -0
  157. data/lib/cucumber/treetop_parser/feature_es.rb +1591 -0
  158. data/lib/cucumber/treetop_parser/feature_et.rb +1591 -0
  159. data/lib/cucumber/treetop_parser/feature_fr.rb +1591 -0
  160. data/lib/cucumber/treetop_parser/feature_id.rb +1591 -0
  161. data/lib/cucumber/treetop_parser/feature_it.rb +1591 -0
  162. data/lib/cucumber/treetop_parser/feature_ja.rb +1591 -0
  163. data/lib/cucumber/treetop_parser/feature_nl.rb +1591 -0
  164. data/lib/cucumber/treetop_parser/feature_no.rb +1591 -0
  165. data/lib/cucumber/treetop_parser/feature_parser.rb +34 -0
  166. data/lib/cucumber/treetop_parser/feature_pl.rb +1591 -0
  167. data/lib/cucumber/treetop_parser/feature_pt.rb +1591 -0
  168. data/lib/cucumber/treetop_parser/feature_ro.rb +1591 -0
  169. data/lib/cucumber/treetop_parser/feature_ro2.rb +1591 -0
  170. data/lib/cucumber/treetop_parser/feature_ru.rb +1591 -0
  171. data/lib/cucumber/treetop_parser/feature_se.rb +1591 -0
  172. data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1591 -0
  173. data/lib/cucumber/version.rb +9 -0
  174. data/rails_generators/cucumber/USAGE +11 -0
  175. data/rails_generators/cucumber/cucumber_generator.rb +30 -0
  176. data/rails_generators/cucumber/templates/cucumber +7 -0
  177. data/rails_generators/cucumber/templates/cucumber.rake +7 -0
  178. data/rails_generators/cucumber/templates/env.rb +8 -0
  179. data/rails_generators/cucumber/templates/webrat_steps.rb +46 -0
  180. data/rails_generators/feature/USAGE +12 -0
  181. data/rails_generators/feature/feature_generator.rb +16 -0
  182. data/rails_generators/feature/templates/feature.erb +28 -0
  183. data/rails_generators/feature/templates/steps.erb +22 -0
  184. data/script/console +10 -0
  185. data/script/console.cmd +1 -0
  186. data/script/destroy +14 -0
  187. data/script/destroy.cmd +1 -0
  188. data/script/generate +14 -0
  189. data/script/generate.cmd +1 -0
  190. data/script/txt2html +74 -0
  191. data/script/txt2html.cmd +1 -0
  192. data/setup.rb +1585 -0
  193. data/spec/cucumber/broadcaster_spec.rb +27 -0
  194. data/spec/cucumber/cli_spec.rb +242 -0
  195. data/spec/cucumber/core_ext/proc_spec.rb +45 -0
  196. data/spec/cucumber/core_ext/string_spec.rb +34 -0
  197. data/spec/cucumber/executor_spec.rb +222 -0
  198. data/spec/cucumber/formatters/ansicolor_spec.rb +35 -0
  199. data/spec/cucumber/formatters/autotest_formatter_spec.rb +26 -0
  200. data/spec/cucumber/formatters/features.html +269 -0
  201. data/spec/cucumber/formatters/html_formatter_spec.rb +74 -0
  202. data/spec/cucumber/formatters/pretty_formatter_spec.rb +204 -0
  203. data/spec/cucumber/formatters/profile_formatter_spec.rb +192 -0
  204. data/spec/cucumber/formatters/progress_formatter_spec.rb +65 -0
  205. data/spec/cucumber/model/table_spec.rb +20 -0
  206. data/spec/cucumber/rails/stubs/mini_rails.rb +17 -0
  207. data/spec/cucumber/rails/stubs/test_help.rb +1 -0
  208. data/spec/cucumber/rails/world_spec.rb +11 -0
  209. data/spec/cucumber/sell_cucumbers.feature +19 -0
  210. data/spec/cucumber/step_mother_spec.rb +74 -0
  211. data/spec/cucumber/tree/feature_spec.rb +12 -0
  212. data/spec/cucumber/tree/row_scenario_spec.rb +25 -0
  213. data/spec/cucumber/tree/scenario_spec.rb +76 -0
  214. data/spec/cucumber/tree/step_spec.rb +50 -0
  215. data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
  216. data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
  217. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +98 -0
  218. data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
  219. data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
  220. data/spec/cucumber/treetop_parser/multiline_steps.feature +17 -0
  221. data/spec/cucumber/treetop_parser/multiple_tables.feature +29 -0
  222. data/spec/cucumber/treetop_parser/spaces.feature +10 -0
  223. data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
  224. data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
  225. data/spec/spec.opts +2 -0
  226. data/spec/spec_helper.rb +19 -0
  227. metadata +151 -35
@@ -0,0 +1,58 @@
1
+ require 'cucumber/formatters/ansicolor'
2
+
3
+ module Cucumber
4
+ module Formatters
5
+ class ProgressFormatter
6
+ include ANSIColor
7
+
8
+ def initialize(io)
9
+ @io = (io == STDOUT) ? Kernel : io
10
+ @errors = []
11
+ @pending_scenarios = []
12
+ end
13
+
14
+ def scenario_executing(scenario)
15
+ if scenario.pending?
16
+ @pending_scenarios << scenario
17
+ @io.print pending("P")
18
+ end
19
+ end
20
+
21
+ def step_passed(step, regexp, args)
22
+ @io.print passed('.')
23
+ end
24
+
25
+ def step_failed(step, regexp, args)
26
+ @errors << step.error
27
+ @io.print failed('F')
28
+ end
29
+
30
+ def step_pending(step, regexp, args)
31
+ @pending_scenarios << step.scenario
32
+ @io.print pending('P')
33
+ end
34
+
35
+ def step_skipped(step, regexp, args)
36
+ @io.print skipped('_')
37
+ end
38
+
39
+ def dump
40
+ @io.puts pending
41
+ @io.puts "\nPending Scenarios:\n\n" if @pending_scenarios.any?
42
+ @pending_scenarios.uniq.each_with_index do |scenario, n|
43
+ @io.puts "#{n+1}) #{scenario.feature.header.split("\n").first.gsub(/^(Feature|Story):/, '')} (#{scenario.name})"
44
+ end
45
+
46
+ @io.puts failed
47
+ @io.puts "\nFailed:" if @errors.any?
48
+ @errors.each_with_index do |error,n|
49
+ @io.puts
50
+ @io.puts "#{n+1})"
51
+ @io.puts error.message
52
+ @io.puts error.backtrace.join("\n")
53
+ end
54
+ @io.print reset
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,235 @@
1
+ # http://www.ietf.org/rfc/rfc4646.txt
2
+ # http://www.ietf.org/rfc/rfc4647.txt
3
+ # Others:
4
+ # http://en.wikipedia.org/wiki/IETF_language_tag
5
+ # http://www.iana.org/assignments/language-subtag-registry
6
+ # http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt (Use this I think)
7
+ "en":
8
+ feature: Feature
9
+ scenario: Scenario
10
+ more_examples: More Examples
11
+ given_scenario: GivenScenario
12
+ given: Given
13
+ when: When
14
+ then: Then
15
+ and: And
16
+ but: But
17
+ # Please help us keeping the languages below uptodate. The parsers for a language
18
+ # that is missing a keyword will expect the English word until the missing word(s)
19
+ # are added.
20
+ #
21
+ # Please keep the grammars in alphabetical order from here and down.
22
+
23
+ # Arabic
24
+ "ar":
25
+ feature: خاصية
26
+ scenario: سيناريو
27
+ more_examples: امثلة اكثر
28
+ given_scenario: بفرض سيناريو معين
29
+ given: بفرض
30
+ when: متى
31
+ then: اذاً
32
+ and: و
33
+ but: لكن
34
+ # Welsh
35
+ "cy":
36
+ feature: Arwedd
37
+ scenario: Scenario
38
+ more_examples: Hychwaneg enghreifftiau
39
+ given_scenario: Anrhegedig scenario
40
+ given: anrhegedig a
41
+ when: Pryd
42
+ then: Yna
43
+ and: A
44
+ but: Ond
45
+ # Danish
46
+ "da":
47
+ feature: Egenskab
48
+ scenario: Scenarie
49
+ given_scenario: GivetScenarie
50
+ given: Givet
51
+ when: Når
52
+ then: Så
53
+ and: Og
54
+ but: Men
55
+ # German
56
+ "de":
57
+ feature: Funktionalität
58
+ scenario: Szenario
59
+ given_scenario: GegebenesSzenario
60
+ given: Gegeben sei
61
+ when: Wenn
62
+ then: Dann
63
+ and: Und
64
+ but: Aber
65
+ # Texan
66
+ "en-tx":
67
+ feature: Feature
68
+ scenario: Scenario
69
+ more_examples: More Examples
70
+ given_scenario: GivenScenario
71
+ given: Given y'all
72
+ when: When y'all
73
+ then: Then y'all
74
+ and: And y'all
75
+ but: But y'all
76
+ # Spanish
77
+ "es":
78
+ feature: Característica
79
+ scenario: Escenario
80
+ more_examples: Más ejemplos
81
+ given_scenario: DadoElEscenario
82
+ given: Dado
83
+ when: Cuando
84
+ then: Entonces
85
+ and: Y
86
+ but: Pero
87
+ # Estonian
88
+ "et":
89
+ feature: Omadus
90
+ scenario: Stsenaarium
91
+ given_scenario: EeldadesStsenaariumit
92
+ given: Eeldades
93
+ when: Kui
94
+ then: Siis
95
+ and: Ja
96
+ but: Kuid
97
+ # French
98
+ "fr":
99
+ feature: Fonction
100
+ scenario: Scenario
101
+ more_examples: Plus d'exemples
102
+ given_scenario: SoitScenario
103
+ given: Soit
104
+ when: Lorsque
105
+ then: Alors
106
+ and: Et
107
+ but: Mais
108
+ # Malay
109
+ "id":
110
+ feature: Fitur
111
+ scenario: Skenario
112
+ more_examples: Contoh Tambahan
113
+ given_scenario: DenganSkenario
114
+ given: Dengan
115
+ when: Ketika
116
+ then: Maka
117
+ and: Dan
118
+ but: Tapi
119
+ # Italian
120
+ "it":
121
+ feature: Funzionalità
122
+ scenario: Scenario
123
+ more_examples: Più esempi
124
+ given_scenario: DatoLoScenario
125
+ given: Dato
126
+ when: Quando
127
+ then: Allora
128
+ and: E
129
+ but: Ma
130
+ # Japanese
131
+ "ja":
132
+ feature: フィーチャ
133
+ scenario: シナリオ
134
+ more_examples: 他のサンプル
135
+ given_scenario: 前提シナリオ
136
+ given: 前提
137
+ when: もし
138
+ then: ならば
139
+ and: かつ
140
+ but: しかし
141
+ # Dutch
142
+ "nl":
143
+ feature: Functionaliteit
144
+ scenario: Scenario
145
+ more_examples: Meer voorbeelden
146
+ given_scenario: GegevenScenario
147
+ given: Gegeven
148
+ when: Als
149
+ then: Dan
150
+ and: En
151
+ but: Maar
152
+ # Norwegian
153
+ "no":
154
+ feature: Egenskap
155
+ scenario: Scenario
156
+ more_examples: Flere eksempler
157
+ given_scenario: GittScenario
158
+ given: Gitt
159
+ when: Når
160
+ then: Så
161
+ and: Og
162
+ but: Men
163
+ # Polish
164
+ "pl":
165
+ feature: Właściwość
166
+ scenario: Scenariusz
167
+ more_examples: WięcejPrzykładów
168
+ given_scenario: DanyScenariusz
169
+ given: Dane
170
+ when: Jeżeli
171
+ then: Wtedy
172
+ and: Oraz
173
+ but: Ale
174
+ # Portuguese
175
+ "pt":
176
+ feature: Característica
177
+ scenario: Cenário
178
+ given_scenario: DadoOCenário
179
+ given: Dado
180
+ when: Quando
181
+ then: Então
182
+ and: E
183
+ but: Mas
184
+ # Romanian (without diacritics - the commonly used)
185
+ "ro":
186
+ feature: Functionalitate
187
+ scenario: Scenariu
188
+ more_examples: Mai multe exemple
189
+ given_scenario: ScenariuDat
190
+ given: Daca
191
+ when: Cand
192
+ then: Atunci
193
+ and: Si
194
+ but: Dar
195
+ # Romanian (with diacritics - not commonly used)
196
+ "ro2":
197
+ feature: Funcționalitate
198
+ scenario: Scenariu
199
+ more_examples: Mai multe exemple
200
+ given_scenario: ScenariuDat
201
+ given: Dacă
202
+ when: Când
203
+ then: Atunci
204
+ and: Și
205
+ but: Dar
206
+ # Russian
207
+ "ru":
208
+ feature: Функционал
209
+ scenario: Сценарий
210
+ given_scenario: ДанныйСценарий
211
+ given: Сначала
212
+ when: Если
213
+ then: То
214
+ and: И
215
+ but: Но
216
+ # Swedish
217
+ "se":
218
+ feature: Egenskap
219
+ scenario: Scenario
220
+ given_scenario: GivetScenario
221
+ given: Givet
222
+ when: När
223
+ then: Så
224
+ and: Och
225
+ but: Men
226
+ # Chinese simplified
227
+ "zh-CN":
228
+ feature: 功能
229
+ scenario: 场景
230
+ given_scenario: 引用场景
231
+ given: 假如
232
+ when: 当
233
+ then: 那么
234
+ and: 而且
235
+ but: 但是
@@ -0,0 +1 @@
1
+ %w{table}.each{|f| require "cucumber/model/#{f}"}
@@ -0,0 +1,28 @@
1
+ module Cucumber
2
+ module Model
3
+ class Table
4
+ attr_accessor :raw
5
+
6
+ # Creates a new table. The +raw+ argument should be an array
7
+ # of arrays
8
+ def initialize(raw)
9
+ @raw = raw
10
+ end
11
+
12
+ # Turn the table into an array of Hash where each Hash
13
+ # has keys corresponding to the table header (first line)
14
+ # and the values are the individual row cells.
15
+ def hashes
16
+ header = @raw[0]
17
+ @raw[1..-1].map do |row|
18
+ h = {}
19
+ row.each_with_index do |v,n|
20
+ key = header[n]
21
+ h[key] = v
22
+ end
23
+ h
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec'
2
+ require 'spec/rails'
3
+
4
+ # Hack to stop RSpec from dumping the summary
5
+ Spec::Runner::Options.class_eval do
6
+ def examples_should_be_run?
7
+ false
8
+ end
9
+ end
10
+
11
+ ActionController::Integration::Session.send(:include, Spec::Matchers)
12
+ ActionController::Integration::Session.send(:include, Spec::Rails::Matchers)
@@ -0,0 +1,73 @@
1
+ # Based on code from Brian Takita, Yurii Rashkovskii and Ben Mabey
2
+ # Adapted by Aslak Hellesøy
3
+
4
+ if defined?(ActiveRecord::Base)
5
+ require 'test_help'
6
+ else
7
+ require 'action_controller/test_process'
8
+ require 'action_controller/integration'
9
+ end
10
+ require 'test/unit/testresult'
11
+
12
+ # These allow exceptions to come through as opposed to being caught and having non-helpful responses returned.
13
+ ActionController::Base.class_eval do
14
+ def perform_action
15
+ perform_action_without_rescue
16
+ end
17
+ end
18
+ Dispatcher.class_eval do
19
+ def self.failsafe_response(output, status, exception = nil)
20
+ raise exception
21
+ end
22
+ end
23
+
24
+ # So that Test::Unit doesn't launch at the end - makes it think it has already been run.
25
+ Test::Unit.run = true if Test::Unit.respond_to?(:run=)
26
+
27
+ $main = self
28
+
29
+ module Cucumber #:nodoc:
30
+ module Rails
31
+ # All scenarios will execute in the context of a new instance of World.
32
+ class World < ActionController::IntegrationTest
33
+ if defined?(ActiveRecord::Base)
34
+ self.use_transactional_fixtures = false
35
+ else
36
+ def self.fixture_table_names; []; end # Workaround for projects that don't use ActiveRecord
37
+ end
38
+
39
+ def initialize #:nodoc:
40
+ @_result = Test::Unit::TestResult.new
41
+ end
42
+ end
43
+
44
+ def self.use_transactional_fixtures
45
+ World.use_transactional_fixtures = true
46
+ if defined?(ActiveRecord::Base)
47
+ $main.Before do
48
+ if ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
49
+ ActiveRecord::Base.connection.increment_open_transactions
50
+ else
51
+ ActiveRecord::Base.send :increment_open_transactions
52
+ end
53
+ ActiveRecord::Base.connection.begin_db_transaction
54
+ ActionMailer::Base.deliveries = [] if defined?(ActionMailer::Base)
55
+ end
56
+
57
+ $main.After do
58
+ ActiveRecord::Base.connection.rollback_db_transaction
59
+ if ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
60
+ ActiveRecord::Base.connection.decrement_open_transactions
61
+ else
62
+ ActiveRecord::Base.send :decrement_open_transactions
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ end
69
+ end
70
+
71
+ World do
72
+ Cucumber::Rails::World.new
73
+ end
@@ -0,0 +1,101 @@
1
+ module Cucumber
2
+ module Rake
3
+ # Defines a task for running features.
4
+ class Task
5
+ LIB = File.expand_path(File.dirname(__FILE__) + '/../..')
6
+
7
+ attr_accessor :libs
8
+ attr_accessor :binary
9
+ attr_accessor :step_list
10
+ attr_accessor :step_pattern
11
+ attr_accessor :feature_list
12
+ attr_accessor :feature_pattern
13
+ attr_accessor :cucumber_opts
14
+ attr_accessor :rcov
15
+ attr_accessor :rcov_opts
16
+
17
+ # Define a task
18
+ def initialize(task_name = "features", desc = "Run Features with Cucumber")
19
+ @task_name, @desc = task_name, desc
20
+ @libs = []
21
+ @rcov_opts = %w{--rails --exclude osx\/objc,gems\/}
22
+
23
+ yield self if block_given?
24
+
25
+ @feature_pattern = "features/**/*.feature" if feature_pattern.nil? && feature_list.nil?
26
+ @step_pattern = "features/**/*.rb" if step_pattern.nil? && step_list.nil?
27
+ @binary ||= File.expand_path(File.dirname(__FILE__) + '/../../../bin/cucumber')
28
+ define_task
29
+ end
30
+
31
+ def define_task
32
+ desc @desc
33
+ task @task_name do
34
+ ruby(arguments_for_ruby_execution.join(" ")) # ruby(*args) is broken on Windows
35
+ end
36
+ end
37
+
38
+ def arguments_for_ruby_execution(task_args = nil)
39
+ lib_args = ['"%s"' % ([LIB] + libs).join(File::PATH_SEPARATOR)]
40
+ cucumber_bin = ['"%s"' % binary]
41
+ cuc_opts = [(ENV['CUCUMBER_OPTS'] || cucumber_opts)]
42
+
43
+ step_files(task_args).each do |step_file|
44
+ cuc_opts << '--require'
45
+ cuc_opts << step_file
46
+ end
47
+
48
+ if rcov
49
+ args = (['-I'] + lib_args + ['-S', 'rcov'] + rcov_opts +
50
+ cucumber_bin + ['--'] + cuc_opts + feature_files(task_args)).flatten
51
+ else
52
+ args = (['-I'] + lib_args + cucumber_bin + cuc_opts + feature_files(task_args)).flatten
53
+ end
54
+
55
+ args
56
+ end
57
+
58
+ def feature_files(task_args = nil) # :nodoc:
59
+ if ENV['FEATURE']
60
+ FileList[ ENV['FEATURE'] ]
61
+ else
62
+ result = []
63
+ result += feature_list.to_a if feature_list
64
+ result += FileList[feature_pattern].to_a if feature_pattern
65
+ FileList[result]
66
+ end
67
+ end
68
+
69
+ def step_files(task_args = nil) # :nodoc:
70
+ if ENV['STEPS']
71
+ FileList[ ENV['STEPS'] ]
72
+ else
73
+ result = []
74
+ result += Array(step_list) if step_list
75
+ result += Array(FileList[step_pattern]) if step_pattern
76
+ FileList[result]
77
+ end
78
+ end
79
+ end
80
+
81
+ class FeatureTask < Task
82
+
83
+ def initialize(task_name = "feature", desc = "Run a specified feature with Cucumber. #{task_name}[feature_name]")
84
+ super(task_name, desc)
85
+ end
86
+
87
+ def define_task
88
+ desc @desc
89
+ task @task_name, :feature_name do |t, args|
90
+ ruby(arguments_for_ruby_execution(args).join(" ")) # ruby(*args) is broken on Windows
91
+ end
92
+ end
93
+
94
+ def feature_files(task_arguments) # :nodoc:
95
+ FileList[File.join("features", "**", "#{task_arguments[:feature_name]}.feature")]
96
+ end
97
+
98
+ end
99
+
100
+ end
101
+ end