cucumber 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/History.txt +21 -1
  2. data/Manifest.txt +49 -47
  3. data/bin/cucumber +1 -1
  4. data/config/hoe.rb +2 -2
  5. data/examples/i18n/Rakefile +6 -8
  6. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
  7. data/examples/i18n/ar/lib/calculator.rb +1 -0
  8. data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +1 -1
  9. data/examples/i18n/de/features/step_definitons/calculator_steps.rb +1 -1
  10. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +1 -1
  11. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +1 -1
  12. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +1 -1
  13. data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +1 -1
  14. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +1 -1
  15. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +1 -1
  16. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +1 -1
  17. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +1 -1
  18. data/examples/i18n/ko/features/addition.feature +1 -1
  19. data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -1
  20. data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +1 -1
  21. data/examples/i18n/no/features/support/env.rb +1 -1
  22. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +1 -1
  23. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +1 -1
  24. data/examples/i18n/ru/features/support/env.rb +1 -1
  25. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +1 -1
  26. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +1 -1
  27. data/examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb +1 -1
  28. data/examples/tickets/features/246.feature +4 -0
  29. data/examples/tickets/features/step_definitons/246_steps.rb +3 -0
  30. data/features/cucumber_cli_outlines.feature +1 -1
  31. data/gem_tasks/rspec.rake +3 -2
  32. data/lib/cucumber/ast/outline_table.rb +1 -1
  33. data/lib/cucumber/ast/table.rb +21 -0
  34. data/lib/cucumber/formatter/ansicolor.rb +10 -2
  35. data/lib/cucumber/languages.yml +51 -3
  36. data/lib/cucumber/parser.rb +2 -7
  37. data/lib/cucumber/parser/feature.rb +34 -39
  38. data/lib/cucumber/parser/feature.tt +1 -1
  39. data/lib/cucumber/parser/i18n.tt +4 -0
  40. data/lib/cucumber/step_definition.rb +9 -12
  41. data/lib/cucumber/step_mother.rb +3 -2
  42. data/lib/cucumber/version.rb +1 -1
  43. data/rails_generators/cucumber/templates/env.rb +1 -1
  44. data/rails_generators/cucumber/templates/paths.rb +2 -1
  45. data/rails_generators/cucumber/templates/webrat_steps.rb +8 -0
  46. data/{spec → specs}/cucumber/ast/background_spec.rb +0 -0
  47. data/{spec → specs}/cucumber/ast/feature_factory.rb +0 -0
  48. data/{spec → specs}/cucumber/ast/feature_spec.rb +0 -0
  49. data/{spec → specs}/cucumber/ast/py_string_spec.rb +0 -0
  50. data/{spec → specs}/cucumber/ast/scenario_outline_spec.rb +0 -0
  51. data/{spec → specs}/cucumber/ast/scenario_spec.rb +0 -0
  52. data/{spec → specs}/cucumber/ast/step_collection_spec.rb +0 -0
  53. data/{spec → specs}/cucumber/ast/step_spec.rb +0 -0
  54. data/{spec → specs}/cucumber/ast/table_spec.rb +21 -0
  55. data/{spec → specs}/cucumber/ast/tags_spec.rb +0 -0
  56. data/{spec → specs}/cucumber/broadcaster_spec.rb +0 -0
  57. data/{spec → specs}/cucumber/cli/configuration_spec.rb +0 -0
  58. data/{spec → specs}/cucumber/cli/main_spec.rb +0 -0
  59. data/{spec → specs}/cucumber/core_ext/proc_spec.rb +1 -1
  60. data/{spec → specs}/cucumber/core_ext/string_spec.rb +0 -0
  61. data/{spec → specs}/cucumber/formatter/ansicolor_spec.rb +0 -0
  62. data/{spec → specs}/cucumber/formatter/color_io_spec.rb +0 -0
  63. data/{spec → specs}/cucumber/formatter/html/cucumber.css +0 -0
  64. data/{spec → specs}/cucumber/formatter/html/cucumber.js +0 -0
  65. data/{spec → specs}/cucumber/formatter/html/index.html +0 -0
  66. data/{spec → specs}/cucumber/formatter/html/jquery-1.3.min.js +0 -0
  67. data/{spec → specs}/cucumber/formatter/html/jquery.uitableedit.js +0 -0
  68. data/{spec → specs}/cucumber/formatters/profile_formatter_spec.rb +0 -0
  69. data/{spec → specs}/cucumber/parser/feature_parser_spec.rb +0 -0
  70. data/{spec → specs}/cucumber/parser/table_parser_spec.rb +0 -0
  71. data/{spec → specs}/cucumber/rails/stubs/mini_rails.rb +0 -0
  72. data/{spec → specs}/cucumber/rails/stubs/test_help.rb +0 -0
  73. data/{spec → specs}/cucumber/rails/world_spec.rb +0 -0
  74. data/{spec → specs}/cucumber/sell_cucumbers.feature +0 -0
  75. data/{spec → specs}/cucumber/step_definition_spec.rb +8 -0
  76. data/{spec → specs}/cucumber/step_mother_spec.rb +19 -3
  77. data/{spec → specs}/cucumber/treetop_parser/empty_feature.feature +0 -0
  78. data/{spec → specs}/cucumber/treetop_parser/empty_scenario.feature +0 -0
  79. data/{spec → specs}/cucumber/treetop_parser/empty_scenario_outline.feature +0 -0
  80. data/{spec → specs}/cucumber/treetop_parser/fit_scenario.feature +0 -0
  81. data/{spec → specs}/cucumber/treetop_parser/given_scenario.feature +0 -0
  82. data/{spec → specs}/cucumber/treetop_parser/invalid_scenario_outlines.feature +0 -0
  83. data/{spec → specs}/cucumber/treetop_parser/multiline_steps.feature +0 -0
  84. data/{spec → specs}/cucumber/treetop_parser/multiple_tables.feature +0 -0
  85. data/{spec → specs}/cucumber/treetop_parser/scenario_outline.feature +0 -0
  86. data/{spec → specs}/cucumber/treetop_parser/spaces.feature +0 -0
  87. data/{spec → specs}/cucumber/treetop_parser/test_dos.feature +0 -0
  88. data/{spec → specs}/cucumber/treetop_parser/with_comments.feature +0 -0
  89. data/{spec → specs}/cucumber/treetop_parser/with_tags.feature +0 -0
  90. data/{spec → specs}/cucumber/world/pending_spec.rb +0 -0
  91. data/{spec → specs}/spec.opts +0 -0
  92. data/{spec → specs}/spec_helper.rb +0 -0
  93. metadata +54 -52
@@ -60,6 +60,23 @@ module Cucumber
60
60
  row.to_hash
61
61
  end
62
62
  end
63
+
64
+ # Converts this table into a Hash where the first column is
65
+ # used as keys and the second column is used as values
66
+ #
67
+ # | a | 2 |
68
+ # | b | 3 |
69
+ #
70
+ # Gets converted into the following:
71
+ #
72
+ # {'a' => '2', 'b' => '3'}
73
+ #
74
+ # The table must be exactly two columns wide
75
+ #
76
+ def rows_hash
77
+ verify_table_width(2)
78
+ @rows_hash = self.transpose.hashes[0]
79
+ end
63
80
 
64
81
  # Gets the raw data of this table. For example, a Table built from
65
82
  # the following plain text:
@@ -160,6 +177,10 @@ module Cucumber
160
177
  def verify_column(column_name)
161
178
  raise %{The column named "#{column_name}" does not exist} unless @raw[0].include?(column_name)
162
179
  end
180
+
181
+ def verify_table_width(width)
182
+ raise %{The table must have exactly #{width} columns} unless @raw[0].size == width
183
+ end
163
184
 
164
185
  def arguments_replaced(arguments) #:nodoc:
165
186
  raw_with_replaced_args = raw.map do |row|
@@ -6,12 +6,20 @@ if Cucumber::WINDOWS_MRI
6
6
  gem 'win32console', '>= 1.2.0'
7
7
  require 'Win32/Console/ANSI'
8
8
  rescue LoadError
9
- STDERR.puts "*** WARNING: You must gem install win32console (1.2.0 or higher) to get coloured output on MRI/Windows"
9
+ STDERR.puts %{*** WARNING: You must "gem install win32console" (1.2.0 or higher) to get coloured output on MRI/Windows}
10
+ Term::ANSIColor.coloring = false
11
+ end
12
+ elsif Cucumber::WINDOWS && Cucumber::JRUBY
13
+ begin
14
+ gem 'aslakhellesoy-ansicolor', '>= 1.0'
15
+ require 'ansicolor'
16
+ rescue LoadError
17
+ STDERR.puts %{*** WARNING: You must "gem install aslakhellesoy-ansicolor --source http://gems.github.com" (1.0 or higher) to get coloured output on JRuby/Windows}
10
18
  Term::ANSIColor.coloring = false
11
19
  end
12
20
  end
13
21
 
14
- Term::ANSIColor.coloring = false if !STDOUT.tty? || (Cucumber::WINDOWS && !Cucumber::WINDOWS_MRI)
22
+ Term::ANSIColor.coloring = false if !STDOUT.tty?
15
23
 
16
24
  module Cucumber
17
25
  module Formatter
@@ -20,6 +20,7 @@
20
20
  then: Then
21
21
  and: And
22
22
  but: But
23
+ space_after_keyword: true
23
24
 
24
25
  # Please help us keeping the languages below uptodate. The parsers for a language
25
26
  # that is missing a keyword will expect the English word until the missing word(s)
@@ -41,6 +42,7 @@
41
42
  then: اذاً|ثم
42
43
  and: و
43
44
  but: لكن
45
+ space_after_keyword: true
44
46
  "cy":
45
47
  name: Welsh
46
48
  native: Cymraeg
@@ -53,6 +55,7 @@
53
55
  then: Yna
54
56
  and: A
55
57
  but: Ond
58
+ space_after_keyword: true
56
59
  "cz":
57
60
  name: Czech
58
61
  native: Česky
@@ -67,6 +70,7 @@
67
70
  then: Pak
68
71
  and: A
69
72
  but: Ale
73
+ space_after_keyword: true
70
74
  "da":
71
75
  name: Danish
72
76
  native: dansk
@@ -81,6 +85,7 @@
81
85
  then: Så
82
86
  and: Og
83
87
  but: Men
88
+ space_after_keyword: true
84
89
  "de":
85
90
  name: German
86
91
  native: Deutsch
@@ -95,6 +100,7 @@
95
100
  then: Dann
96
101
  and: Und
97
102
  but: Aber
103
+ space_after_keyword: true
98
104
  "en-au":
99
105
  name: Australian
100
106
  native: Australian
@@ -109,6 +115,7 @@
109
115
  then: Ya gotta
110
116
  and: N
111
117
  but: Cept
118
+ space_after_keyword: true
112
119
  "en-lol":
113
120
  name: LOLCAT
114
121
  native: LOLCAT
@@ -123,6 +130,7 @@
123
130
  then: DEN
124
131
  and: AN
125
132
  but: BUT
133
+ space_after_keyword: true
126
134
  "en-tx":
127
135
  name: Texan
128
136
  native: Texan
@@ -137,6 +145,7 @@
137
145
  then: Then y'all
138
146
  and: And y'all
139
147
  but: But y'all
148
+ space_after_keyword: true
140
149
  "es":
141
150
  name: Spanish
142
151
  native: español
@@ -151,6 +160,7 @@
151
160
  then: Entonces
152
161
  and: Y
153
162
  but: Pero
163
+ space_after_keyword: true
154
164
  "et":
155
165
  name: Estonian
156
166
  native: eesti keel
@@ -165,6 +175,7 @@
165
175
  then: Siis
166
176
  and: Ja
167
177
  but: Kuid
178
+ space_after_keyword: true
168
179
  "fi":
169
180
  name: Finnish
170
181
  native: suomi
@@ -179,6 +190,7 @@
179
190
  then: Niin
180
191
  and: Ja
181
192
  but: Mutta
193
+ space_after_keyword: true
182
194
  "fr":
183
195
  name: French
184
196
  native: français
@@ -193,11 +205,13 @@
193
205
  then: Alors
194
206
  and: Et
195
207
  but: Mais
208
+ space_after_keyword: true
196
209
  "id":
197
210
  name: Indonesian
198
211
  native: Bahasa Indonesia
199
212
  encoding: UTF-8
200
213
  feature: Fitur
214
+ background: Dasar
201
215
  scenario: Skenario
202
216
  scenario_outline: Skenario konsep
203
217
  examples: Contoh
@@ -206,18 +220,22 @@
206
220
  then: Maka
207
221
  and: Dan
208
222
  but: Tapi
223
+ space_after_keyword: true
209
224
  "it":
210
225
  name: Italian
211
226
  native: italiano
212
227
  encoding: UTF-8
213
228
  feature: Funzionalità
229
+ background: Contesto
214
230
  scenario: Scenario
215
- more_examples: Più esempi
231
+ scenario_outline: Schema dello scenario
232
+ examples: Esempi
216
233
  given: Dato
217
234
  when: Quando
218
235
  then: Allora
219
236
  and: E
220
237
  but: Ma
238
+ space_after_keyword: true
221
239
  "ja":
222
240
  name: Japanese
223
241
  native: 日本語
@@ -225,13 +243,14 @@
225
243
  feature: フィーチャ
226
244
  background: 背景
227
245
  scenario: シナリオ
228
- scenario_outline: シナリオテンプレート|テンプレ|シナリオテンプレ
246
+ scenario_outline: シナリオアウトライン|シナリオテンプレート|テンプレ|シナリオテンプレ
229
247
  examples: 例|サンプル
230
248
  given: 前提
231
249
  when: もし
232
250
  then: ならば
233
251
  and: かつ
234
252
  but: しかし
253
+ space_after_keyword: false
235
254
  "lt":
236
255
  name: Lithuanian
237
256
  native: lietuvių kalba
@@ -244,17 +263,22 @@
244
263
  then: Tada
245
264
  and: Ir
246
265
  but: Bet
266
+ space_after_keyword: true
247
267
  "nl":
248
268
  name: Dutch
249
269
  native: Nederlands
250
270
  encoding: UTF-8
251
271
  feature: Functionaliteit
272
+ background: Achtergrond
252
273
  scenario: Scenario
274
+ scenario_outline: Abstract Scenario
275
+ examples: Voorbeelden
253
276
  given: Gegeven
254
277
  when: Als
255
278
  then: Dan
256
279
  and: En
257
280
  but: Maar
281
+ space_after_keyword: true
258
282
  "no":
259
283
  name: Norwegian
260
284
  native: norsk
@@ -269,6 +293,7 @@
269
293
  then: Så
270
294
  and: Og
271
295
  but: Men
296
+ space_after_keyword: true
272
297
  "pl":
273
298
  name: Polish
274
299
  native: polski
@@ -280,6 +305,7 @@
280
305
  then: Wtedy
281
306
  and: Oraz
282
307
  but: Ale
308
+ space_after_keyword: true
283
309
  "pt":
284
310
  name: Portuguese
285
311
  native: português
@@ -294,6 +320,7 @@
294
320
  then: Então
295
321
  and: E
296
322
  but: Mas
323
+ space_after_keyword: true
297
324
  "ro":
298
325
  name: Romanian
299
326
  native: română
@@ -305,6 +332,7 @@
305
332
  then: Atunci
306
333
  and: Si
307
334
  but: Dar
335
+ space_after_keyword: true
308
336
  "ro2":
309
337
  name: Romanian (diacritical)
310
338
  native: română (diacritical)
@@ -316,6 +344,7 @@
316
344
  then: Atunci
317
345
  and: Și
318
346
  but: Dar
347
+ space_after_keyword: true
319
348
  "ru":
320
349
  name: Russian
321
350
  native: русский
@@ -330,6 +359,7 @@
330
359
  then: То
331
360
  and: И|К тому же
332
361
  but: Но|А
362
+ space_after_keyword: true
333
363
  "se":
334
364
  name: Swedish
335
365
  native: Svenska
@@ -344,6 +374,22 @@
344
374
  then: Så
345
375
  and: Och
346
376
  but: Men
377
+ space_after_keyword: true
378
+ "sk":
379
+ name: Slovak
380
+ native: Slovensky
381
+ encoding: UTF-8
382
+ feature: Požiadavka
383
+ background: Pozadie
384
+ scenario: Scenár
385
+ scenario_outline: Náčrt Scenáru
386
+ examples: Príklady
387
+ given: Pokiaľ
388
+ when: Keď
389
+ then: Tak
390
+ and: A
391
+ but: Ale
392
+ space_after_keyword: true
347
393
  "zh-CN":
348
394
  name: Chinese simplified
349
395
  native: 简体中文
@@ -358,6 +404,7 @@
358
404
  then: 那么
359
405
  and: 而且
360
406
  but: 但是
407
+ space_after_keyword: false
361
408
  "zh-TW":
362
409
  name: Chinese traditional
363
410
  native: 繁體中文
@@ -372,6 +419,7 @@
372
419
  then: 那麼
373
420
  and: 而且|並且
374
421
  but: 但是
422
+ space_after_keyword: false
375
423
  "ko":
376
424
  name: Korean
377
425
  native: 한국어
@@ -381,9 +429,9 @@
381
429
  scenario: 시나리오
382
430
  scenario_outline: 시나리오 개요
383
431
  examples: 예
384
- more_examples: 다른 예
385
432
  given: 조건
386
433
  when: 만일
387
434
  then: 그러면
388
435
  and: 그리고
389
436
  but: 하지만
437
+ space_after_keyword: false
@@ -13,12 +13,6 @@ module Cucumber
13
13
  #
14
14
  # The AST classes are defined in the Cucumber::Ast module.
15
15
  module Parser
16
- translator = Module.new do
17
- def keywordz(key)
18
- 'Scenario'
19
- end
20
- end
21
-
22
16
  def self.load_parser(keywords)
23
17
  Loader.new(keywords)
24
18
  end
@@ -34,7 +28,8 @@ module Cucumber
34
28
  require 'cucumber/parser/feature'
35
29
  end
36
30
 
37
- def keywords(key)
31
+ def keywords(key, raw=false)
32
+ return @keywords[key] if raw
38
33
  values = @keywords[key].split('|')
39
34
  values.map{|value| "'#{value}'"}.join(" / ")
40
35
  end
@@ -870,6 +870,10 @@ module Cucumber
870
870
  elements[2]
871
871
  end
872
872
 
873
+ def keyword_space
874
+ elements[3]
875
+ end
876
+
873
877
  def name
874
878
  elements[4]
875
879
  end
@@ -920,60 +924,51 @@ module Cucumber
920
924
  r4 = _nt_step_keyword
921
925
  s0 << r4
922
926
  if r4
923
- s5, i5 = [], index
924
- loop do
925
- r6 = _nt_space
926
- if r6
927
- s5 << r6
928
- else
929
- break
930
- end
931
- end
932
- r5 = SyntaxNode.new(input, i5...index, s5)
927
+ r5 = _nt_keyword_space
933
928
  s0 << r5
934
929
  if r5
935
- r7 = _nt_line_to_eol
936
- s0 << r7
937
- if r7
938
- i8 = index
939
- s9, i9 = [], index
930
+ r6 = _nt_line_to_eol
931
+ s0 << r6
932
+ if r6
933
+ i7 = index
934
+ s8, i8 = [], index
940
935
  loop do
941
- r10 = _nt_eol
942
- if r10
943
- s9 << r10
936
+ r9 = _nt_eol
937
+ if r9
938
+ s8 << r9
944
939
  else
945
940
  break
946
941
  end
947
942
  end
948
- if s9.empty?
949
- self.index = i9
950
- r9 = nil
943
+ if s8.empty?
944
+ self.index = i8
945
+ r8 = nil
951
946
  else
952
- r9 = SyntaxNode.new(input, i9...index, s9)
947
+ r8 = SyntaxNode.new(input, i8...index, s8)
953
948
  end
954
- if r9
955
- r8 = r9
949
+ if r8
950
+ r7 = r8
956
951
  else
957
- r11 = _nt_eof
958
- if r11
959
- r8 = r11
952
+ r10 = _nt_eof
953
+ if r10
954
+ r7 = r10
960
955
  else
961
- self.index = i8
962
- r8 = nil
956
+ self.index = i7
957
+ r7 = nil
963
958
  end
964
959
  end
965
- s0 << r8
966
- if r8
967
- r13 = _nt_multiline_arg
968
- if r13
969
- r12 = r13
960
+ s0 << r7
961
+ if r7
962
+ r12 = _nt_multiline_arg
963
+ if r12
964
+ r11 = r12
970
965
  else
971
- r12 = SyntaxNode.new(input, index...index)
966
+ r11 = SyntaxNode.new(input, index...index)
972
967
  end
973
- s0 << r12
974
- if r12
975
- r14 = _nt_white
976
- s0 << r14
968
+ s0 << r11
969
+ if r11
970
+ r13 = _nt_white
971
+ s0 << r13
977
972
  end
978
973
  end
979
974
  end
@@ -121,7 +121,7 @@ module Cucumber
121
121
  end
122
122
 
123
123
  rule step
124
- comment space* step_keyword space* name:line_to_eol (eol+ / eof) multi:multiline_arg? white {
124
+ comment space* step_keyword keyword_space name:line_to_eol (eol+ / eof) multi:multiline_arg? white {
125
125
  def build
126
126
  if multi.respond_to?(:build)
127
127
  Ast::Step.new(step_keyword.line, step_keyword.text_value, name.text_value.strip, multi.build)