aslakhellesoy-cucumber 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +38 -3
- data/Manifest.txt +17 -1
- data/README.txt +2 -39
- data/bin/cucumber +1 -1
- data/examples/calculator_ruby_features/features/addition.rb +16 -0
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +1 -0
- data/examples/i18n/de/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +1 -0
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +1 -0
- data/examples/i18n/fr/features/addition.feature +13 -11
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +6 -2
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +1 -0
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +2 -0
- data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +1 -0
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +1 -0
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +1 -0
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/selenium/features/search.feature +1 -1
- data/examples/selenium/features/step_definitons/stories_steps.rb +2 -3
- data/examples/tickets/features/lib/eatting_machine.rb +18 -0
- data/examples/tickets/features/lib/pantry.rb +20 -0
- data/examples/tickets/features/scenario_outline.feature +64 -0
- data/examples/tickets/features/step_definitons/scenario_outline_steps.rb +34 -0
- data/examples/tickets/features/step_definitons/tickets_steps.rb +4 -0
- data/gem_tasks/fix_cr_lf.rake +1 -1
- data/gem_tasks/yard.rake +8 -0
- data/lib/autotest/cucumber_mixin.rb +3 -3
- data/lib/cucumber/broadcaster.rb +1 -1
- data/lib/cucumber/cli.rb +87 -42
- data/lib/cucumber/core_ext/exception.rb +20 -0
- data/lib/cucumber/core_ext/string.rb +1 -1
- data/lib/cucumber/executor.rb +35 -18
- data/lib/cucumber/formatters/ansicolor.rb +65 -74
- data/lib/cucumber/formatters/html_formatter.rb +33 -10
- data/lib/cucumber/formatters/pretty_formatter.rb +58 -16
- data/lib/cucumber/formatters/progress_formatter.rb +3 -0
- data/lib/cucumber/formatters/unicode.rb +27 -0
- data/lib/cucumber/languages.yml +6 -4
- data/lib/cucumber/platform.rb +1 -0
- data/lib/cucumber/rails/world.rb +6 -6
- data/lib/cucumber/step_mother.rb +3 -0
- data/lib/cucumber/tree/feature.rb +28 -2
- data/lib/cucumber/tree/scenario.rb +62 -1
- data/lib/cucumber/tree/step.rb +32 -1
- data/lib/cucumber/treetop_parser/feature.treetop.erb +54 -7
- data/lib/cucumber/treetop_parser/feature_ar.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_cy.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_da.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_de.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_en-lol.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_en-tx.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_en.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_es.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_et.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_fr.rb +389 -30
- data/lib/cucumber/treetop_parser/feature_id.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_it.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_ja.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_lt.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_nl.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_no.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_pl.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_pt.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_ro.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_ro2.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_ru.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_se.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +377 -18
- data/lib/cucumber/version.rb +1 -1
- data/lib/cucumber/world/pending.rb +22 -0
- data/lib/cucumber/world.rb +1 -0
- data/lib/cucumber.rb +2 -0
- data/rails_generators/cucumber/templates/env.rb +1 -0
- data/rails_generators/feature/feature_generator.rb +22 -2
- data/rails_generators/feature/templates/feature.erb +15 -12
- data/rails_generators/feature/templates/steps.erb +16 -14
- data/spec/cucumber/cli_spec.rb +87 -6
- data/spec/cucumber/executor_spec.rb +102 -30
- data/spec/cucumber/formatters/ansicolor_spec.rb +10 -10
- data/spec/cucumber/formatters/html_formatter_spec.rb +30 -0
- data/spec/cucumber/formatters/pretty_formatter_spec.rb +139 -4
- data/spec/cucumber/formatters/progress_formatter_spec.rb +16 -0
- data/spec/cucumber/tree/feature_spec.rb +84 -5
- data/spec/cucumber/tree/row_scenario_outline_spec.rb +73 -0
- data/spec/cucumber/tree/row_step_outline_spec.rb +38 -0
- data/spec/cucumber/tree/scenario_outline_spec.rb +50 -0
- data/spec/cucumber/tree/step_outline_spec.rb +17 -0
- data/spec/cucumber/tree/step_spec.rb +9 -0
- data/spec/cucumber/treetop_parser/empty_scenario_outline.feature +3 -0
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +22 -0
- data/spec/cucumber/treetop_parser/invalid_scenario_outlines.feature +7 -0
- data/spec/cucumber/treetop_parser/scenario_outline.feature +16 -0
- data/spec/cucumber/world/pending_spec.rb +46 -0
- data/spec/spec_helper.rb +2 -1
- metadata +19 -4
- data/TODO.txt +0 -26
@@ -94,12 +94,17 @@ module Feature
|
|
94
94
|
if r4
|
95
95
|
r3 = r4
|
96
96
|
else
|
97
|
-
r5 =
|
97
|
+
r5 = _nt_scenario_outline_keyword
|
98
98
|
if r5
|
99
99
|
r3 = r5
|
100
100
|
else
|
101
|
-
|
102
|
-
|
101
|
+
r6 = _nt_comment_to_eol
|
102
|
+
if r6
|
103
|
+
r3 = r6
|
104
|
+
else
|
105
|
+
self.index = i3
|
106
|
+
r3 = nil
|
107
|
+
end
|
103
108
|
end
|
104
109
|
end
|
105
110
|
if r3
|
@@ -111,13 +116,13 @@ module Feature
|
|
111
116
|
s1 << r2
|
112
117
|
if r2
|
113
118
|
if index < input_length
|
114
|
-
|
119
|
+
r7 = (SyntaxNode).new(input, index...(index + 1))
|
115
120
|
@index += 1
|
116
121
|
else
|
117
122
|
terminal_parse_failure("any character")
|
118
|
-
|
123
|
+
r7 = nil
|
119
124
|
end
|
120
|
-
s1 <<
|
125
|
+
s1 << r7
|
121
126
|
end
|
122
127
|
if s1.last
|
123
128
|
r1 = (SyntaxNode).new(input, i1...index, s1)
|
@@ -149,7 +154,7 @@ module Feature
|
|
149
154
|
elements[0]
|
150
155
|
end
|
151
156
|
|
152
|
-
def
|
157
|
+
def scenario_or_scenario_outline_or_table
|
153
158
|
elements[1]
|
154
159
|
end
|
155
160
|
end
|
@@ -166,13 +171,13 @@ module Feature
|
|
166
171
|
|
167
172
|
module ScenarioSequence2
|
168
173
|
def compile(feature)
|
169
|
-
([head] + tail).each do |
|
170
|
-
|
174
|
+
([head] + tail).each do |scenario_or_scenario_outline_or_table|
|
175
|
+
scenario_or_scenario_outline_or_table.compile(feature) if scenario_or_scenario_outline_or_table.respond_to?(:compile)
|
171
176
|
end
|
172
177
|
end
|
173
178
|
|
174
179
|
def tail
|
175
|
-
super.elements.map { |elt| elt.
|
180
|
+
super.elements.map { |elt| elt.scenario_or_scenario_outline_or_table }
|
176
181
|
end
|
177
182
|
end
|
178
183
|
|
@@ -185,7 +190,7 @@ module Feature
|
|
185
190
|
end
|
186
191
|
|
187
192
|
i0, s0 = index, []
|
188
|
-
r2 =
|
193
|
+
r2 = _nt_scenario_outline_or_scenario
|
189
194
|
if r2
|
190
195
|
r1 = r2
|
191
196
|
else
|
@@ -199,7 +204,7 @@ module Feature
|
|
199
204
|
r5 = _nt_space
|
200
205
|
s4 << r5
|
201
206
|
if r5
|
202
|
-
r6 =
|
207
|
+
r6 = _nt_scenario_or_scenario_outline_or_table
|
203
208
|
s4 << r6
|
204
209
|
end
|
205
210
|
if s4.last
|
@@ -232,6 +237,33 @@ module Feature
|
|
232
237
|
return r0
|
233
238
|
end
|
234
239
|
|
240
|
+
def _nt_scenario_outline_or_scenario
|
241
|
+
start_index = index
|
242
|
+
if node_cache[:scenario_outline_or_scenario].has_key?(index)
|
243
|
+
cached = node_cache[:scenario_outline_or_scenario][index]
|
244
|
+
@index = cached.interval.end if cached
|
245
|
+
return cached
|
246
|
+
end
|
247
|
+
|
248
|
+
i0 = index
|
249
|
+
r1 = _nt_scenario_outline
|
250
|
+
if r1
|
251
|
+
r0 = r1
|
252
|
+
else
|
253
|
+
r2 = _nt_scenario
|
254
|
+
if r2
|
255
|
+
r0 = r2
|
256
|
+
else
|
257
|
+
self.index = i0
|
258
|
+
r0 = nil
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
node_cache[:scenario_outline_or_scenario][start_index] = r0
|
263
|
+
|
264
|
+
return r0
|
265
|
+
end
|
266
|
+
|
235
267
|
module Scenario0
|
236
268
|
def space
|
237
269
|
elements[0]
|
@@ -327,20 +359,102 @@ module Feature
|
|
327
359
|
return r0
|
328
360
|
end
|
329
361
|
|
330
|
-
|
362
|
+
module ScenarioOutline0
|
363
|
+
def scenario_outline_keyword
|
364
|
+
elements[0]
|
365
|
+
end
|
366
|
+
|
367
|
+
def name
|
368
|
+
elements[2]
|
369
|
+
end
|
370
|
+
|
371
|
+
def outline_body
|
372
|
+
elements[3]
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
module ScenarioOutline1
|
377
|
+
def compile(feature)
|
378
|
+
line = input.line_of(interval.first)
|
379
|
+
scenario = feature.add_scenario_outline(name.text_value.strip, line)
|
380
|
+
Feature.last_scenario = scenario
|
381
|
+
outline_body.compile(feature, scenario) if outline_body.respond_to?(:compile)
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
def _nt_scenario_outline
|
386
|
+
start_index = index
|
387
|
+
if node_cache[:scenario_outline].has_key?(index)
|
388
|
+
cached = node_cache[:scenario_outline][index]
|
389
|
+
@index = cached.interval.end if cached
|
390
|
+
return cached
|
391
|
+
end
|
392
|
+
|
393
|
+
i0, s0 = index, []
|
394
|
+
r1 = _nt_scenario_outline_keyword
|
395
|
+
s0 << r1
|
396
|
+
if r1
|
397
|
+
r3 = _nt_space
|
398
|
+
if r3
|
399
|
+
r2 = r3
|
400
|
+
else
|
401
|
+
r2 = SyntaxNode.new(input, index...index)
|
402
|
+
end
|
403
|
+
s0 << r2
|
404
|
+
if r2
|
405
|
+
r4 = _nt_line_to_eol
|
406
|
+
s0 << r4
|
407
|
+
if r4
|
408
|
+
r6 = _nt_steps_and_optional_examples
|
409
|
+
if r6
|
410
|
+
r5 = r6
|
411
|
+
else
|
412
|
+
r5 = SyntaxNode.new(input, index...index)
|
413
|
+
end
|
414
|
+
s0 << r5
|
415
|
+
end
|
416
|
+
end
|
417
|
+
end
|
418
|
+
if s0.last
|
419
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
420
|
+
r0.extend(ScenarioOutline0)
|
421
|
+
r0.extend(ScenarioOutline1)
|
422
|
+
else
|
423
|
+
self.index = i0
|
424
|
+
r0 = nil
|
425
|
+
end
|
426
|
+
|
427
|
+
node_cache[:scenario_outline][start_index] = r0
|
428
|
+
|
429
|
+
return r0
|
430
|
+
end
|
431
|
+
|
432
|
+
def _nt_scenario_or_scenario_outline_or_table
|
331
433
|
start_index = index
|
332
|
-
if node_cache[:
|
333
|
-
cached = node_cache[:
|
434
|
+
if node_cache[:scenario_or_scenario_outline_or_table].has_key?(index)
|
435
|
+
cached = node_cache[:scenario_or_scenario_outline_or_table][index]
|
334
436
|
@index = cached.interval.end if cached
|
335
437
|
return cached
|
336
438
|
end
|
337
439
|
|
338
440
|
i0 = index
|
339
|
-
r1 =
|
441
|
+
r1 = _nt_scenario_outline
|
340
442
|
if r1
|
341
443
|
r0 = r1
|
342
444
|
else
|
343
|
-
|
445
|
+
i2 = index
|
446
|
+
r3 = _nt_scenario
|
447
|
+
if r3
|
448
|
+
r2 = r3
|
449
|
+
else
|
450
|
+
r4 = _nt_more_examples
|
451
|
+
if r4
|
452
|
+
r2 = r4
|
453
|
+
else
|
454
|
+
self.index = i2
|
455
|
+
r2 = nil
|
456
|
+
end
|
457
|
+
end
|
344
458
|
if r2
|
345
459
|
r0 = r2
|
346
460
|
else
|
@@ -349,7 +463,104 @@ module Feature
|
|
349
463
|
end
|
350
464
|
end
|
351
465
|
|
352
|
-
node_cache[:
|
466
|
+
node_cache[:scenario_or_scenario_outline_or_table][start_index] = r0
|
467
|
+
|
468
|
+
return r0
|
469
|
+
end
|
470
|
+
|
471
|
+
module StepsAndOptionalExamples0
|
472
|
+
def space
|
473
|
+
elements[0]
|
474
|
+
end
|
475
|
+
|
476
|
+
def step_sequence
|
477
|
+
elements[1]
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
module StepsAndOptionalExamples1
|
482
|
+
def space
|
483
|
+
elements[0]
|
484
|
+
end
|
485
|
+
|
486
|
+
def examples
|
487
|
+
elements[1]
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
491
|
+
module StepsAndOptionalExamples2
|
492
|
+
def steps
|
493
|
+
elements[0]
|
494
|
+
end
|
495
|
+
|
496
|
+
def table
|
497
|
+
elements[1]
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
module StepsAndOptionalExamples3
|
502
|
+
def compile(feature, scenario)
|
503
|
+
steps.step_sequence.compile(scenario) if steps.respond_to?(:step_sequence)
|
504
|
+
table.examples.compile(feature, scenario) if table.respond_to?(:examples) && table.examples.respond_to?(:compile)
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
508
|
+
def _nt_steps_and_optional_examples
|
509
|
+
start_index = index
|
510
|
+
if node_cache[:steps_and_optional_examples].has_key?(index)
|
511
|
+
cached = node_cache[:steps_and_optional_examples][index]
|
512
|
+
@index = cached.interval.end if cached
|
513
|
+
return cached
|
514
|
+
end
|
515
|
+
|
516
|
+
i0, s0 = index, []
|
517
|
+
i1, s1 = index, []
|
518
|
+
r2 = _nt_space
|
519
|
+
s1 << r2
|
520
|
+
if r2
|
521
|
+
r3 = _nt_step_sequence
|
522
|
+
s1 << r3
|
523
|
+
end
|
524
|
+
if s1.last
|
525
|
+
r1 = (SyntaxNode).new(input, i1...index, s1)
|
526
|
+
r1.extend(StepsAndOptionalExamples0)
|
527
|
+
else
|
528
|
+
self.index = i1
|
529
|
+
r1 = nil
|
530
|
+
end
|
531
|
+
s0 << r1
|
532
|
+
if r1
|
533
|
+
i5, s5 = index, []
|
534
|
+
r6 = _nt_space
|
535
|
+
s5 << r6
|
536
|
+
if r6
|
537
|
+
r7 = _nt_examples
|
538
|
+
s5 << r7
|
539
|
+
end
|
540
|
+
if s5.last
|
541
|
+
r5 = (SyntaxNode).new(input, i5...index, s5)
|
542
|
+
r5.extend(StepsAndOptionalExamples1)
|
543
|
+
else
|
544
|
+
self.index = i5
|
545
|
+
r5 = nil
|
546
|
+
end
|
547
|
+
if r5
|
548
|
+
r4 = r5
|
549
|
+
else
|
550
|
+
r4 = SyntaxNode.new(input, index...index)
|
551
|
+
end
|
552
|
+
s0 << r4
|
553
|
+
end
|
554
|
+
if s0.last
|
555
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
556
|
+
r0.extend(StepsAndOptionalExamples2)
|
557
|
+
r0.extend(StepsAndOptionalExamples3)
|
558
|
+
else
|
559
|
+
self.index = i0
|
560
|
+
r0 = nil
|
561
|
+
end
|
562
|
+
|
563
|
+
node_cache[:steps_and_optional_examples][start_index] = r0
|
353
564
|
|
354
565
|
return r0
|
355
566
|
end
|
@@ -399,6 +610,51 @@ module Feature
|
|
399
610
|
return r0
|
400
611
|
end
|
401
612
|
|
613
|
+
module Examples0
|
614
|
+
def examples_keyword
|
615
|
+
elements[0]
|
616
|
+
end
|
617
|
+
|
618
|
+
def table
|
619
|
+
elements[1]
|
620
|
+
end
|
621
|
+
end
|
622
|
+
|
623
|
+
module Examples1
|
624
|
+
def compile(feature, scenario)
|
625
|
+
table.compile_examples(feature, scenario)
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
629
|
+
def _nt_examples
|
630
|
+
start_index = index
|
631
|
+
if node_cache[:examples].has_key?(index)
|
632
|
+
cached = node_cache[:examples][index]
|
633
|
+
@index = cached.interval.end if cached
|
634
|
+
return cached
|
635
|
+
end
|
636
|
+
|
637
|
+
i0, s0 = index, []
|
638
|
+
r1 = _nt_examples_keyword
|
639
|
+
s0 << r1
|
640
|
+
if r1
|
641
|
+
r2 = _nt_table
|
642
|
+
s0 << r2
|
643
|
+
end
|
644
|
+
if s0.last
|
645
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
646
|
+
r0.extend(Examples0)
|
647
|
+
r0.extend(Examples1)
|
648
|
+
else
|
649
|
+
self.index = i0
|
650
|
+
r0 = nil
|
651
|
+
end
|
652
|
+
|
653
|
+
node_cache[:examples][start_index] = r0
|
654
|
+
|
655
|
+
return r0
|
656
|
+
end
|
657
|
+
|
402
658
|
module Table0
|
403
659
|
def eol
|
404
660
|
elements[1]
|
@@ -431,6 +687,13 @@ module Feature
|
|
431
687
|
end
|
432
688
|
end
|
433
689
|
|
690
|
+
def compile_examples(feature, scenario)
|
691
|
+
scenario.table_header = head.cell_values
|
692
|
+
body.each do |table_line|
|
693
|
+
feature.add_row_scenario_outline(scenario, table_line.cell_values, table_line.line)
|
694
|
+
end
|
695
|
+
end
|
696
|
+
|
434
697
|
def matrix
|
435
698
|
([head] + body).map do |table_line|
|
436
699
|
table_line.cell_values # We're losing the line - we'll get it back when we make our own class
|
@@ -1484,6 +1747,54 @@ module Feature
|
|
1484
1747
|
return r0
|
1485
1748
|
end
|
1486
1749
|
|
1750
|
+
module ScenarioOutlineKeyword0
|
1751
|
+
end
|
1752
|
+
|
1753
|
+
def _nt_scenario_outline_keyword
|
1754
|
+
start_index = index
|
1755
|
+
if node_cache[:scenario_outline_keyword].has_key?(index)
|
1756
|
+
cached = node_cache[:scenario_outline_keyword][index]
|
1757
|
+
@index = cached.interval.end if cached
|
1758
|
+
return cached
|
1759
|
+
end
|
1760
|
+
|
1761
|
+
i0, s0 = index, []
|
1762
|
+
if input.index("Scenario Outline", index) == index
|
1763
|
+
r1 = (SyntaxNode).new(input, index...(index + 16))
|
1764
|
+
@index += 16
|
1765
|
+
else
|
1766
|
+
terminal_parse_failure("Scenario Outline")
|
1767
|
+
r1 = nil
|
1768
|
+
end
|
1769
|
+
s0 << r1
|
1770
|
+
if r1
|
1771
|
+
if input.index(":", index) == index
|
1772
|
+
r3 = (SyntaxNode).new(input, index...(index + 1))
|
1773
|
+
@index += 1
|
1774
|
+
else
|
1775
|
+
terminal_parse_failure(":")
|
1776
|
+
r3 = nil
|
1777
|
+
end
|
1778
|
+
if r3
|
1779
|
+
r2 = r3
|
1780
|
+
else
|
1781
|
+
r2 = SyntaxNode.new(input, index...index)
|
1782
|
+
end
|
1783
|
+
s0 << r2
|
1784
|
+
end
|
1785
|
+
if s0.last
|
1786
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
1787
|
+
r0.extend(ScenarioOutlineKeyword0)
|
1788
|
+
else
|
1789
|
+
self.index = i0
|
1790
|
+
r0 = nil
|
1791
|
+
end
|
1792
|
+
|
1793
|
+
node_cache[:scenario_outline_keyword][start_index] = r0
|
1794
|
+
|
1795
|
+
return r0
|
1796
|
+
end
|
1797
|
+
|
1487
1798
|
module MoreExamplesKeyword0
|
1488
1799
|
end
|
1489
1800
|
|
@@ -1532,6 +1843,54 @@ module Feature
|
|
1532
1843
|
return r0
|
1533
1844
|
end
|
1534
1845
|
|
1846
|
+
module ExamplesKeyword0
|
1847
|
+
end
|
1848
|
+
|
1849
|
+
def _nt_examples_keyword
|
1850
|
+
start_index = index
|
1851
|
+
if node_cache[:examples_keyword].has_key?(index)
|
1852
|
+
cached = node_cache[:examples_keyword][index]
|
1853
|
+
@index = cached.interval.end if cached
|
1854
|
+
return cached
|
1855
|
+
end
|
1856
|
+
|
1857
|
+
i0, s0 = index, []
|
1858
|
+
if input.index("Examples", index) == index
|
1859
|
+
r1 = (SyntaxNode).new(input, index...(index + 8))
|
1860
|
+
@index += 8
|
1861
|
+
else
|
1862
|
+
terminal_parse_failure("Examples")
|
1863
|
+
r1 = nil
|
1864
|
+
end
|
1865
|
+
s0 << r1
|
1866
|
+
if r1
|
1867
|
+
if input.index(":", index) == index
|
1868
|
+
r3 = (SyntaxNode).new(input, index...(index + 1))
|
1869
|
+
@index += 1
|
1870
|
+
else
|
1871
|
+
terminal_parse_failure(":")
|
1872
|
+
r3 = nil
|
1873
|
+
end
|
1874
|
+
if r3
|
1875
|
+
r2 = r3
|
1876
|
+
else
|
1877
|
+
r2 = SyntaxNode.new(input, index...index)
|
1878
|
+
end
|
1879
|
+
s0 << r2
|
1880
|
+
end
|
1881
|
+
if s0.last
|
1882
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
1883
|
+
r0.extend(ExamplesKeyword0)
|
1884
|
+
else
|
1885
|
+
self.index = i0
|
1886
|
+
r0 = nil
|
1887
|
+
end
|
1888
|
+
|
1889
|
+
node_cache[:examples_keyword][start_index] = r0
|
1890
|
+
|
1891
|
+
return r0
|
1892
|
+
end
|
1893
|
+
|
1535
1894
|
module GivenScenarioKeyword0
|
1536
1895
|
end
|
1537
1896
|
|
data/lib/cucumber/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module World
|
3
|
+
module Pending
|
4
|
+
|
5
|
+
##
|
6
|
+
# Mark this step as pending
|
7
|
+
def pending(message = "TODO")
|
8
|
+
if block_given?
|
9
|
+
begin
|
10
|
+
yield
|
11
|
+
rescue Exception => e
|
12
|
+
raise Cucumber::ForcedPending.new(message)
|
13
|
+
end
|
14
|
+
raise Cucumber::ForcedPending.new("Expected pending '#{message}' to fail. No Error was raised.")
|
15
|
+
else
|
16
|
+
raise Cucumber::ForcedPending.new(message)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
%w{pending}.each{|f| require "cucumber/world/#{f}"}
|
data/lib/cucumber.rb
CHANGED
@@ -15,6 +15,8 @@ require 'cucumber/formatters'
|
|
15
15
|
require 'cucumber/treetop_parser/feature_parser'
|
16
16
|
require 'cucumber/cli'
|
17
17
|
require 'cucumber/broadcaster'
|
18
|
+
require 'cucumber/world'
|
19
|
+
require 'cucumber/core_ext/exception'
|
18
20
|
|
19
21
|
module Cucumber
|
20
22
|
LANGUAGE_FILE = File.expand_path(File.dirname(__FILE__) + '/cucumber/languages.yml')
|
@@ -2,6 +2,7 @@
|
|
2
2
|
ENV["RAILS_ENV"] = "test"
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
4
4
|
require 'cucumber/rails/world'
|
5
|
+
require 'cucumber/formatters/unicode' # Comment out this line if you don't want Cucumber Unicode support
|
5
6
|
Cucumber::Rails.use_transactional_fixtures
|
6
7
|
|
7
8
|
require 'webrat/rails'
|
@@ -8,9 +8,29 @@ class FeatureGenerator < Rails::Generator::NamedBase
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
class NamedArg
|
12
|
+
attr_reader :name
|
13
|
+
|
14
|
+
def initialize(s)
|
15
|
+
@name, @type = *s.split(':')
|
16
|
+
end
|
17
|
+
|
18
|
+
def value(n)
|
19
|
+
if @type == 'boolean'
|
20
|
+
(n % 2) == 0
|
21
|
+
else
|
22
|
+
"#{@name} #{n}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def named_args
|
28
|
+
args.map{|arg| NamedArg.new(arg)}
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
12
32
|
|
13
33
|
def banner
|
14
34
|
"Usage: #{$0} feature ModelName [field:type, field:type]"
|
15
35
|
end
|
16
|
-
end
|
36
|
+
end
|
@@ -6,23 +6,26 @@ Feature: Manage <%= plural_name %>
|
|
6
6
|
Scenario: Register new <%= singular_name %>
|
7
7
|
Given I am on the new <%= singular_name %> page
|
8
8
|
<% keyword = 'When' -%>
|
9
|
-
<%
|
10
|
-
<%= keyword %> I fill in "<%= arg.humanize %>" with "
|
9
|
+
<% named_args.each do |arg| -%>
|
10
|
+
<%= keyword %> I fill in "<%= arg.name.humanize %>" with "<%= arg.value(1) %>"
|
11
11
|
<% keyword = 'And' -%>
|
12
12
|
<% end -%>
|
13
13
|
And I press "Create"
|
14
14
|
<% keyword = 'Then' -%>
|
15
|
-
<%
|
16
|
-
<%= keyword %> I should see "
|
15
|
+
<% named_args.each do |arg| -%>
|
16
|
+
<%= keyword %> I should see "<%= arg.value(1) %>"
|
17
17
|
<% keyword = 'And' -%>
|
18
18
|
<% end -%>
|
19
19
|
|
20
20
|
Scenario: Delete <%= singular_name %>
|
21
|
-
Given
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
Given the following <%= plural_name %>:
|
22
|
+
|<%= named_args.map(&:name).join('|') %>|
|
23
|
+
<% (1..4).each do |n| -%>
|
24
|
+
|<%= named_args.map{|arg| arg.value(n)}.join('|') %>|
|
25
|
+
<% end -%>
|
26
|
+
When I delete the 3rd <%= singular_name %>
|
27
|
+
Then I should see the following <%= plural_name %>:
|
28
|
+
|<%= named_args.map(&:name).join('|') %>|
|
29
|
+
<% [1,2,4].each do |n| -%>
|
30
|
+
|<%= named_args.map{|arg| arg.value(n)}.join('|') %>|
|
31
|
+
<% end -%>
|
@@ -1,22 +1,24 @@
|
|
1
1
|
Given /I am on the new <%= singular_name %> page/ do
|
2
|
-
|
2
|
+
visit "/<%= plural_name %>/new"
|
3
3
|
end
|
4
4
|
|
5
|
-
Given
|
6
|
-
<%= class_name %>.
|
7
|
-
<%= class_name %>.destroy_all
|
8
|
-
n.to_i.times do |n|
|
9
|
-
<%= class_name %>.create! :name => "<%= class_name %> #{n}"
|
10
|
-
end
|
11
|
-
end
|
5
|
+
Given /^the following <%= plural_name %>:$/ do |<%= plural_name %>|
|
6
|
+
<%= class_name %>.create!(<%= plural_name %>.hashes)
|
12
7
|
end
|
13
8
|
|
14
|
-
When
|
15
|
-
|
16
|
-
|
9
|
+
When /^I delete the (\d+)(?:st|nd|rd|th) <%= singular_name %>$/ do |pos|
|
10
|
+
visit <%= plural_name %>_url
|
11
|
+
within("table > tr:nth-child(#{pos.to_i+1})") do
|
12
|
+
click_link "Destroy"
|
13
|
+
end
|
17
14
|
end
|
18
15
|
|
19
|
-
Then
|
20
|
-
<%=
|
21
|
-
|
16
|
+
Then /^I should see the following <%= plural_name %>:$/ do |<%= plural_name %>|
|
17
|
+
<%= plural_name %>.raw[1..-1].each_with_index do |row, i|
|
18
|
+
row.each_with_index do |cell, j|
|
19
|
+
response.should have_selector("table > tr:nth-child(#{i+2}) > td:nth-child(#{j+1})") { |td|
|
20
|
+
td.inner_text.should == cell
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
22
24
|
end
|