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