cucumber 2.0.0.beta.3 → 2.0.0.beta.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +20 -3
  3. data/cucumber.gemspec +2 -1
  4. data/examples/tcl/features/step_definitions/fib_steps.rb +1 -1
  5. data/features/docs/extending_cucumber/custom_formatter.feature +65 -7
  6. data/features/docs/formatters/debug_formatter.feature +24 -17
  7. data/features/docs/formatters/pretty_formatter.feature +42 -0
  8. data/features/docs/formatters/rerun_formatter.feature +3 -2
  9. data/lib/cucumber/cli/configuration.rb +3 -7
  10. data/lib/cucumber/cli/main.rb +1 -1
  11. data/lib/cucumber/{runtime → filters}/gated_receiver.rb +5 -1
  12. data/lib/cucumber/filters/quit.rb +24 -0
  13. data/lib/cucumber/filters/randomizer.rb +36 -0
  14. data/lib/cucumber/filters/tag_limits.rb +40 -0
  15. data/lib/cucumber/{runtime → filters}/tag_limits/test_case_index.rb +4 -2
  16. data/lib/cucumber/{runtime → filters}/tag_limits/verifier.rb +4 -2
  17. data/lib/cucumber/formatter/console.rb +2 -2
  18. data/lib/cucumber/formatter/debug.rb +1 -8
  19. data/lib/cucumber/formatter/fanout.rb +27 -0
  20. data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +1 -3
  21. data/lib/cucumber/formatter/html.rb +12 -4
  22. data/lib/cucumber/formatter/ignore_missing_messages.rb +20 -0
  23. data/lib/cucumber/formatter/junit.rb +2 -2
  24. data/lib/cucumber/formatter/legacy_api/adapter.rb +1008 -0
  25. data/lib/cucumber/formatter/legacy_api/ast.rb +374 -0
  26. data/lib/cucumber/formatter/legacy_api/results.rb +51 -0
  27. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +30 -0
  28. data/lib/cucumber/formatter/pretty.rb +4 -0
  29. data/lib/cucumber/formatter/rerun.rb +14 -88
  30. data/lib/cucumber/language_support/language_methods.rb +0 -54
  31. data/lib/cucumber/multiline_argument/data_table.rb +3 -4
  32. data/lib/cucumber/platform.rb +1 -1
  33. data/lib/cucumber/runtime.rb +41 -107
  34. data/spec/cucumber/{runtime → filters}/gated_receiver_spec.rb +3 -3
  35. data/spec/cucumber/{runtime → filters}/tag_limits/test_case_index_spec.rb +3 -3
  36. data/spec/cucumber/{runtime → filters}/tag_limits/verifier_spec.rb +4 -4
  37. data/spec/cucumber/{runtime/tag_limits/filter_spec.rb → filters/tag_limits_spec.rb} +6 -6
  38. data/spec/cucumber/formatter/debug_spec.rb +39 -530
  39. data/spec/cucumber/formatter/html_spec.rb +56 -0
  40. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +1902 -0
  41. data/spec/cucumber/formatter/pretty_spec.rb +128 -0
  42. data/spec/cucumber/formatter/rerun_spec.rb +106 -0
  43. data/spec/cucumber/formatter/spec_helper.rb +6 -2
  44. data/spec/cucumber/rb_support/rb_language_spec.rb +2 -2
  45. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +1 -1
  46. data/spec/cucumber/runtime_spec.rb +1 -5
  47. data/spec/spec_helper.rb +2 -0
  48. metadata +44 -29
  49. data/features/docs/extending_cucumber/formatter_callbacks.feature +0 -370
  50. data/features/docs/output_from_hooks.feature +0 -128
  51. data/lib/cucumber/reports/legacy_formatter.rb +0 -1349
  52. data/lib/cucumber/runtime/results.rb +0 -64
  53. data/lib/cucumber/runtime/tag_limits.rb +0 -15
  54. data/lib/cucumber/runtime/tag_limits/filter.rb +0 -31
  55. data/spec/cucumber/reports/legacy_formatter_spec.rb +0 -1860
  56. data/spec/cucumber/runtime/results_spec.rb +0 -88
@@ -313,6 +313,62 @@ module Cucumber
313
313
 
314
314
  it { expect(@doc.css('pre').map { |pre| /^(Given|And)/.match(pre.text)[1] }).to eq ["Given", "Given"] }
315
315
  end
316
+
317
+ describe "with a output from hooks" do
318
+ describe "in a scenario" do
319
+ define_feature <<-FEATURE
320
+ Feature:
321
+ Scenario:
322
+ Given this step passes
323
+ FEATURE
324
+
325
+ define_steps do
326
+ Before do
327
+ puts "Before hook"
328
+ end
329
+ AfterStep do
330
+ puts "AfterStep hook"
331
+ end
332
+ After do
333
+ puts "After hook"
334
+ end
335
+ Given(/^this step passes$/) {}
336
+ end
337
+
338
+ it 'should have ccs nodes ".step.message" for all the hooks' do
339
+ expect(@doc.css('.step.message').length).to eq 3
340
+ expect(@doc.css('.step.message')[0].text).to eq "Before hook"
341
+ expect(@doc.css('.step.message')[1].text).to eq "AfterStep hook"
342
+ expect(@doc.css('.step.message')[2].text).to eq "After hook"
343
+ end
344
+ end
345
+
346
+ describe "in a scenario outline" do
347
+ define_feature <<-FEATURE
348
+ Feature:
349
+ Scenario Outline:
350
+ Given this step <status>
351
+ Examples:
352
+ | status |
353
+ | passes |
354
+ FEATURE
355
+
356
+ define_steps do
357
+ Before do
358
+ puts "Before hook"
359
+ end
360
+ AfterStep do
361
+ puts "AfterStep hook"
362
+ end
363
+ After do
364
+ puts "After hook"
365
+ end
366
+ Given(/^this step passes$/) {}
367
+ end
368
+
369
+ it { expect(@doc).to have_css_node('.message', /Before hook, AfterStep hook, After hook/) }
370
+ end
371
+ end
316
372
  end
317
373
  end
318
374
  end
@@ -0,0 +1,1902 @@
1
+ require 'cucumber/formatter/legacy_api/adapter'
2
+ require 'cucumber/core'
3
+ require 'cucumber/core/gherkin/writer'
4
+ require 'cucumber/mappings'
5
+
6
+ module Cucumber
7
+ module Formatter::LegacyApi
8
+ describe Adapter do
9
+ include Core::Gherkin::Writer
10
+ include Core
11
+
12
+ let(:report) { Adapter.new(formatter, runtime.results, runtime.support_code, runtime.configuration) }
13
+ let(:formatter) { double('formatter').as_null_object }
14
+ let(:runtime) { Runtime.new }
15
+ let(:mappings) { mappings = CustomMappings.new }
16
+
17
+ Failure = Class.new(StandardError)
18
+
19
+ class CustomMappings
20
+ def test_case(test_case, mapper)
21
+ # The adapter is built on the assumption that each test case will have at least one step. This is annoying
22
+ # for tests, but a safe assumption for production use as we always add one hook to initialize the world.
23
+ mapper.before {}
24
+ end
25
+
26
+ def test_step(test_step, mapper)
27
+ if test_step.name =~ /pass/
28
+ mapper.map {}
29
+ end
30
+
31
+ if test_step.name =~ /fail/
32
+ mapper.map { raise Failure }
33
+ end
34
+ end
35
+ end
36
+
37
+ context 'message order' do
38
+ let(:formatter) { MessageSpy.new }
39
+
40
+ it 'two features' do
41
+ gherkin_docs = [
42
+ gherkin do
43
+ feature do
44
+ scenario do
45
+ step 'passing'
46
+ end
47
+ end
48
+ end,
49
+ gherkin do
50
+ feature do
51
+ scenario do
52
+ step 'passing'
53
+ end
54
+ end
55
+ end,
56
+ ]
57
+ execute gherkin_docs, mappings, report
58
+ expect( formatter.legacy_messages ).to eq [
59
+ :before_features,
60
+ :before_feature,
61
+ :before_tags,
62
+ :after_tags,
63
+ :feature_name,
64
+ :before_feature_element,
65
+ :before_tags,
66
+ :after_tags,
67
+ :scenario_name,
68
+ :before_steps,
69
+ :before_step,
70
+ :before_step_result,
71
+ :step_name,
72
+ :after_step_result,
73
+ :after_step,
74
+ :after_steps,
75
+ :after_feature_element,
76
+ :after_feature,
77
+ :before_feature,
78
+ :before_tags,
79
+ :after_tags,
80
+ :feature_name,
81
+ :before_feature_element,
82
+ :before_tags,
83
+ :after_tags,
84
+ :scenario_name,
85
+ :before_steps,
86
+ :before_step,
87
+ :before_step_result,
88
+ :step_name,
89
+ :after_step_result,
90
+ :after_step,
91
+ :after_steps,
92
+ :after_feature_element,
93
+ :after_feature,
94
+ :after_features,
95
+ ]
96
+ end
97
+
98
+ it 'a scenario with no steps' do
99
+ execute_gherkin do
100
+ feature do
101
+ scenario
102
+ end
103
+ end
104
+
105
+ expect( formatter.legacy_messages ).to eq [
106
+ :before_features,
107
+ :before_feature,
108
+ :before_tags,
109
+ :after_tags,
110
+ :feature_name,
111
+ :before_feature_element,
112
+ :before_tags,
113
+ :after_tags,
114
+ :scenario_name,
115
+ :after_feature_element,
116
+ :after_feature,
117
+ :after_features,
118
+ ]
119
+ end
120
+
121
+ it 'a scenario with no steps coming after another scenario' do
122
+ execute_gherkin do
123
+ feature do
124
+ scenario do
125
+ step 'passing'
126
+ end
127
+ scenario
128
+ end
129
+ end
130
+ expect( formatter.legacy_messages ).to eq [
131
+ :before_features,
132
+ :before_feature,
133
+ :before_tags,
134
+ :after_tags,
135
+ :feature_name,
136
+ :before_feature_element,
137
+ :before_tags,
138
+ :after_tags,
139
+ :scenario_name,
140
+ :before_steps,
141
+ :before_step,
142
+ :before_step_result,
143
+ :step_name,
144
+ :after_step_result,
145
+ :after_step,
146
+ :after_steps,
147
+ :after_feature_element,
148
+ :before_feature_element,
149
+ :before_tags,
150
+ :after_tags,
151
+ :scenario_name,
152
+ :after_feature_element,
153
+ :after_feature,
154
+ :after_features,
155
+ ]
156
+ end
157
+
158
+ it 'a scenario with one step' do
159
+ execute_gherkin do
160
+ feature do
161
+ scenario do
162
+ step 'passing'
163
+ end
164
+ end
165
+ end
166
+ expect( formatter.legacy_messages ).to eq [
167
+ :before_features,
168
+ :before_feature,
169
+ :before_tags,
170
+ :after_tags,
171
+ :feature_name,
172
+ :before_feature_element,
173
+ :before_tags,
174
+ :after_tags,
175
+ :scenario_name,
176
+ :before_steps,
177
+ :before_step,
178
+ :before_step_result,
179
+ :step_name,
180
+ :after_step_result,
181
+ :after_step,
182
+ :after_steps,
183
+ :after_feature_element,
184
+ :after_feature,
185
+ :after_features,
186
+ ]
187
+ end
188
+
189
+ it 'a scenario with two steps, one of them failing' do
190
+ execute_gherkin do
191
+ feature do
192
+ scenario do
193
+ step 'passing'
194
+ step 'failing'
195
+ end
196
+ end
197
+ end
198
+ expect( formatter.legacy_messages ).to eq [
199
+ :before_features,
200
+ :before_feature,
201
+ :before_tags,
202
+ :after_tags,
203
+ :feature_name,
204
+ :before_feature_element,
205
+ :before_tags,
206
+ :after_tags,
207
+ :scenario_name,
208
+ :before_steps,
209
+ :before_step,
210
+ :before_step_result,
211
+ :step_name,
212
+ :after_step_result,
213
+ :after_step,
214
+ :before_step,
215
+ :before_step_result,
216
+ :step_name,
217
+ :exception,
218
+ :after_step_result,
219
+ :after_step,
220
+ :after_steps,
221
+ :after_feature_element,
222
+ :after_feature,
223
+ :after_features,
224
+ ]
225
+ end
226
+
227
+ it 'a feature with two scenarios' do
228
+ execute_gherkin do
229
+ feature do
230
+ scenario do
231
+ step 'passing'
232
+ end
233
+ scenario do
234
+ step 'passing'
235
+ end
236
+ end
237
+ end
238
+ expect( formatter.legacy_messages ).to eq [
239
+ :before_features,
240
+ :before_feature,
241
+ :before_tags,
242
+ :after_tags,
243
+ :feature_name,
244
+ :before_feature_element,
245
+ :before_tags,
246
+ :after_tags,
247
+ :scenario_name,
248
+ :before_steps,
249
+ :before_step,
250
+ :before_step_result,
251
+ :step_name,
252
+ :after_step_result,
253
+ :after_step,
254
+ :after_steps,
255
+ :after_feature_element,
256
+ :before_feature_element,
257
+ :before_tags,
258
+ :after_tags,
259
+ :scenario_name,
260
+ :before_steps,
261
+ :before_step,
262
+ :before_step_result,
263
+ :step_name,
264
+ :after_step_result,
265
+ :after_step,
266
+ :after_steps,
267
+ :after_feature_element,
268
+ :after_feature,
269
+ :after_features,
270
+ ]
271
+ end
272
+
273
+ it 'a feature with a background and two scenarios' do
274
+ execute_gherkin do
275
+ feature do
276
+ background do
277
+ step 'passing'
278
+ end
279
+ scenario do
280
+ step 'passing'
281
+ end
282
+ scenario do
283
+ step 'passing'
284
+ end
285
+ end
286
+ end
287
+ expect( formatter.legacy_messages ).to eq [
288
+ :before_features,
289
+ :before_feature,
290
+ :before_tags,
291
+ :after_tags,
292
+ :feature_name,
293
+ :before_background,
294
+ :background_name,
295
+ :before_steps,
296
+ :before_step,
297
+ :before_step_result,
298
+ :step_name,
299
+ :after_step_result,
300
+ :after_step,
301
+ :after_steps,
302
+ :after_background,
303
+ :before_feature_element,
304
+ :before_tags,
305
+ :after_tags,
306
+ :scenario_name,
307
+ :before_steps,
308
+ :before_step,
309
+ :before_step_result,
310
+ :step_name,
311
+ :after_step_result,
312
+ :after_step,
313
+ :after_steps,
314
+ :after_feature_element,
315
+ :before_feature_element,
316
+ :before_tags,
317
+ :after_tags,
318
+ :scenario_name,
319
+ :before_steps,
320
+ :before_step,
321
+ :before_step_result,
322
+ :step_name,
323
+ :after_step_result,
324
+ :after_step,
325
+ :after_steps,
326
+ :after_feature_element,
327
+ :after_feature,
328
+ :after_features,
329
+ ]
330
+ end
331
+
332
+ it 'a feature with a background and one scenario and one scenario outline' do
333
+ execute_gherkin do
334
+ feature do
335
+ background do
336
+ step 'passing'
337
+ end
338
+ scenario do
339
+ step 'passing'
340
+ end
341
+ scenario_outline do
342
+ step '<result>ing'
343
+ examples do
344
+ row 'result'
345
+ row 'pass'
346
+ end
347
+ end
348
+ end
349
+ end
350
+ expect( formatter.legacy_messages ).to eq [
351
+ :before_features,
352
+ :before_feature,
353
+ :before_tags,
354
+ :after_tags,
355
+ :feature_name,
356
+ :before_background,
357
+ :background_name,
358
+ :before_steps,
359
+ :before_step,
360
+ :before_step_result,
361
+ :step_name,
362
+ :after_step_result,
363
+ :after_step,
364
+ :after_steps,
365
+ :after_background,
366
+ :before_feature_element,
367
+ :before_tags,
368
+ :after_tags,
369
+ :scenario_name,
370
+ :before_steps,
371
+ :before_step,
372
+ :before_step_result,
373
+ :step_name,
374
+ :after_step_result,
375
+ :after_step,
376
+ :after_steps,
377
+ :after_feature_element,
378
+ :before_feature_element,
379
+ :before_tags,
380
+ :after_tags,
381
+ :scenario_name,
382
+ :before_steps,
383
+ :before_step,
384
+ :before_step_result,
385
+ :step_name,
386
+ :after_step_result,
387
+ :after_step,
388
+ :after_steps,
389
+ :before_examples_array,
390
+ :before_examples,
391
+ :examples_name,
392
+ :before_outline_table,
393
+ :before_table_row,
394
+ :before_table_cell,
395
+ :table_cell_value,
396
+ :after_table_cell,
397
+ :after_table_row,
398
+ :before_table_row,
399
+ :before_table_cell,
400
+ :table_cell_value,
401
+ :after_table_cell,
402
+ :after_table_row,
403
+ :after_outline_table,
404
+ :after_examples,
405
+ :after_examples_array,
406
+ :after_feature_element,
407
+ :after_feature,
408
+ :after_features,
409
+ ]
410
+ end
411
+
412
+ it 'a feature with a background and one scenario outline and one scenario' do
413
+ execute_gherkin do
414
+ feature do
415
+ background do
416
+ step 'passing'
417
+ end
418
+ scenario_outline do
419
+ step '<result>ing'
420
+ examples do
421
+ row 'result'
422
+ row 'pass'
423
+ end
424
+ end
425
+ scenario do
426
+ step 'passing'
427
+ end
428
+ end
429
+ end
430
+ expect( formatter.legacy_messages ).to eq [
431
+ :before_features,
432
+ :before_feature,
433
+ :before_tags,
434
+ :after_tags,
435
+ :feature_name,
436
+ :before_background,
437
+ :background_name,
438
+ :before_steps,
439
+ :before_step,
440
+ :before_step_result,
441
+ :step_name,
442
+ :after_step_result,
443
+ :after_step,
444
+ :after_steps,
445
+ :after_background,
446
+ :before_feature_element,
447
+ :before_tags,
448
+ :after_tags,
449
+ :scenario_name,
450
+ :before_steps,
451
+ :before_step,
452
+ :before_step_result,
453
+ :step_name,
454
+ :after_step_result,
455
+ :after_step,
456
+ :after_steps,
457
+ :before_examples_array,
458
+ :before_examples,
459
+ :examples_name,
460
+ :before_outline_table,
461
+ :before_table_row,
462
+ :before_table_cell,
463
+ :table_cell_value,
464
+ :after_table_cell,
465
+ :after_table_row,
466
+ :before_table_row,
467
+ :before_table_cell,
468
+ :table_cell_value,
469
+ :after_table_cell,
470
+ :after_table_row,
471
+ :after_outline_table,
472
+ :after_examples,
473
+ :after_examples_array,
474
+ :after_feature_element,
475
+ :before_feature_element,
476
+ :before_tags,
477
+ :after_tags,
478
+ :scenario_name,
479
+ :before_steps,
480
+ :before_step,
481
+ :before_step_result,
482
+ :step_name,
483
+ :after_step_result,
484
+ :after_step,
485
+ :after_steps,
486
+ :after_feature_element,
487
+ :after_feature,
488
+ :after_features,
489
+ ]
490
+ end
491
+
492
+ it 'a feature with a background and two scenario outlines' do
493
+ execute_gherkin do
494
+ feature do
495
+ background do
496
+ step 'passing'
497
+ end
498
+ scenario_outline do
499
+ step '<result>ing'
500
+ examples do
501
+ row 'result'
502
+ row 'pass'
503
+ end
504
+ end
505
+ scenario_outline do
506
+ step '<result>ing'
507
+ examples do
508
+ row 'result'
509
+ row 'pass'
510
+ end
511
+ end
512
+ end
513
+ end
514
+ expect( formatter.legacy_messages ).to eq [
515
+ :before_features,
516
+ :before_feature,
517
+ :before_tags,
518
+ :after_tags,
519
+ :feature_name,
520
+ :before_background,
521
+ :background_name,
522
+ :before_steps,
523
+ :before_step,
524
+ :before_step_result,
525
+ :step_name,
526
+ :after_step_result,
527
+ :after_step,
528
+ :after_steps,
529
+ :after_background,
530
+ :before_feature_element,
531
+ :before_tags,
532
+ :after_tags,
533
+ :scenario_name,
534
+ :before_steps,
535
+ :before_step,
536
+ :before_step_result,
537
+ :step_name,
538
+ :after_step_result,
539
+ :after_step,
540
+ :after_steps,
541
+ :before_examples_array,
542
+ :before_examples,
543
+ :examples_name,
544
+ :before_outline_table,
545
+ :before_table_row,
546
+ :before_table_cell,
547
+ :table_cell_value,
548
+ :after_table_cell,
549
+ :after_table_row,
550
+ :before_table_row,
551
+ :before_table_cell,
552
+ :table_cell_value,
553
+ :after_table_cell,
554
+ :after_table_row,
555
+ :after_outline_table,
556
+ :after_examples,
557
+ :after_examples_array,
558
+ :after_feature_element,
559
+ :before_feature_element,
560
+ :before_tags,
561
+ :after_tags,
562
+ :scenario_name,
563
+ :before_steps,
564
+ :before_step,
565
+ :before_step_result,
566
+ :step_name,
567
+ :after_step_result,
568
+ :after_step,
569
+ :after_steps,
570
+ :before_examples_array,
571
+ :before_examples,
572
+ :examples_name,
573
+ :before_outline_table,
574
+ :before_table_row,
575
+ :before_table_cell,
576
+ :table_cell_value,
577
+ :after_table_cell,
578
+ :after_table_row,
579
+ :before_table_row,
580
+ :before_table_cell,
581
+ :table_cell_value,
582
+ :after_table_cell,
583
+ :after_table_row,
584
+ :after_outline_table,
585
+ :after_examples,
586
+ :after_examples_array,
587
+ :after_feature_element,
588
+ :after_feature,
589
+ :after_features,
590
+ ]
591
+ end
592
+
593
+ it 'a feature with a background and one scenario outline with two rows' do
594
+ execute_gherkin do
595
+ feature do
596
+ background do
597
+ step 'passing'
598
+ end
599
+ scenario_outline do
600
+ step '<result>ing'
601
+ examples do
602
+ row 'result'
603
+ row 'pass'
604
+ row 'pass'
605
+ end
606
+ end
607
+ end
608
+ end
609
+ expect( formatter.legacy_messages ).to eq [
610
+ :before_features,
611
+ :before_feature,
612
+ :before_tags,
613
+ :after_tags,
614
+ :feature_name,
615
+ :before_background,
616
+ :background_name,
617
+ :before_steps,
618
+ :before_step,
619
+ :before_step_result,
620
+ :step_name,
621
+ :after_step_result,
622
+ :after_step,
623
+ :after_steps,
624
+ :after_background,
625
+ :before_feature_element,
626
+ :before_tags,
627
+ :after_tags,
628
+ :scenario_name,
629
+ :before_steps,
630
+ :before_step,
631
+ :before_step_result,
632
+ :step_name,
633
+ :after_step_result,
634
+ :after_step,
635
+ :after_steps,
636
+ :before_examples_array,
637
+ :before_examples,
638
+ :examples_name,
639
+ :before_outline_table,
640
+ :before_table_row,
641
+ :before_table_cell,
642
+ :table_cell_value,
643
+ :after_table_cell,
644
+ :after_table_row,
645
+ :before_table_row,
646
+ :before_table_cell,
647
+ :table_cell_value,
648
+ :after_table_cell,
649
+ :after_table_row,
650
+ :before_table_row,
651
+ :before_table_cell,
652
+ :table_cell_value,
653
+ :after_table_cell,
654
+ :after_table_row,
655
+ :after_outline_table,
656
+ :after_examples,
657
+ :after_examples_array,
658
+ :after_feature_element,
659
+ :after_feature,
660
+ :after_features,
661
+ ]
662
+ end
663
+
664
+ it 'a feature with a background and one scenario outline with two examples tables' do
665
+ execute_gherkin do
666
+ feature do
667
+ background do
668
+ step 'passing'
669
+ end
670
+ scenario_outline do
671
+ step '<result>ing'
672
+ examples do
673
+ row 'result'
674
+ row 'pass'
675
+ end
676
+ examples do
677
+ row 'result'
678
+ row 'pass'
679
+ end
680
+ end
681
+ end
682
+ end
683
+ expect( formatter.legacy_messages ).to eq [
684
+ :before_features,
685
+ :before_feature,
686
+ :before_tags,
687
+ :after_tags,
688
+ :feature_name,
689
+ :before_background,
690
+ :background_name,
691
+ :before_steps,
692
+ :before_step,
693
+ :before_step_result,
694
+ :step_name,
695
+ :after_step_result,
696
+ :after_step,
697
+ :after_steps,
698
+ :after_background,
699
+ :before_feature_element,
700
+ :before_tags,
701
+ :after_tags,
702
+ :scenario_name,
703
+ :before_steps,
704
+ :before_step,
705
+ :before_step_result,
706
+ :step_name,
707
+ :after_step_result,
708
+ :after_step,
709
+ :after_steps,
710
+ :before_examples_array,
711
+ :before_examples,
712
+ :examples_name,
713
+ :before_outline_table,
714
+ :before_table_row,
715
+ :before_table_cell,
716
+ :table_cell_value,
717
+ :after_table_cell,
718
+ :after_table_row,
719
+ :before_table_row,
720
+ :before_table_cell,
721
+ :table_cell_value,
722
+ :after_table_cell,
723
+ :after_table_row,
724
+ :after_outline_table,
725
+ :after_examples,
726
+ :before_examples,
727
+ :examples_name,
728
+ :before_outline_table,
729
+ :before_table_row,
730
+ :before_table_cell,
731
+ :table_cell_value,
732
+ :after_table_cell,
733
+ :after_table_row,
734
+ :before_table_row,
735
+ :before_table_cell,
736
+ :table_cell_value,
737
+ :after_table_cell,
738
+ :after_table_row,
739
+ :after_outline_table,
740
+ :after_examples,
741
+ :after_examples_array,
742
+ :after_feature_element,
743
+ :after_feature,
744
+ :after_features,
745
+ ]
746
+ end
747
+
748
+ it 'a feature with a background with two steps' do
749
+ execute_gherkin do
750
+ feature do
751
+ background do
752
+ step 'passing'
753
+ step 'passing'
754
+ end
755
+ scenario do
756
+ step 'passing'
757
+ end
758
+ end
759
+ end
760
+ expect( formatter.legacy_messages ).to eq [
761
+ :before_features,
762
+ :before_feature,
763
+ :before_tags,
764
+ :after_tags,
765
+ :feature_name,
766
+ :before_background,
767
+ :background_name,
768
+ :before_steps,
769
+ :before_step,
770
+ :before_step_result,
771
+ :step_name,
772
+ :after_step_result,
773
+ :after_step,
774
+ :before_step,
775
+ :before_step_result,
776
+ :step_name,
777
+ :after_step_result,
778
+ :after_step,
779
+ :after_steps,
780
+ :after_background,
781
+ :before_feature_element,
782
+ :before_tags,
783
+ :after_tags,
784
+ :scenario_name,
785
+ :before_steps,
786
+ :before_step,
787
+ :before_step_result,
788
+ :step_name,
789
+ :after_step_result,
790
+ :after_step,
791
+ :after_steps,
792
+ :after_feature_element,
793
+ :after_feature,
794
+ :after_features,
795
+ ]
796
+ end
797
+
798
+ it 'a feature with a background' do
799
+ execute_gherkin do
800
+ feature do
801
+ background do
802
+ step 'passing'
803
+ end
804
+ scenario do
805
+ step 'passing'
806
+ end
807
+ end
808
+ end
809
+ expect( formatter.legacy_messages ).to eq [
810
+ :before_features,
811
+ :before_feature,
812
+ :before_tags,
813
+ :after_tags,
814
+ :feature_name,
815
+ :before_background,
816
+ :background_name,
817
+ :before_steps,
818
+ :before_step,
819
+ :before_step_result,
820
+ :step_name,
821
+ :after_step_result,
822
+ :after_step,
823
+ :after_steps,
824
+ :after_background,
825
+ :before_feature_element,
826
+ :before_tags,
827
+ :after_tags,
828
+ :scenario_name,
829
+ :before_steps,
830
+ :before_step,
831
+ :before_step_result,
832
+ :step_name,
833
+ :after_step_result,
834
+ :after_step,
835
+ :after_steps,
836
+ :after_feature_element,
837
+ :after_feature,
838
+ :after_features,
839
+ ]
840
+ end
841
+
842
+ it 'scenario outline' do
843
+ execute_gherkin do
844
+ feature do
845
+ scenario_outline do
846
+ step '<result>ing'
847
+ examples do
848
+ row 'result'
849
+ row 'pass'
850
+ end
851
+ end
852
+ end
853
+ end
854
+ expect( formatter.legacy_messages ).to eq [
855
+ :before_features,
856
+ :before_feature,
857
+ :before_tags,
858
+ :after_tags,
859
+ :feature_name,
860
+ :before_feature_element,
861
+ :before_tags,
862
+ :after_tags,
863
+ :scenario_name,
864
+ :before_steps,
865
+ :before_step,
866
+ :before_step_result,
867
+ :step_name,
868
+ :after_step_result,
869
+ :after_step,
870
+ :after_steps,
871
+ :before_examples_array,
872
+ :before_examples,
873
+ :examples_name,
874
+ :before_outline_table,
875
+ :before_table_row,
876
+ :before_table_cell,
877
+ :table_cell_value,
878
+ :after_table_cell,
879
+ :after_table_row,
880
+ :before_table_row,
881
+ :before_table_cell,
882
+ :table_cell_value,
883
+ :after_table_cell,
884
+ :after_table_row,
885
+ :after_outline_table,
886
+ :after_examples,
887
+ :after_examples_array,
888
+ :after_feature_element,
889
+ :after_feature,
890
+ :after_features,
891
+ ]
892
+ end
893
+
894
+ it 'scenario outline after scenario' do
895
+ execute_gherkin do
896
+ feature do
897
+ scenario do
898
+ step 'passing'
899
+ end
900
+ scenario_outline do
901
+ step '<result>ing'
902
+ examples do
903
+ row 'result'
904
+ row 'pass'
905
+ end
906
+ end
907
+ end
908
+ end
909
+ expect( formatter.legacy_messages ).to eq [
910
+ :before_features,
911
+ :before_feature,
912
+ :before_tags,
913
+ :after_tags,
914
+ :feature_name,
915
+ :before_feature_element,
916
+ :before_tags,
917
+ :after_tags,
918
+ :scenario_name,
919
+ :before_steps,
920
+ :before_step,
921
+ :before_step_result,
922
+ :step_name,
923
+ :after_step_result,
924
+ :after_step,
925
+ :after_steps,
926
+ :after_feature_element,
927
+ :before_feature_element,
928
+ :before_tags,
929
+ :after_tags,
930
+ :scenario_name,
931
+ :before_steps,
932
+ :before_step,
933
+ :before_step_result,
934
+ :step_name,
935
+ :after_step_result,
936
+ :after_step,
937
+ :after_steps,
938
+ :before_examples_array,
939
+ :before_examples,
940
+ :examples_name,
941
+ :before_outline_table,
942
+ :before_table_row,
943
+ :before_table_cell,
944
+ :table_cell_value,
945
+ :after_table_cell,
946
+ :after_table_row,
947
+ :before_table_row,
948
+ :before_table_cell,
949
+ :table_cell_value,
950
+ :after_table_cell,
951
+ :after_table_row,
952
+ :after_outline_table,
953
+ :after_examples,
954
+ :after_examples_array,
955
+ :after_feature_element,
956
+ :after_feature,
957
+ :after_features,
958
+ ]
959
+ end
960
+
961
+ it 'scenario outline before scenario' do
962
+ execute_gherkin do
963
+ feature do
964
+ scenario_outline do
965
+ step '<result>ing'
966
+ examples do
967
+ row 'result'
968
+ row 'pass'
969
+ end
970
+ end
971
+ scenario do
972
+ step 'passing'
973
+ end
974
+ end
975
+ end
976
+ expect( formatter.legacy_messages ).to eq [
977
+ :before_features,
978
+ :before_feature,
979
+ :before_tags,
980
+ :after_tags,
981
+ :feature_name,
982
+ :before_feature_element,
983
+ :before_tags,
984
+ :after_tags,
985
+ :scenario_name,
986
+ :before_steps,
987
+ :before_step,
988
+ :before_step_result,
989
+ :step_name,
990
+ :after_step_result,
991
+ :after_step,
992
+ :after_steps,
993
+ :before_examples_array,
994
+ :before_examples,
995
+ :examples_name,
996
+ :before_outline_table,
997
+ :before_table_row,
998
+ :before_table_cell,
999
+ :table_cell_value,
1000
+ :after_table_cell,
1001
+ :after_table_row,
1002
+ :before_table_row,
1003
+ :before_table_cell,
1004
+ :table_cell_value,
1005
+ :after_table_cell,
1006
+ :after_table_row,
1007
+ :after_outline_table,
1008
+ :after_examples,
1009
+ :after_examples_array,
1010
+ :after_feature_element,
1011
+ :before_feature_element,
1012
+ :before_tags,
1013
+ :after_tags,
1014
+ :scenario_name,
1015
+ :before_steps,
1016
+ :before_step,
1017
+ :before_step_result,
1018
+ :step_name,
1019
+ :after_step_result,
1020
+ :after_step,
1021
+ :after_steps,
1022
+ :after_feature_element,
1023
+ :after_feature,
1024
+ :after_features,
1025
+ ]
1026
+ end
1027
+
1028
+ it 'scenario outline two rows' do
1029
+ execute_gherkin do
1030
+ feature do
1031
+ scenario_outline do
1032
+ step '<result>ing'
1033
+ examples do
1034
+ row 'result'
1035
+ row 'pass'
1036
+ row 'pass'
1037
+ end
1038
+ end
1039
+ end
1040
+ end
1041
+ expect( formatter.legacy_messages ).to eq [
1042
+ :before_features,
1043
+ :before_feature,
1044
+ :before_tags,
1045
+ :after_tags,
1046
+ :feature_name,
1047
+ :before_feature_element,
1048
+ :before_tags,
1049
+ :after_tags,
1050
+ :scenario_name,
1051
+ :before_steps,
1052
+ :before_step,
1053
+ :before_step_result,
1054
+ :step_name,
1055
+ :after_step_result,
1056
+ :after_step,
1057
+ :after_steps,
1058
+ :before_examples_array,
1059
+ :before_examples,
1060
+ :examples_name,
1061
+ :before_outline_table,
1062
+ :before_table_row,
1063
+ :before_table_cell,
1064
+ :table_cell_value,
1065
+ :after_table_cell,
1066
+ :after_table_row,
1067
+ :before_table_row,
1068
+ :before_table_cell,
1069
+ :table_cell_value,
1070
+ :after_table_cell,
1071
+ :after_table_row,
1072
+ :before_table_row,
1073
+ :before_table_cell,
1074
+ :table_cell_value,
1075
+ :after_table_cell,
1076
+ :after_table_row,
1077
+ :after_outline_table,
1078
+ :after_examples,
1079
+ :after_examples_array,
1080
+ :after_feature_element,
1081
+ :after_feature,
1082
+ :after_features,
1083
+ ]
1084
+ end
1085
+
1086
+ it 'scenario outline two examples tables' do
1087
+ execute_gherkin do
1088
+ feature do
1089
+ scenario_outline do
1090
+ step '<result>ing'
1091
+ examples do
1092
+ row 'result'
1093
+ row 'pass'
1094
+ end
1095
+ examples do
1096
+ row 'result'
1097
+ row 'pass'
1098
+ end
1099
+ end
1100
+ end
1101
+ end
1102
+ expect( formatter.legacy_messages ).to eq [
1103
+ :before_features,
1104
+ :before_feature,
1105
+ :before_tags,
1106
+ :after_tags,
1107
+ :feature_name,
1108
+ :before_feature_element,
1109
+ :before_tags,
1110
+ :after_tags,
1111
+ :scenario_name,
1112
+ :before_steps,
1113
+ :before_step,
1114
+ :before_step_result,
1115
+ :step_name,
1116
+ :after_step_result,
1117
+ :after_step,
1118
+ :after_steps,
1119
+ :before_examples_array,
1120
+ :before_examples,
1121
+ :examples_name,
1122
+ :before_outline_table,
1123
+ :before_table_row,
1124
+ :before_table_cell,
1125
+ :table_cell_value,
1126
+ :after_table_cell,
1127
+ :after_table_row,
1128
+ :before_table_row,
1129
+ :before_table_cell,
1130
+ :table_cell_value,
1131
+ :after_table_cell,
1132
+ :after_table_row,
1133
+ :after_outline_table,
1134
+ :after_examples,
1135
+ :before_examples,
1136
+ :examples_name,
1137
+ :before_outline_table,
1138
+ :before_table_row,
1139
+ :before_table_cell,
1140
+ :table_cell_value,
1141
+ :after_table_cell,
1142
+ :after_table_row,
1143
+ :before_table_row,
1144
+ :before_table_cell,
1145
+ :table_cell_value,
1146
+ :after_table_cell,
1147
+ :after_table_row,
1148
+ :after_outline_table,
1149
+ :after_examples,
1150
+ :after_examples_array,
1151
+ :after_feature_element,
1152
+ :after_feature,
1153
+ :after_features,
1154
+ ]
1155
+ end
1156
+
1157
+ it 'two scenario outline' do
1158
+ execute_gherkin do
1159
+ feature do
1160
+ scenario_outline do
1161
+ step '<result>ing'
1162
+ examples do
1163
+ row 'result'
1164
+ row 'pass'
1165
+ end
1166
+ end
1167
+ scenario_outline do
1168
+ step '<result>ing'
1169
+ examples do
1170
+ row 'result'
1171
+ row 'pass'
1172
+ end
1173
+ end
1174
+ end
1175
+ end
1176
+ expect( formatter.legacy_messages ).to eq [
1177
+ :before_features,
1178
+ :before_feature,
1179
+ :before_tags,
1180
+ :after_tags,
1181
+ :feature_name,
1182
+ :before_feature_element,
1183
+ :before_tags,
1184
+ :after_tags,
1185
+ :scenario_name,
1186
+ :before_steps,
1187
+ :before_step,
1188
+ :before_step_result,
1189
+ :step_name,
1190
+ :after_step_result,
1191
+ :after_step,
1192
+ :after_steps,
1193
+ :before_examples_array,
1194
+ :before_examples,
1195
+ :examples_name,
1196
+ :before_outline_table,
1197
+ :before_table_row,
1198
+ :before_table_cell,
1199
+ :table_cell_value,
1200
+ :after_table_cell,
1201
+ :after_table_row,
1202
+ :before_table_row,
1203
+ :before_table_cell,
1204
+ :table_cell_value,
1205
+ :after_table_cell,
1206
+ :after_table_row,
1207
+ :after_outline_table,
1208
+ :after_examples,
1209
+ :after_examples_array,
1210
+ :after_feature_element,
1211
+ :before_feature_element,
1212
+ :before_tags,
1213
+ :after_tags,
1214
+ :scenario_name,
1215
+ :before_steps,
1216
+ :before_step,
1217
+ :before_step_result,
1218
+ :step_name,
1219
+ :after_step_result,
1220
+ :after_step,
1221
+ :after_steps,
1222
+ :before_examples_array,
1223
+ :before_examples,
1224
+ :examples_name,
1225
+ :before_outline_table,
1226
+ :before_table_row,
1227
+ :before_table_cell,
1228
+ :table_cell_value,
1229
+ :after_table_cell,
1230
+ :after_table_row,
1231
+ :before_table_row,
1232
+ :before_table_cell,
1233
+ :table_cell_value,
1234
+ :after_table_cell,
1235
+ :after_table_row,
1236
+ :after_outline_table,
1237
+ :after_examples,
1238
+ :after_examples_array,
1239
+ :after_feature_element,
1240
+ :after_feature,
1241
+ :after_features,
1242
+ ]
1243
+ end
1244
+
1245
+ it 'failing scenario outline' do
1246
+ execute_gherkin do
1247
+ feature do
1248
+ scenario_outline do
1249
+ step '<result>ing'
1250
+ examples do
1251
+ row 'result'
1252
+ row 'fail'
1253
+ end
1254
+ end
1255
+ end
1256
+ end
1257
+ expect( formatter.legacy_messages ).to eq [
1258
+ :before_features,
1259
+ :before_feature,
1260
+ :before_tags,
1261
+ :after_tags,
1262
+ :feature_name,
1263
+ :before_feature_element,
1264
+ :before_tags,
1265
+ :after_tags,
1266
+ :scenario_name,
1267
+ :before_steps,
1268
+ :before_step,
1269
+ :before_step_result,
1270
+ :step_name,
1271
+ :after_step_result,
1272
+ :after_step,
1273
+ :after_steps,
1274
+ :before_examples_array,
1275
+ :before_examples,
1276
+ :examples_name,
1277
+ :before_outline_table,
1278
+ :before_table_row,
1279
+ :before_table_cell,
1280
+ :table_cell_value,
1281
+ :after_table_cell,
1282
+ :after_table_row,
1283
+ :before_table_row,
1284
+ :before_table_cell,
1285
+ :table_cell_value,
1286
+ :after_table_cell,
1287
+ :after_table_row,
1288
+ :after_outline_table,
1289
+ :after_examples,
1290
+ :after_examples_array,
1291
+ :after_feature_element,
1292
+ :after_feature,
1293
+ :after_features,
1294
+ ]
1295
+ end
1296
+
1297
+ it 'a feature with a failing background and two scenarios' do
1298
+ execute_gherkin do
1299
+ feature do
1300
+ background do
1301
+ step 'failing'
1302
+ end
1303
+ scenario do
1304
+ step 'passing'
1305
+ end
1306
+ scenario do
1307
+ step 'passing'
1308
+ end
1309
+ end
1310
+ end
1311
+ expect( formatter.legacy_messages ).to eq [
1312
+ :before_features,
1313
+ :before_feature,
1314
+ :before_tags,
1315
+ :after_tags,
1316
+ :feature_name,
1317
+ :before_background,
1318
+ :background_name,
1319
+ :before_steps,
1320
+ :before_step,
1321
+ :before_step_result,
1322
+ :step_name,
1323
+ :exception,
1324
+ :after_step_result,
1325
+ :after_step,
1326
+ :after_steps,
1327
+ :after_background,
1328
+ :before_feature_element,
1329
+ :before_tags,
1330
+ :after_tags,
1331
+ :scenario_name,
1332
+ :before_steps,
1333
+ :before_step,
1334
+ :before_step_result,
1335
+ :step_name,
1336
+ :after_step_result,
1337
+ :after_step,
1338
+ :after_steps,
1339
+ :after_feature_element,
1340
+ :before_feature_element,
1341
+ :before_tags,
1342
+ :after_tags,
1343
+ :scenario_name,
1344
+ :before_steps,
1345
+ :before_step,
1346
+ :before_step_result,
1347
+ :step_name,
1348
+ :after_step_result,
1349
+ :after_step,
1350
+ :after_steps,
1351
+ :after_feature_element,
1352
+ :after_feature,
1353
+ :after_features,
1354
+ ]
1355
+ end
1356
+
1357
+ context 'in expand mode' do
1358
+ let(:runtime) { Runtime.new expand: true }
1359
+ let(:formatter) { MessageSpy.new }
1360
+
1361
+ it 'scenario outline two rows' do
1362
+ execute_gherkin do
1363
+ feature do
1364
+ scenario_outline do
1365
+ step '<result>ing'
1366
+ examples do
1367
+ row 'result'
1368
+ row 'pass'
1369
+ row 'pass'
1370
+ end
1371
+ end
1372
+ end
1373
+ end
1374
+ expect( formatter.legacy_messages ).to eq [
1375
+ :before_features,
1376
+ :before_feature,
1377
+ :before_tags,
1378
+ :after_tags,
1379
+ :feature_name,
1380
+ :before_feature_element,
1381
+ :before_tags,
1382
+ :after_tags,
1383
+ :scenario_name,
1384
+ :before_steps,
1385
+ :before_step,
1386
+ :before_step_result,
1387
+ :step_name,
1388
+ :after_step_result,
1389
+ :after_step,
1390
+ :after_steps,
1391
+ :before_examples_array,
1392
+ :before_examples,
1393
+ :examples_name,
1394
+ :before_outline_table,
1395
+ :scenario_name,
1396
+ :before_step,
1397
+ :before_step_result,
1398
+ :step_name,
1399
+ :after_step_result,
1400
+ :after_step,
1401
+ :scenario_name,
1402
+ :before_step,
1403
+ :before_step_result,
1404
+ :step_name,
1405
+ :after_step_result,
1406
+ :after_step,
1407
+ :after_outline_table,
1408
+ :after_examples,
1409
+ :after_examples_array,
1410
+ :after_feature_element,
1411
+ :after_feature,
1412
+ :after_features,
1413
+ ]
1414
+ end
1415
+ end
1416
+
1417
+ context 'with exception in after step hook' do
1418
+
1419
+ class CustomMappingsWithAfterStepHook < CustomMappings
1420
+ def test_step(test_step, mappings)
1421
+ super
1422
+ mappings.after { raise Failure }
1423
+ end
1424
+ end
1425
+
1426
+ let(:mappings) { CustomMappingsWithAfterStepHook.new }
1427
+
1428
+ it 'prints the exception within the step' do
1429
+ execute_gherkin do
1430
+ feature do
1431
+ scenario do
1432
+ step 'passing'
1433
+ end
1434
+ end
1435
+ end
1436
+ expect( formatter.legacy_messages ).to eq([
1437
+ :before_features,
1438
+ :before_feature,
1439
+ :before_tags,
1440
+ :after_tags,
1441
+ :feature_name,
1442
+ :before_feature_element,
1443
+ :before_tags,
1444
+ :after_tags,
1445
+ :scenario_name,
1446
+ :before_steps,
1447
+ :before_step,
1448
+ :before_step_result,
1449
+ :step_name,
1450
+ :after_step_result,
1451
+ :after_step,
1452
+ :exception,
1453
+ :after_steps,
1454
+ :after_feature_element,
1455
+ :after_feature,
1456
+ :after_features,
1457
+ ])
1458
+ end
1459
+ end
1460
+
1461
+ context 'with exception in a single before hook' do
1462
+ class CustomMappingsWithBeforeHook < CustomMappings
1463
+ def test_case(test_case, mappings)
1464
+ super
1465
+ mappings.before { raise Failure }
1466
+ end
1467
+ end
1468
+
1469
+ let(:mappings) { CustomMappingsWithBeforeHook.new }
1470
+
1471
+ it 'prints the exception after the scenario name' do
1472
+ execute_gherkin do
1473
+ feature do
1474
+ scenario do
1475
+ step 'passing'
1476
+ end
1477
+ end
1478
+ end
1479
+
1480
+ expect( formatter.legacy_messages ).to eq([
1481
+ :before_features,
1482
+ :before_feature,
1483
+ :before_tags,
1484
+ :after_tags,
1485
+ :feature_name,
1486
+ :before_feature_element,
1487
+ :before_tags,
1488
+ :after_tags,
1489
+ :scenario_name,
1490
+ :exception,
1491
+ :before_steps,
1492
+ :before_step,
1493
+ :before_step_result,
1494
+ :step_name,
1495
+ :after_step_result,
1496
+ :after_step,
1497
+ :after_steps,
1498
+ :after_feature_element,
1499
+ :after_feature,
1500
+ :after_features,
1501
+ ])
1502
+ end
1503
+
1504
+ it 'prints the exception after the background name' do
1505
+ mappings = Class.new(CustomMappings) {
1506
+ def test_case(test_case, mapper)
1507
+ mapper.before { raise Failure }
1508
+ end
1509
+ }.new
1510
+
1511
+ execute_gherkin(mappings) do
1512
+ feature do
1513
+ background do
1514
+ step 'passing'
1515
+ end
1516
+ scenario do
1517
+ step 'passing'
1518
+ end
1519
+ end
1520
+ end
1521
+
1522
+ expect( formatter.legacy_messages ).to eq([
1523
+ :before_features,
1524
+ :before_feature,
1525
+ :before_tags,
1526
+ :after_tags,
1527
+ :feature_name,
1528
+ :before_background,
1529
+ :background_name,
1530
+ :exception,
1531
+ :before_steps,
1532
+ :before_step,
1533
+ :before_step_result,
1534
+ :step_name,
1535
+ :after_step_result,
1536
+ :after_step,
1537
+ :after_steps,
1538
+ :after_background,
1539
+ :before_feature_element,
1540
+ :before_tags,
1541
+ :after_tags,
1542
+ :scenario_name,
1543
+ :before_steps,
1544
+ :before_step,
1545
+ :before_step_result,
1546
+ :step_name,
1547
+ :after_step_result,
1548
+ :after_step,
1549
+ :after_steps,
1550
+ :after_feature_element,
1551
+ :after_feature,
1552
+ :after_features,
1553
+ ])
1554
+ end
1555
+
1556
+
1557
+ it 'prints the exception before the examples table row' do
1558
+ mappings = Class.new(CustomMappings) {
1559
+ def test_case(test_case, mapper)
1560
+ mapper.before { raise Failure }
1561
+ end
1562
+ }.new
1563
+
1564
+ execute_gherkin(mappings) do
1565
+ feature do
1566
+ scenario_outline do
1567
+ step '<status>ing'
1568
+ examples do
1569
+ row 'status'
1570
+ row 'pass'
1571
+ end
1572
+ end
1573
+ end
1574
+ end
1575
+
1576
+ expect( formatter.legacy_messages ).to eq([
1577
+ :before_features,
1578
+ :before_feature,
1579
+ :before_tags,
1580
+ :after_tags,
1581
+ :feature_name,
1582
+ :before_feature_element,
1583
+ :before_tags,
1584
+ :after_tags,
1585
+ :scenario_name,
1586
+ :before_steps,
1587
+ :before_step,
1588
+ :before_step_result,
1589
+ :step_name,
1590
+ :after_step_result,
1591
+ :after_step,
1592
+ :after_steps,
1593
+ :before_examples_array,
1594
+ :before_examples,
1595
+ :examples_name,
1596
+ :before_outline_table,
1597
+ :before_table_row,
1598
+ :before_table_cell,
1599
+ :table_cell_value,
1600
+ :after_table_cell,
1601
+ :after_table_row,
1602
+ :exception,
1603
+ :before_table_row,
1604
+ :before_table_cell,
1605
+ :table_cell_value,
1606
+ :after_table_cell,
1607
+ :after_table_row,
1608
+ :after_outline_table,
1609
+ :after_examples,
1610
+ :after_examples_array,
1611
+ :after_feature_element,
1612
+ :after_feature,
1613
+ :after_features,
1614
+ ])
1615
+ end
1616
+ end
1617
+
1618
+ context 'with exception in the first of several before hooks' do
1619
+ # This proves that the second before hook's result doesn't overwrite
1620
+ # the result of the first one.
1621
+ it 'prints the exception after the scenario name' do
1622
+ mappings = Class.new(CustomMappings) {
1623
+ def test_case(test_case, mapper)
1624
+ mapper.before { raise Failure }
1625
+ mapper.before { }
1626
+ end
1627
+ }.new
1628
+
1629
+ execute_gherkin(mappings) do
1630
+ feature do
1631
+ scenario do
1632
+ step 'passing'
1633
+ end
1634
+ end
1635
+ end
1636
+
1637
+ expect( formatter.legacy_messages ).to eq([
1638
+ :before_features,
1639
+ :before_feature,
1640
+ :before_tags,
1641
+ :after_tags,
1642
+ :feature_name,
1643
+ :before_feature_element,
1644
+ :before_tags,
1645
+ :after_tags,
1646
+ :scenario_name,
1647
+ :exception,
1648
+ :before_steps,
1649
+ :before_step,
1650
+ :before_step_result,
1651
+ :step_name,
1652
+ :after_step_result,
1653
+ :after_step,
1654
+ :after_steps,
1655
+ :after_feature_element,
1656
+ :after_feature,
1657
+ :after_features,
1658
+ ])
1659
+ end
1660
+ end
1661
+
1662
+ context 'with exception in after hooks' do
1663
+ let(:mappings) do
1664
+ Class.new(CustomMappings) {
1665
+ def test_case(test_case, mapper)
1666
+ mapper.after { raise Failure }
1667
+ end
1668
+ }.new
1669
+ end
1670
+
1671
+ it 'prints the exception after the steps' do
1672
+
1673
+ execute_gherkin(mappings) do
1674
+ feature do
1675
+ scenario do
1676
+ step 'passing'
1677
+ end
1678
+ end
1679
+ end
1680
+
1681
+ expect( formatter.legacy_messages ).to eq([
1682
+ :before_features,
1683
+ :before_feature,
1684
+ :before_tags,
1685
+ :after_tags,
1686
+ :feature_name,
1687
+ :before_feature_element,
1688
+ :before_tags,
1689
+ :after_tags,
1690
+ :scenario_name,
1691
+ :before_steps,
1692
+ :before_step,
1693
+ :before_step_result,
1694
+ :step_name,
1695
+ :after_step_result,
1696
+ :after_step,
1697
+ :after_steps,
1698
+ :exception,
1699
+ :after_feature_element,
1700
+ :after_feature,
1701
+ :after_features,
1702
+ ])
1703
+ end
1704
+
1705
+ it 'prints the exception after the examples table row' do
1706
+ execute_gherkin do
1707
+ feature do
1708
+ scenario_outline do
1709
+ step '<status>ing'
1710
+ examples do
1711
+ row 'status'
1712
+ row 'pass'
1713
+ end
1714
+ end
1715
+ end
1716
+ end
1717
+
1718
+ expect( formatter.legacy_messages ).to eq([
1719
+ :before_features,
1720
+ :before_feature,
1721
+ :before_tags,
1722
+ :after_tags,
1723
+ :feature_name,
1724
+ :before_feature_element,
1725
+ :before_tags,
1726
+ :after_tags,
1727
+ :scenario_name,
1728
+ :before_steps,
1729
+ :before_step,
1730
+ :before_step_result,
1731
+ :step_name,
1732
+ :after_step_result,
1733
+ :after_step,
1734
+ :after_steps,
1735
+ :before_examples_array,
1736
+ :before_examples,
1737
+ :examples_name,
1738
+ :before_outline_table,
1739
+ :before_table_row,
1740
+ :before_table_cell,
1741
+ :table_cell_value,
1742
+ :after_table_cell,
1743
+ :after_table_row,
1744
+ :before_table_row,
1745
+ :before_table_cell,
1746
+ :table_cell_value,
1747
+ :after_table_cell,
1748
+ :after_table_row,
1749
+ :exception,
1750
+ :after_outline_table,
1751
+ :after_examples,
1752
+ :after_examples_array,
1753
+ :after_feature_element,
1754
+ :after_feature,
1755
+ :after_features,
1756
+ ])
1757
+ end
1758
+ end
1759
+
1760
+ context 'with exception in the first of several after hooks' do
1761
+ let(:mappings) do
1762
+ Class.new(CustomMappings) {
1763
+ def test_case(test_case, mapper)
1764
+ mapper.after { raise Failure }
1765
+ mapper.after { }
1766
+ end
1767
+ }.new
1768
+ end
1769
+
1770
+ it 'prints the exception after the steps' do
1771
+ execute_gherkin do
1772
+ feature do
1773
+ scenario do
1774
+ step 'passing'
1775
+ end
1776
+ end
1777
+ end
1778
+
1779
+ expect( formatter.legacy_messages ).to eq([
1780
+ :before_features,
1781
+ :before_feature,
1782
+ :before_tags,
1783
+ :after_tags,
1784
+ :feature_name,
1785
+ :before_feature_element,
1786
+ :before_tags,
1787
+ :after_tags,
1788
+ :scenario_name,
1789
+ :before_steps,
1790
+ :before_step,
1791
+ :before_step_result,
1792
+ :step_name,
1793
+ :after_step_result,
1794
+ :after_step,
1795
+ :after_steps,
1796
+ :exception,
1797
+ :after_feature_element,
1798
+ :after_feature,
1799
+ :after_features,
1800
+ ])
1801
+ end
1802
+ end
1803
+
1804
+ context 'with an exception in an after hook but no steps' do
1805
+ let(:mappings) do
1806
+ Class.new(CustomMappings) {
1807
+ def test_case(test_case, mapper)
1808
+ mapper.after { raise Failure }
1809
+ end
1810
+ }.new
1811
+ end
1812
+
1813
+ it 'prints the exception after the steps' do
1814
+ execute_gherkin do
1815
+ feature do
1816
+ scenario do
1817
+ end
1818
+ end
1819
+ end
1820
+
1821
+ expect( formatter.legacy_messages ).to eq([
1822
+ :before_features,
1823
+ :before_feature,
1824
+ :before_tags,
1825
+ :after_tags,
1826
+ :feature_name,
1827
+ :before_feature_element,
1828
+ :before_tags,
1829
+ :after_tags,
1830
+ :scenario_name,
1831
+ :exception,
1832
+ :after_feature_element,
1833
+ :after_feature,
1834
+ :after_features,
1835
+ ])
1836
+ end
1837
+ end
1838
+ end
1839
+
1840
+ it 'passes an object responding to failed? with the after_feature_element message' do
1841
+ expect( formatter ).to receive(:after_feature_element) do |scenario|
1842
+ expect( scenario ).to be_failed
1843
+ end
1844
+ execute_gherkin do
1845
+ feature do
1846
+ scenario do
1847
+ step 'failing'
1848
+ end
1849
+ end
1850
+ end
1851
+ end
1852
+
1853
+ context 'in strict mode' do
1854
+ let(:runtime) { Runtime.new strict: true }
1855
+
1856
+ it 'passes an exception to the formatter for undefined steps' do
1857
+ expect( formatter ).to receive(:exception) do |exception|
1858
+ expect( exception.message ).to eq %{Undefined step: "this step is undefined"}
1859
+ end
1860
+ execute_gherkin do
1861
+ feature do
1862
+ scenario do
1863
+ step 'this step is undefined'
1864
+ end
1865
+ end
1866
+ end
1867
+ end
1868
+ end
1869
+
1870
+ class MessageSpy
1871
+ attr_reader :messages
1872
+
1873
+ def initialize
1874
+ @messages = []
1875
+ end
1876
+
1877
+ def legacy_messages
1878
+ @messages - [
1879
+ :before_test_step,
1880
+ :before_test_case,
1881
+ :after_test_step,
1882
+ :after_test_case,
1883
+ :done
1884
+ ]
1885
+ end
1886
+
1887
+ def method_missing(message, *args)
1888
+ @messages << message
1889
+ end
1890
+
1891
+ def respond_to_missing?(name, include_private = false)
1892
+ true
1893
+ end
1894
+ end
1895
+
1896
+ def execute_gherkin(custom_mappings = mappings, &gherkin)
1897
+ execute [gherkin(&gherkin)], custom_mappings, report
1898
+ end
1899
+
1900
+ end
1901
+ end
1902
+ end