gherkin 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/.gitattributes +1 -0
  2. data/History.txt +18 -0
  3. data/README.rdoc +4 -1
  4. data/Rakefile +4 -2
  5. data/VERSION.yml +1 -1
  6. data/bin/gherkin +1 -1
  7. data/dotnet/.gitignore +13 -0
  8. data/features/feature_parser.feature +22 -2
  9. data/features/native_lexer.feature +1 -1
  10. data/features/parser_with_native_lexer.feature +1 -1
  11. data/features/step_definitions/gherkin_steps.rb +2 -6
  12. data/features/step_definitions/pretty_printer_steps.rb +2 -3
  13. data/features/steps_parser.feature +1 -1
  14. data/gherkin.gemspec +53 -24
  15. data/java/Gherkin.iml +2 -4
  16. data/java/build.xml +3 -0
  17. data/java/src/gherkin/FixJava.java +6 -3
  18. data/java/src/gherkin/I18nLexer.java +48 -0
  19. data/java/src/gherkin/Listener.java +3 -1
  20. data/java/src/gherkin/Main.java +17 -0
  21. data/java/src/gherkin/Parser.java +9 -3
  22. data/java/src/gherkin/formatter/Argument.java +39 -0
  23. data/java/src/gherkin/formatter/ArgumentFormat.java +17 -0
  24. data/java/src/gherkin/formatter/Colors.java +7 -0
  25. data/java/src/gherkin/formatter/Formatter.java +15 -0
  26. data/java/src/gherkin/formatter/PrettyFormatter.java +219 -0
  27. data/java/src/gherkin/parser/StateMachineReader.java +8 -3
  28. data/java/test/gherkin/formatter/ArgumentTest.java +17 -0
  29. data/lib/gherkin/csharp_lexer.rb +15 -0
  30. data/lib/gherkin/format/argument.rb +35 -0
  31. data/lib/gherkin/format/monochrome_format.rb +9 -0
  32. data/lib/gherkin/i18n.rb +22 -0
  33. data/lib/gherkin/i18n.yml +34 -20
  34. data/lib/gherkin/i18n_lexer.rb +57 -13
  35. data/lib/gherkin/lexer.rb +9 -18
  36. data/lib/gherkin/parser.rb +3 -3
  37. data/lib/gherkin/parser/meta.txt +5 -4
  38. data/lib/gherkin/parser/root.txt +11 -9
  39. data/lib/gherkin/parser/steps.txt +4 -3
  40. data/lib/gherkin/rb_parser.rb +13 -5
  41. data/lib/gherkin/tools/colors.rb +119 -0
  42. data/lib/gherkin/tools/files.rb +6 -1
  43. data/lib/gherkin/tools/pretty_listener.rb +115 -23
  44. data/ragel/lexer.c.rl.erb +67 -51
  45. data/ragel/lexer.csharp.rl.erb +240 -0
  46. data/ragel/lexer.java.rl.erb +27 -18
  47. data/ragel/lexer.rb.rl.erb +17 -17
  48. data/ragel/lexer_common.rl.erb +8 -8
  49. data/spec/gherkin/c_lexer_spec.rb +4 -4
  50. data/spec/gherkin/csharp_lexer_spec.rb +20 -0
  51. data/spec/gherkin/fixtures/comments_in_table.feature +9 -0
  52. data/spec/gherkin/fixtures/complex.feature +2 -0
  53. data/spec/gherkin/fixtures/dos_line_endings.feature +45 -0
  54. data/spec/gherkin/fixtures/i18n_fr.feature +1 -0
  55. data/spec/gherkin/fixtures/i18n_no.feature +1 -0
  56. data/spec/gherkin/fixtures/i18n_zh-CN.feature +1 -0
  57. data/spec/gherkin/format/argument_spec.rb +28 -0
  58. data/spec/gherkin/i18n_lexer_spec.rb +4 -4
  59. data/spec/gherkin/i18n_spec.rb +31 -23
  60. data/spec/gherkin/java_lexer_spec.rb +4 -3
  61. data/spec/gherkin/parser_spec.rb +5 -0
  62. data/spec/gherkin/rb_lexer_spec.rb +4 -2
  63. data/spec/gherkin/sexp_recorder.rb +1 -1
  64. data/spec/gherkin/shared/lexer_spec.rb +169 -60
  65. data/spec/gherkin/shared/py_string_spec.rb +6 -0
  66. data/spec/gherkin/shared/row_spec.rb +107 -0
  67. data/spec/gherkin/shared/tags_spec.rb +1 -1
  68. data/spec/gherkin/tools/colors_spec.rb +19 -0
  69. data/spec/gherkin/tools/pretty_listener_spec.rb +147 -0
  70. data/spec/spec_helper.rb +31 -7
  71. data/tasks/compile.rake +81 -7
  72. data/tasks/ragel_task.rb +6 -4
  73. data/tasks/rspec.rake +2 -2
  74. metadata +104 -41
  75. data/lib/gherkin/java_lexer.rb +0 -10
  76. data/spec/gherkin/shared/table_spec.rb +0 -97
@@ -29,7 +29,8 @@ class RagelTask
29
29
  {
30
30
  'c' => "ext/gherkin_lexer_#{@i18n.sanitized_key}/gherkin_lexer_#{@i18n.sanitized_key}.c",
31
31
  'java' => "java/src/gherkin/lexer/#{@i18n.sanitized_key.capitalize}.java",
32
- 'rb' => "lib/gherkin/rb_lexer/#{@i18n.sanitized_key}.rb"
32
+ 'rb' => "lib/gherkin/rb_lexer/#{@i18n.sanitized_key}.rb",
33
+ 'csharp' => "tmp/#{@i18n.sanitized_key}.cs"
33
34
  }[@lang]
34
35
  end
35
36
 
@@ -51,9 +52,10 @@ class RagelTask
51
52
 
52
53
  def flags
53
54
  {
54
- 'c' => '-C',
55
- 'java' => '-J',
56
- 'rb' => '-R'
55
+ 'c' => '-C',
56
+ 'java' => '-J',
57
+ 'rb' => '-R',
58
+ 'csharp' => '-A -L -T0'
57
59
  }[@lang]
58
60
  end
59
61
 
@@ -2,13 +2,13 @@ require 'spec/rake/spectask'
2
2
 
3
3
  Spec::Rake::SpecTask.new(:spec) do |spec|
4
4
  spec.libs << 'lib' << 'spec'
5
- spec.spec_opts << '--color'
5
+ spec.spec_opts << '--color --diff'
6
6
  end
7
7
  task :spec => [:check_dependencies]
8
8
 
9
9
  Spec::Rake::SpecTask.new(:rcov) do |spec|
10
10
  spec.libs << 'lib' << 'spec'
11
- spec.spec_opts << '--color'
11
+ spec.spec_opts << '--color --diff'
12
12
  spec.pattern = 'spec/**/*_spec.rb'
13
13
  spec.rcov = true
14
14
  spec.rcov_opts = %w{--exclude spec\/}
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gherkin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 3
9
+ version: 1.0.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - Mike Sassak
@@ -11,49 +16,78 @@ autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
18
 
14
- date: 2009-12-30 00:00:00 +01:00
19
+ date: 2010-03-30 00:00:00 +02:00
15
20
  default_executable: gherkin
16
21
  dependencies:
17
22
  - !ruby/object:Gem::Dependency
18
23
  name: trollop
19
- type: :runtime
20
- version_requirement:
21
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
22
26
  requirements:
23
27
  - - ">="
24
28
  - !ruby/object:Gem::Version
29
+ segments:
30
+ - 1
31
+ - 15
25
32
  version: "1.15"
26
- version:
33
+ type: :runtime
34
+ version_requirements: *id001
27
35
  - !ruby/object:Gem::Dependency
28
36
  name: rspec
29
- type: :development
30
- version_requirement:
31
- version_requirements: !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
32
39
  requirements:
33
40
  - - ">="
34
41
  - !ruby/object:Gem::Version
35
- version: 1.2.9
36
- version:
42
+ segments:
43
+ - 1
44
+ - 3
45
+ - 0
46
+ version: 1.3.0
47
+ type: :development
48
+ version_requirements: *id002
37
49
  - !ruby/object:Gem::Dependency
38
50
  name: cucumber
39
- type: :development
40
- version_requirement:
41
- version_requirements: !ruby/object:Gem::Requirement
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
42
53
  requirements:
43
54
  - - ">="
44
55
  - !ruby/object:Gem::Version
45
- version: 0.5.1
46
- version:
56
+ segments:
57
+ - 0
58
+ - 6
59
+ - 2
60
+ version: 0.6.2
61
+ type: :development
62
+ version_requirements: *id003
47
63
  - !ruby/object:Gem::Dependency
48
64
  name: rake-compiler
49
- type: :development
50
- version_requirement:
51
- version_requirements: !ruby/object:Gem::Requirement
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
52
67
  requirements:
53
68
  - - ">="
54
69
  - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
72
+ - 7
73
+ - 0
55
74
  version: 0.7.0
56
- version:
75
+ type: :development
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: albacore
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ - 1
87
+ - 0
88
+ version: 0.1.0
89
+ type: :development
90
+ version_requirements: *id005
57
91
  description: A fast Gherkin lexer/parser based on the Ragel State Machine Compiler.
58
92
  email: cukes@googlegroups.com
59
93
  executables:
@@ -61,14 +95,15 @@ executables:
61
95
  extensions:
62
96
  - ext/gherkin_lexer_ar/extconf.rb
63
97
  - ext/gherkin_lexer_bg/extconf.rb
64
- - ext/gherkin_lexer_cat/extconf.rb
98
+ - ext/gherkin_lexer_ca/extconf.rb
65
99
  - ext/gherkin_lexer_cs/extconf.rb
66
- - ext/gherkin_lexer_cy/extconf.rb
100
+ - ext/gherkin_lexer_cyGB/extconf.rb
67
101
  - ext/gherkin_lexer_da/extconf.rb
68
102
  - ext/gherkin_lexer_de/extconf.rb
69
103
  - ext/gherkin_lexer_en/extconf.rb
70
104
  - ext/gherkin_lexer_enau/extconf.rb
71
105
  - ext/gherkin_lexer_enlol/extconf.rb
106
+ - ext/gherkin_lexer_enScouse/extconf.rb
72
107
  - ext/gherkin_lexer_entx/extconf.rb
73
108
  - ext/gherkin_lexer_es/extconf.rb
74
109
  - ext/gherkin_lexer_et/extconf.rb
@@ -88,12 +123,12 @@ extensions:
88
123
  - ext/gherkin_lexer_pl/extconf.rb
89
124
  - ext/gherkin_lexer_pt/extconf.rb
90
125
  - ext/gherkin_lexer_ro/extconf.rb
91
- - ext/gherkin_lexer_ro2/extconf.rb
126
+ - ext/gherkin_lexer_roRO/extconf.rb
92
127
  - ext/gherkin_lexer_ru/extconf.rb
93
- - ext/gherkin_lexer_se/extconf.rb
94
128
  - ext/gherkin_lexer_sk/extconf.rb
95
- - ext/gherkin_lexer_sr/extconf.rb
129
+ - ext/gherkin_lexer_srCyrl/extconf.rb
96
130
  - ext/gherkin_lexer_srLatn/extconf.rb
131
+ - ext/gherkin_lexer_sv/extconf.rb
97
132
  - ext/gherkin_lexer_tr/extconf.rb
98
133
  - ext/gherkin_lexer_uz/extconf.rb
99
134
  - ext/gherkin_lexer_vi/extconf.rb
@@ -103,6 +138,7 @@ extra_rdoc_files:
103
138
  - LICENSE
104
139
  - README.rdoc
105
140
  files:
141
+ - .gitattributes
106
142
  - .gitignore
107
143
  - .mailmap
108
144
  - History.txt
@@ -112,14 +148,16 @@ files:
112
148
  - VERSION.yml
113
149
  - bin/gherkin
114
150
  - cucumber.yml
151
+ - dotnet/.gitignore
115
152
  - ext/gherkin_lexer_ar/gherkin_lexer_ar.c
116
153
  - ext/gherkin_lexer_bg/gherkin_lexer_bg.c
117
- - ext/gherkin_lexer_cat/gherkin_lexer_cat.c
154
+ - ext/gherkin_lexer_ca/gherkin_lexer_ca.c
118
155
  - ext/gherkin_lexer_cs/gherkin_lexer_cs.c
119
- - ext/gherkin_lexer_cy/gherkin_lexer_cy.c
156
+ - ext/gherkin_lexer_cyGB/gherkin_lexer_cyGB.c
120
157
  - ext/gherkin_lexer_da/gherkin_lexer_da.c
121
158
  - ext/gherkin_lexer_de/gherkin_lexer_de.c
122
159
  - ext/gherkin_lexer_en/gherkin_lexer_en.c
160
+ - ext/gherkin_lexer_enScouse/gherkin_lexer_enScouse.c
123
161
  - ext/gherkin_lexer_enau/gherkin_lexer_enau.c
124
162
  - ext/gherkin_lexer_enlol/gherkin_lexer_enlol.c
125
163
  - ext/gherkin_lexer_entx/gherkin_lexer_entx.c
@@ -141,12 +179,12 @@ files:
141
179
  - ext/gherkin_lexer_pl/gherkin_lexer_pl.c
142
180
  - ext/gherkin_lexer_pt/gherkin_lexer_pt.c
143
181
  - ext/gherkin_lexer_ro/gherkin_lexer_ro.c
144
- - ext/gherkin_lexer_ro2/gherkin_lexer_ro2.c
182
+ - ext/gherkin_lexer_roRO/gherkin_lexer_roRO.c
145
183
  - ext/gherkin_lexer_ru/gherkin_lexer_ru.c
146
- - ext/gherkin_lexer_se/gherkin_lexer_se.c
147
184
  - ext/gherkin_lexer_sk/gherkin_lexer_sk.c
148
- - ext/gherkin_lexer_sr/gherkin_lexer_sr.c
185
+ - ext/gherkin_lexer_srCyrl/gherkin_lexer_srCyrl.c
149
186
  - ext/gherkin_lexer_srLatn/gherkin_lexer_srLatn.c
187
+ - ext/gherkin_lexer_sv/gherkin_lexer_sv.c
150
188
  - ext/gherkin_lexer_tr/gherkin_lexer_tr.c
151
189
  - ext/gherkin_lexer_uz/gherkin_lexer_uz.c
152
190
  - ext/gherkin_lexer_vi/gherkin_lexer_vi.c
@@ -165,22 +203,32 @@ files:
165
203
  - java/Gherkin.iml
166
204
  - java/build.xml
167
205
  - java/src/gherkin/FixJava.java
206
+ - java/src/gherkin/I18nLexer.java
168
207
  - java/src/gherkin/Lexer.java
169
208
  - java/src/gherkin/LexingError.java
170
209
  - java/src/gherkin/Listener.java
210
+ - java/src/gherkin/Main.java
171
211
  - java/src/gherkin/ParseError.java
172
212
  - java/src/gherkin/Parser.java
213
+ - java/src/gherkin/formatter/Argument.java
214
+ - java/src/gherkin/formatter/ArgumentFormat.java
215
+ - java/src/gherkin/formatter/Colors.java
216
+ - java/src/gherkin/formatter/Formatter.java
217
+ - java/src/gherkin/formatter/PrettyFormatter.java
173
218
  - java/src/gherkin/lexer/.gitignore
174
219
  - java/src/gherkin/parser/StateMachineReader.java
220
+ - java/test/gherkin/formatter/ArgumentTest.java
175
221
  - lib/.gitignore
176
222
  - lib/gherkin.rb
177
223
  - lib/gherkin/c_lexer.rb
178
224
  - lib/gherkin/cli/main.rb
179
225
  - lib/gherkin/core_ext/array.rb
226
+ - lib/gherkin/csharp_lexer.rb
227
+ - lib/gherkin/format/argument.rb
228
+ - lib/gherkin/format/monochrome_format.rb
180
229
  - lib/gherkin/i18n.rb
181
230
  - lib/gherkin/i18n.yml
182
231
  - lib/gherkin/i18n_lexer.rb
183
- - lib/gherkin/java_lexer.rb
184
232
  - lib/gherkin/lexer.rb
185
233
  - lib/gherkin/parser.rb
186
234
  - lib/gherkin/parser/meta.txt
@@ -191,12 +239,13 @@ files:
191
239
  - lib/gherkin/rb_lexer/README.rdoc
192
240
  - lib/gherkin/rb_lexer/ar.rb
193
241
  - lib/gherkin/rb_lexer/bg.rb
194
- - lib/gherkin/rb_lexer/cat.rb
242
+ - lib/gherkin/rb_lexer/ca.rb
195
243
  - lib/gherkin/rb_lexer/cs.rb
196
- - lib/gherkin/rb_lexer/cy.rb
244
+ - lib/gherkin/rb_lexer/cyGB.rb
197
245
  - lib/gherkin/rb_lexer/da.rb
198
246
  - lib/gherkin/rb_lexer/de.rb
199
247
  - lib/gherkin/rb_lexer/en.rb
248
+ - lib/gherkin/rb_lexer/enScouse.rb
200
249
  - lib/gherkin/rb_lexer/enau.rb
201
250
  - lib/gherkin/rb_lexer/enlol.rb
202
251
  - lib/gherkin/rb_lexer/entx.rb
@@ -218,12 +267,12 @@ files:
218
267
  - lib/gherkin/rb_lexer/pl.rb
219
268
  - lib/gherkin/rb_lexer/pt.rb
220
269
  - lib/gherkin/rb_lexer/ro.rb
221
- - lib/gherkin/rb_lexer/ro2.rb
270
+ - lib/gherkin/rb_lexer/roRO.rb
222
271
  - lib/gherkin/rb_lexer/ru.rb
223
- - lib/gherkin/rb_lexer/se.rb
224
272
  - lib/gherkin/rb_lexer/sk.rb
225
- - lib/gherkin/rb_lexer/sr.rb
273
+ - lib/gherkin/rb_lexer/srCyrl.rb
226
274
  - lib/gherkin/rb_lexer/srLatn.rb
275
+ - lib/gherkin/rb_lexer/sv.rb
227
276
  - lib/gherkin/rb_lexer/tr.rb
228
277
  - lib/gherkin/rb_lexer/uz.rb
229
278
  - lib/gherkin/rb_lexer/vi.rb
@@ -231,6 +280,7 @@ files:
231
280
  - lib/gherkin/rb_lexer/zhTW.rb
232
281
  - lib/gherkin/rb_parser.rb
233
282
  - lib/gherkin/tools.rb
283
+ - lib/gherkin/tools/colors.rb
234
284
  - lib/gherkin/tools/files.rb
235
285
  - lib/gherkin/tools/pretty_listener.rb
236
286
  - lib/gherkin/tools/reformat.rb
@@ -239,18 +289,23 @@ files:
239
289
  - nativegems.sh
240
290
  - ragel/i18n/.gitignore
241
291
  - ragel/lexer.c.rl.erb
292
+ - ragel/lexer.csharp.rl.erb
242
293
  - ragel/lexer.java.rl.erb
243
294
  - ragel/lexer.rb.rl.erb
244
295
  - ragel/lexer_common.rl.erb
245
296
  - spec/gherkin/c_lexer_spec.rb
297
+ - spec/gherkin/csharp_lexer_spec.rb
246
298
  - spec/gherkin/fixtures/1.feature
299
+ - spec/gherkin/fixtures/comments_in_table.feature
247
300
  - spec/gherkin/fixtures/complex.feature
301
+ - spec/gherkin/fixtures/dos_line_endings.feature
248
302
  - spec/gherkin/fixtures/i18n_fr.feature
249
303
  - spec/gherkin/fixtures/i18n_no.feature
250
304
  - spec/gherkin/fixtures/i18n_zh-CN.feature
251
305
  - spec/gherkin/fixtures/simple.feature
252
306
  - spec/gherkin/fixtures/simple_with_comments.feature
253
307
  - spec/gherkin/fixtures/simple_with_tags.feature
308
+ - spec/gherkin/format/argument_spec.rb
254
309
  - spec/gherkin/i18n_lexer_spec.rb
255
310
  - spec/gherkin/i18n_spec.rb
256
311
  - spec/gherkin/java_lexer_spec.rb
@@ -259,8 +314,10 @@ files:
259
314
  - spec/gherkin/sexp_recorder.rb
260
315
  - spec/gherkin/shared/lexer_spec.rb
261
316
  - spec/gherkin/shared/py_string_spec.rb
262
- - spec/gherkin/shared/table_spec.rb
317
+ - spec/gherkin/shared/row_spec.rb
263
318
  - spec/gherkin/shared/tags_spec.rb
319
+ - spec/gherkin/tools/colors_spec.rb
320
+ - spec/gherkin/tools/pretty_listener_spec.rb
264
321
  - spec/spec_helper.rb
265
322
  - tasks/bench.rake
266
323
  - tasks/bench/feature_builder.rb
@@ -284,23 +341,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
284
341
  requirements:
285
342
  - - ">="
286
343
  - !ruby/object:Gem::Version
344
+ segments:
345
+ - 0
287
346
  version: "0"
288
- version:
289
347
  required_rubygems_version: !ruby/object:Gem::Requirement
290
348
  requirements:
291
349
  - - ">="
292
350
  - !ruby/object:Gem::Version
351
+ segments:
352
+ - 0
293
353
  version: "0"
294
- version:
295
354
  requirements: []
296
355
 
297
356
  rubyforge_project:
298
- rubygems_version: 1.3.5
357
+ rubygems_version: 1.3.6
299
358
  signing_key:
300
359
  specification_version: 3
301
360
  summary: Fast Gherkin lexer/parser
302
361
  test_files:
303
362
  - spec/gherkin/c_lexer_spec.rb
363
+ - spec/gherkin/csharp_lexer_spec.rb
364
+ - spec/gherkin/format/argument_spec.rb
304
365
  - spec/gherkin/i18n_lexer_spec.rb
305
366
  - spec/gherkin/i18n_spec.rb
306
367
  - spec/gherkin/java_lexer_spec.rb
@@ -309,6 +370,8 @@ test_files:
309
370
  - spec/gherkin/sexp_recorder.rb
310
371
  - spec/gherkin/shared/lexer_spec.rb
311
372
  - spec/gherkin/shared/py_string_spec.rb
312
- - spec/gherkin/shared/table_spec.rb
373
+ - spec/gherkin/shared/row_spec.rb
313
374
  - spec/gherkin/shared/tags_spec.rb
375
+ - spec/gherkin/tools/colors_spec.rb
376
+ - spec/gherkin/tools/pretty_listener_spec.rb
314
377
  - spec/spec_helper.rb
@@ -1,10 +0,0 @@
1
- require 'gherkin.jar'
2
-
3
- module Gherkin
4
- module JavaLexer
5
- def self.[](i18n_language)
6
- i18n_lexer_class_name = i18n_language.gsub(/[\s-]/, '').capitalize
7
- Java::GherkinLexer.__send__(i18n_lexer_class_name)
8
- end
9
- end
10
- end
@@ -1,97 +0,0 @@
1
- #encoding: utf-8
2
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
3
-
4
- module Gherkin
5
- module Lexer
6
- shared_examples_for "a Gherkin lexer lexing tables" do
7
- tables = {
8
- "|a|b|\n" => [%w{a b}],
9
- "|a|b|c|\n" => [%w{a b c}],
10
- "|c|d|\n|e|f|\n" => [%w{c d}, %w{e f}]
11
- }
12
-
13
- tables.each do |text, expected|
14
- it "should parse #{text}" do
15
- @listener.should_receive(:table).with(t(expected), 1)
16
- @lexer.scan(text.dup)
17
- end
18
- end
19
-
20
- it "should parse a table with many columns" do
21
- @listener.should_receive(:table).with(t([%w{a b c d e f g h i j k l m n o p}]), 1)
22
- @lexer.scan("|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|\n")
23
- end
24
-
25
- it "should parse a multicharacter cell content" do
26
- @listener.should_receive(:table).with(t([%w{foo bar}]), 1)
27
- @lexer.scan("| foo | bar |\n")
28
- end
29
-
30
- it "should parse cells with spaces within the content" do
31
- @listener.should_receive(:table).with(t([["Dill pickle", "Valencia orange"], ["Ruby red grapefruit", "Tire iron"]]), 1)
32
- @lexer.scan("| Dill pickle | Valencia orange |\n| Ruby red grapefruit | Tire iron |\n")
33
- end
34
-
35
- it "should allow utf-8" do
36
- # Fails in 1.9.1!
37
- # 'Gherkin::Lexer::Table should allow utf-8 with using == to evaluate' FAILED
38
- # expected: [[:table, [["ůﻚ", "2"]], 1]],
39
- # got: [[:table, [["\xC5\xAF\xEF\xBB\x9A", "2"]], 1]] (using ==)
40
- # BUT, simply running:
41
- # [[:table, [["ůﻚ", "2"]], 1]].should == [[:table, [["\xC5\xAF\xEF\xBB\x9A", "2"]], 1]]
42
- # passes
43
- #
44
- @lexer.scan(" | ůﻚ | 2 | \n")
45
- @listener.to_sexp.should == [
46
- [:table, [["ůﻚ", "2"]], 1]
47
- ]
48
- end
49
-
50
- it "should allow utf-8 using should_receive" do
51
- @listener.should_receive(:table).with(t([['繁體中文 而且','並且','繁體中文 而且','並且']]), 1)
52
- @lexer.scan("| 繁體中文 而且|並且| 繁體中文 而且|並且|\n")
53
- end
54
-
55
- it "should parse a 2x2 table" do
56
- @listener.should_receive(:table).with(t([%w{1 2}, %w{3 4}]), 1)
57
- @lexer.scan("| 1 | 2 |\n| 3 | 4 |\n")
58
- end
59
-
60
- it "should parse a 2x2 table with several newlines" do
61
- @listener.should_receive(:table).with(t([%w{1 2}, %w{3 4}]), 1)
62
- @lexer.scan("| 1 | 2 |\n| 3 | 4 |\n\n\n")
63
- end
64
-
65
- it "should parse a 2x2 table with empty cells" do
66
- @listener.should_receive(:table).with(t([['1', ''], ['', '4']]), 1)
67
- @lexer.scan("| 1 | |\n|| 4 |\n")
68
- end
69
-
70
- it "should parse a 1x2 table that does not end in a newline" do
71
- @listener.should_receive(:table).with(t([%w{1 2}]), 1)
72
- @lexer.scan("| 1 | 2 |")
73
- end
74
-
75
- it "should parse a 1x2 table without spaces and newline" do
76
- @listener.should_receive(:table).with(t([%w{1 2}]), 1)
77
- @lexer.scan("|1|2|\n")
78
- end
79
-
80
- it "should parse a row with whitespace after the rows" do
81
- @listener.should_receive(:table).with(t([%w{1 2}, %w{a b}]), 1)
82
- @lexer.scan("| 1 | 2 | \n | a | b | \n")
83
- end
84
-
85
- it "should parse a table with lots of whitespace" do
86
- @listener.should_receive(:table).with(t([["abc", "123"]]), 1)
87
- @lexer.scan(" \t| \t abc\t| \t123\t \t\t| \t\t \t \t\n ")
88
- end
89
-
90
- it "should raise LexingError for rows that aren't closed" do
91
- lambda {
92
- @lexer.scan("|| oh hello \n")
93
- }.should raise_error(/Parsing error on line 1: '|| oh hello/)
94
- end
95
- end
96
- end
97
- end