cucumber 2.0.0.beta.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/History.md +131 -32
  4. data/Rakefile +0 -2
  5. data/cucumber.gemspec +4 -3
  6. data/examples/i18n/ht/Rakefile +6 -0
  7. data/examples/i18n/ht/features/adisyon.feature +17 -0
  8. data/examples/i18n/ht/features/divizyon.feature +10 -0
  9. data/examples/i18n/ht/features/step_definitions/kalkilatris_steps.rb +25 -0
  10. data/examples/i18n/ht/lib/kalkilatris.rb +14 -0
  11. data/examples/tcl/features/step_definitions/fib_steps.rb +1 -1
  12. data/features/docs/cli/dry_run.feature +48 -0
  13. data/features/docs/cli/exclude_files.feature +1 -2
  14. data/features/docs/cli/run_specific_scenarios.feature +28 -66
  15. data/features/docs/cli/strict_mode.feature +24 -1
  16. data/features/docs/defining_steps/nested_steps.feature +49 -0
  17. data/features/docs/defining_steps/skip_scenario.feature +31 -2
  18. data/features/docs/defining_steps/snippets.feature +15 -0
  19. data/features/docs/exception_in_after_step_hook.feature +1 -1
  20. data/features/docs/exception_in_around_hook.feature +80 -0
  21. data/features/docs/extending_cucumber/custom_filter.feature +29 -0
  22. data/features/docs/extending_cucumber/custom_formatter.feature +65 -7
  23. data/features/docs/formatters/debug_formatter.feature +24 -17
  24. data/features/docs/formatters/json_formatter.feature +65 -1
  25. data/features/docs/formatters/junit_formatter.feature +40 -0
  26. data/features/docs/formatters/pretty_formatter.feature +42 -0
  27. data/features/docs/formatters/rerun_formatter.feature +3 -2
  28. data/features/docs/getting_started.feature +1 -1
  29. data/features/docs/{wire_protocol_erb.feature → wire_protocol/erb_configuration.feature} +2 -2
  30. data/features/docs/wire_protocol/handle_unexpected_response.feature +30 -0
  31. data/features/docs/wire_protocol/invoke_message.feature +216 -0
  32. data/features/docs/wire_protocol/readme.md +26 -0
  33. data/features/docs/wire_protocol/snippets_message.feature +51 -0
  34. data/features/docs/wire_protocol/step_matches_message.feature +81 -0
  35. data/features/docs/{wire_protocol_table_diffing.feature → wire_protocol/table_diffing.feature} +1 -0
  36. data/features/docs/{wire_protocol_tags.feature → wire_protocol/tags.feature} +1 -0
  37. data/features/docs/{wire_protocol_timeouts.feature → wire_protocol/timeouts.feature} +1 -0
  38. data/features/docs/work_in_progress.feature +1 -1
  39. data/features/docs/writing_support_code/after_hooks.feature +24 -0
  40. data/features/docs/writing_support_code/around_hooks.feature +31 -0
  41. data/features/docs/writing_support_code/before_hook.feature +7 -3
  42. data/features/docs/writing_support_code/tagged_hooks.feature +44 -6
  43. data/features/lib/step_definitions/wire_steps.rb +18 -1
  44. data/features/lib/support/fake_wire_server.rb +10 -7
  45. data/lib/cucumber/cli/configuration.rb +6 -11
  46. data/lib/cucumber/cli/main.rb +2 -2
  47. data/lib/cucumber/cli/options.rb +8 -1
  48. data/lib/cucumber/cli/profile_loader.rb +1 -1
  49. data/lib/cucumber/core_ext/instance_exec.rb +1 -1
  50. data/lib/cucumber/encoding.rb +5 -0
  51. data/lib/cucumber/errors.rb +8 -0
  52. data/lib/cucumber/file_specs.rb +3 -1
  53. data/lib/cucumber/filters/activate_steps.rb +33 -0
  54. data/lib/cucumber/filters/apply_after_hooks.rb +9 -0
  55. data/lib/cucumber/filters/apply_after_step_hooks.rb +12 -0
  56. data/lib/cucumber/filters/apply_around_hooks.rb +12 -0
  57. data/lib/cucumber/filters/apply_before_hooks.rb +9 -0
  58. data/lib/cucumber/{runtime → filters}/gated_receiver.rb +5 -1
  59. data/lib/cucumber/filters/prepare_world.rb +45 -0
  60. data/lib/cucumber/filters/quit.rb +28 -0
  61. data/lib/cucumber/filters/randomizer.rb +40 -0
  62. data/lib/cucumber/{runtime → filters}/tag_limits/test_case_index.rb +4 -2
  63. data/lib/cucumber/{runtime → filters}/tag_limits/verifier.rb +4 -2
  64. data/lib/cucumber/filters/tag_limits.rb +45 -0
  65. data/lib/cucumber/filters.rb +9 -0
  66. data/lib/cucumber/formatter/ansicolor.rb +0 -8
  67. data/lib/cucumber/formatter/console.rb +37 -20
  68. data/lib/cucumber/formatter/debug.rb +1 -8
  69. data/lib/cucumber/formatter/fanout.rb +27 -0
  70. data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +10 -9
  71. data/lib/cucumber/formatter/html.rb +31 -6
  72. data/lib/cucumber/formatter/ignore_missing_messages.rb +20 -0
  73. data/lib/cucumber/formatter/junit.rb +97 -2
  74. data/lib/cucumber/formatter/legacy_api/adapter.rb +1060 -0
  75. data/lib/cucumber/formatter/legacy_api/ast.rb +376 -0
  76. data/lib/cucumber/formatter/legacy_api/results.rb +51 -0
  77. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +30 -0
  78. data/lib/cucumber/formatter/pretty.rb +14 -0
  79. data/lib/cucumber/formatter/progress.rb +10 -0
  80. data/lib/cucumber/formatter/rerun.rb +14 -88
  81. data/lib/cucumber/hooks.rb +97 -0
  82. data/lib/cucumber/language_support/language_methods.rb +0 -54
  83. data/lib/cucumber/multiline_argument/data_table.rb +41 -29
  84. data/lib/cucumber/platform.rb +3 -3
  85. data/lib/cucumber/project_initializer.rb +43 -0
  86. data/lib/cucumber/rb_support/rb_hook.rb +2 -2
  87. data/lib/cucumber/rb_support/rb_step_definition.rb +11 -2
  88. data/lib/cucumber/rb_support/rb_transform.rb +3 -1
  89. data/lib/cucumber/rb_support/rb_world.rb +2 -2
  90. data/lib/cucumber/rb_support/snippet.rb +1 -1
  91. data/lib/cucumber/rspec/doubles.rb +1 -1
  92. data/lib/cucumber/running_test_case.rb +115 -0
  93. data/lib/cucumber/runtime/after_hooks.rb +24 -0
  94. data/lib/cucumber/runtime/before_hooks.rb +23 -0
  95. data/lib/cucumber/runtime/for_programming_languages.rb +4 -8
  96. data/lib/cucumber/runtime/step_hooks.rb +22 -0
  97. data/lib/cucumber/runtime/support_code.rb +70 -5
  98. data/lib/cucumber/runtime.rb +56 -112
  99. data/lib/cucumber/step_match.rb +26 -2
  100. data/lib/cucumber.rb +7 -3
  101. data/spec/cucumber/cli/configuration_spec.rb +16 -1
  102. data/spec/cucumber/cli/profile_loader_spec.rb +10 -0
  103. data/spec/cucumber/core_ext/instance_exec_spec.rb +4 -0
  104. data/spec/cucumber/file_specs_spec.rb +21 -2
  105. data/spec/cucumber/filters/activate_steps_spec.rb +57 -0
  106. data/spec/cucumber/{runtime → filters}/gated_receiver_spec.rb +3 -3
  107. data/spec/cucumber/{runtime → filters}/tag_limits/test_case_index_spec.rb +3 -3
  108. data/spec/cucumber/{runtime → filters}/tag_limits/verifier_spec.rb +4 -4
  109. data/spec/cucumber/{runtime/tag_limits/filter_spec.rb → filters/tag_limits_spec.rb} +6 -6
  110. data/spec/cucumber/formatter/debug_spec.rb +25 -530
  111. data/spec/cucumber/formatter/html_spec.rb +140 -0
  112. data/spec/cucumber/formatter/junit_spec.rb +212 -156
  113. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +2090 -0
  114. data/spec/cucumber/formatter/pretty_spec.rb +248 -2
  115. data/spec/cucumber/formatter/rerun_spec.rb +107 -0
  116. data/spec/cucumber/formatter/spec_helper.rb +17 -8
  117. data/spec/cucumber/hooks_spec.rb +30 -0
  118. data/spec/cucumber/multiline_argument/data_table_spec.rb +53 -47
  119. data/spec/cucumber/project_initializer_spec.rb +87 -0
  120. data/spec/cucumber/rb_support/rb_language_spec.rb +2 -2
  121. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +32 -7
  122. data/spec/cucumber/rb_support/rb_transform_spec.rb +20 -0
  123. data/spec/cucumber/rb_support/snippet_spec.rb +6 -6
  124. data/spec/cucumber/running_test_case_spec.rb +83 -0
  125. data/spec/cucumber/runtime_spec.rb +1 -5
  126. data/spec/spec_helper.rb +3 -4
  127. metadata +149 -107
  128. data/bin/cuke +0 -60
  129. data/features/docs/extending_cucumber/formatter_callbacks.feature +0 -370
  130. data/features/docs/output_from_hooks.feature +0 -128
  131. data/features/docs/report_called_undefined_steps.feature +0 -57
  132. data/features/docs/wire_protocol.feature +0 -337
  133. data/gem_tasks/yard/default/layout/html/bubble_32x32.png +0 -0
  134. data/gem_tasks/yard/default/layout/html/footer.erb +0 -5
  135. data/gem_tasks/yard/default/layout/html/index.erb +0 -1
  136. data/gem_tasks/yard/default/layout/html/layout.erb +0 -25
  137. data/gem_tasks/yard/default/layout/html/logo.erb +0 -1
  138. data/gem_tasks/yard/default/layout/html/setup.rb +0 -4
  139. data/gem_tasks/yard.rake +0 -43
  140. data/lib/cucumber/mappings.rb +0 -238
  141. data/lib/cucumber/reports/legacy_formatter.rb +0 -1349
  142. data/lib/cucumber/runtime/results.rb +0 -64
  143. data/lib/cucumber/runtime/tag_limits/filter.rb +0 -31
  144. data/lib/cucumber/runtime/tag_limits.rb +0 -15
  145. data/spec/cucumber/mappings_spec.rb +0 -180
  146. data/spec/cucumber/reports/legacy_formatter_spec.rb +0 -1860
  147. data/spec/cucumber/runtime/results_spec.rb +0 -88
@@ -21,6 +21,19 @@ module Cucumber
21
21
  run_defined_feature
22
22
  end
23
23
 
24
+ describe "with a scenario with no steps" do
25
+ define_feature <<-FEATURE
26
+ Feature: Banana party
27
+
28
+ Scenario: Monkey eats banana
29
+ FEATURE
30
+
31
+ it "outputs the scenario name" do
32
+ expect(@out.string).to include "Scenario: Monkey eats banana"
33
+ end
34
+ end
35
+
36
+
24
37
  describe "with a scenario" do
25
38
  define_feature <<-FEATURE
26
39
  Feature: Banana party
@@ -263,6 +276,96 @@ OUTPUT
263
276
  """
264
277
  bar
265
278
  """
279
+ OUTPUT
280
+ end
281
+ end
282
+
283
+ describe "with output from hooks" do
284
+ define_feature <<-FEATURE
285
+ Feature:
286
+ Scenario:
287
+ Given this step passes
288
+ Scenario Outline:
289
+ Given this step <status>
290
+ Examples:
291
+ | status |
292
+ | passes |
293
+ FEATURE
294
+
295
+ define_steps do
296
+ Before do
297
+ puts "Before hook"
298
+ end
299
+ AfterStep do
300
+ puts "AfterStep hook"
301
+ end
302
+ After do
303
+ puts "After hook"
304
+ end
305
+ Given(/^this step passes$/) {}
306
+ end
307
+
308
+ it "displays hook output appropriately " do
309
+ expect( @out.string ).to include <<OUTPUT
310
+ Feature:
311
+
312
+ Scenario:
313
+ Before hook
314
+ Given this step passes
315
+ AfterStep hook
316
+ After hook
317
+
318
+ Scenario Outline:
319
+ Given this step <status>
320
+
321
+ Examples:
322
+ | status |
323
+ | passes | Before hook, AfterStep hook, After hook
324
+
325
+ 2 scenarios (2 passed)
326
+ 2 steps (2 passed)
327
+ OUTPUT
328
+ end
329
+ end
330
+
331
+ describe "with background and output from hooks" do
332
+ define_feature <<-FEATURE
333
+ Feature:
334
+ Background:
335
+ Given this step passes
336
+ Scenario:
337
+ Given this step passes
338
+ FEATURE
339
+
340
+ define_steps do
341
+ Before do
342
+ puts "Before hook"
343
+ end
344
+ AfterStep do
345
+ puts "AfterStep hook"
346
+ end
347
+ After do
348
+ puts "After hook"
349
+ end
350
+ Given(/^this step passes$/) {}
351
+ end
352
+
353
+ it "displays hook output appropriately " do
354
+ expect( @out.string ).to include <<OUTPUT
355
+ Feature:
356
+
357
+ Background:
358
+ Before hook
359
+ Given this step passes
360
+ AfterStep hook
361
+
362
+ Scenario:
363
+ Given this step passes
364
+ AfterStep hook
365
+ After hook
366
+
367
+ 1 scenario (1 passed)
368
+ 2 steps (2 passed)
266
369
  OUTPUT
267
370
  end
268
371
  end
@@ -444,7 +547,6 @@ OUTPUT
444
547
 
445
548
  context "In --expand mode" do
446
549
  let(:runtime) { Runtime.new({:expand => true})}
447
- let(:mappings) { Mappings.new(runtime) }
448
550
  before(:each) do
449
551
  Cucumber::Term::ANSIColor.coloring = false
450
552
  @out = StringIO.new
@@ -491,12 +593,49 @@ OUTPUT
491
593
  end
492
594
  end
493
595
  end
596
+
597
+ describe "with a scenario outline in en-lol" do
598
+ define_feature <<-FEATURE
599
+ # language: en-lol
600
+ OH HAI: STUFFING
601
+
602
+ MISHUN SRSLY: CUCUMBR
603
+ I CAN HAZ IN TEH BEGINNIN <BEGINNIN> CUCUMBRZ
604
+ WEN I EAT <EAT> CUCUMBRZ
605
+ DEN I HAS <EAT> CUCUMBERZ IN MAH BELLY
606
+ AN IN TEH END <KTHXBAI> CUCUMBRZ KTHXBAI
607
+
608
+ EXAMPLZ:
609
+ | BEGINNIN | EAT | KTHXBAI |
610
+ | 3 | 2 | 1 |
611
+ FEATURE
612
+
613
+ it "outputs localized text" do
614
+ lines = <<-OUTPUT
615
+ OH HAI: STUFFING
616
+
617
+ MISHUN SRSLY: CUCUMBR
618
+ I CAN HAZ IN TEH BEGINNIN <BEGINNIN> CUCUMBRZ
619
+ WEN I EAT <EAT> CUCUMBRZ
620
+ DEN I HAS <EAT> CUCUMBERZ IN MAH BELLY
621
+ AN IN TEH END <KTHXBAI> CUCUMBRZ KTHXBAI
622
+ EXAMPLZ:
623
+ MISHUN: | 3 | 2 | 1 |
624
+ I CAN HAZ IN TEH BEGINNIN 3 CUCUMBRZ
625
+ WEN I EAT 2 CUCUMBRZ
626
+ DEN I HAS 2 CUCUMBERZ IN MAH BELLY
627
+ AN IN TEH END 1 CUCUMBRZ KTHXBAI
628
+ OUTPUT
629
+ lines.split("\n").each do |line|
630
+ expect(@out.string).to include line.strip
631
+ end
632
+ end
633
+ end
494
634
  end
495
635
  end
496
636
 
497
637
  context "In --expand mode with --source as an option" do
498
638
  let(:runtime) { Runtime.new({:expand => true})}
499
- let(:mappings) { Mappings.new(runtime) }
500
639
  before(:each) do
501
640
  Cucumber::Term::ANSIColor.coloring = false
502
641
  @out = StringIO.new
@@ -572,6 +711,113 @@ OUTPUT
572
711
  end
573
712
  end
574
713
  end
714
+
715
+ context "snippets contain relevant keyword replacements" do
716
+
717
+ before(:each) do
718
+ Cucumber::Term::ANSIColor.coloring = false
719
+ @out = StringIO.new
720
+ @formatter = Pretty.new(runtime, @out, {snippets: true})
721
+ run_defined_feature
722
+ end
723
+
724
+ describe "With a scenario that has undefined steps" do
725
+ define_feature <<-FEATURE
726
+ Feature: Banana party
727
+
728
+ Scenario: many monkeys eat many things
729
+ Given there are bananas and apples
730
+ And other monkeys are around
731
+ When one monkey eats a banana
732
+ And the other monkeys eat all the apples
733
+ Then bananas remain
734
+ But there are no apples left
735
+ FEATURE
736
+
737
+ it "containes snippets with 'And' or 'But' replaced by previous step name" do
738
+ expect(@out.string).to include("Given(/^there are bananas and apples$/)")
739
+ expect(@out.string).to include("Given(/^other monkeys are around$/)")
740
+ expect(@out.string).to include("When(/^one monkey eats a banana$/)")
741
+ expect(@out.string).to include("When(/^the other monkeys eat all the apples$/)")
742
+ expect(@out.string).to include("Then(/^bananas remain$/)")
743
+ expect(@out.string).to include("Then(/^there are no apples left$/)")
744
+ end
745
+ end
746
+
747
+ describe "With a scenario that uses * and 'But'" do
748
+ define_feature <<-FEATURE
749
+ Feature: Banana party
750
+
751
+ Scenario: many monkeys eat many things
752
+ * there are bananas and apples
753
+ * other monkeys are around
754
+ When one monkey eats a banana
755
+ * the other monkeys eat all the apples
756
+ Then bananas remain
757
+ * there are no apples left
758
+ FEATURE
759
+ it "replaces the first step with 'Given'" do
760
+ expect(@out.string).to include("Given(/^there are bananas and apples$/)")
761
+ end
762
+ it "uses actual keywords as the 'previous' keyword for future replacements" do
763
+ expect(@out.string).to include("Given(/^other monkeys are around$/)")
764
+ expect(@out.string).to include("When(/^the other monkeys eat all the apples$/)")
765
+ expect(@out.string).to include("Then(/^there are no apples left$/)")
766
+ end
767
+ end
768
+
769
+ describe "With a scenario where the only undefined step uses 'And'" do
770
+ define_feature <<-FEATURE
771
+ Feature:
772
+
773
+ Scenario:
774
+ Given this step passes
775
+ Then this step passes
776
+ And this step is undefined
777
+ FEATURE
778
+ define_steps do
779
+ Given(/^this step passes$/) {}
780
+ end
781
+ it "uses actual keyword of the previous passing step for the undefined step" do
782
+ expect(@out.string).to include("Then(/^this step is undefined$/)")
783
+ end
784
+ end
785
+
786
+ describe "With scenarios where the first step is undefined and uses '*'" do
787
+ define_feature <<-FEATURE
788
+ Feature:
789
+
790
+ Scenario:
791
+ * this step is undefined
792
+ Then this step passes
793
+
794
+ Scenario:
795
+ * this step is also undefined
796
+ Then this step passes
797
+ FEATURE
798
+ define_steps do
799
+ Given(/^this step passes$/) {}
800
+ end
801
+ it "uses 'Given' as actual keyword the step in each scenario" do
802
+ expect(@out.string).to include("Given(/^this step is undefined$/)")
803
+ expect(@out.string).to include("Given(/^this step is also undefined$/)")
804
+ end
805
+ end
806
+
807
+ describe "with a scenario in en-lol" do
808
+ define_feature <<-FEATURE
809
+ # language: en-lol
810
+ OH HAI: STUFFING
811
+
812
+ MISHUN: CUCUMBR
813
+ I CAN HAZ IN TEH BEGINNIN CUCUMBRZ
814
+ AN I EAT CUCUMBRZ
815
+ FEATURE
816
+ it "uses actual keyword of the previous passing step for the undefined step" do
817
+ expect(@out.string).to include("ICANHAZ(/^I EAT CUCUMBRZ$/)")
818
+ end
819
+ end
820
+ end
575
821
  end
576
822
  end
577
823
  end
@@ -0,0 +1,107 @@
1
+ require 'cucumber/formatter/rerun'
2
+ require 'cucumber/core'
3
+ require 'cucumber/core/gherkin/writer'
4
+ require 'cucumber/core/filter'
5
+
6
+ module Cucumber::Formatter
7
+ describe Rerun do
8
+ include Cucumber::Core::Gherkin::Writer
9
+ include Cucumber::Core
10
+
11
+ # after_test_case
12
+ context 'when 2 scenarios fail in the same file' do
13
+ class WithSteps < Cucumber::Core::Filter.new
14
+ def test_case(test_case)
15
+ test_steps = test_case.test_steps.map do |step|
16
+ case step.name
17
+ when /fail/
18
+ step.with_action { raise Failure }
19
+ when /pass/
20
+ step.with_action {}
21
+ else
22
+ step
23
+ end
24
+ end
25
+
26
+ test_case.with_steps(test_steps).describe_to(receiver)
27
+ end
28
+ end
29
+
30
+ it 'Prints the locations of the failed scenarios' do
31
+ gherkin = gherkin('foo.feature') do
32
+ feature do
33
+ scenario do
34
+ step 'failing'
35
+ end
36
+
37
+ scenario do
38
+ step 'failing'
39
+ end
40
+
41
+ scenario do
42
+ step 'passing'
43
+ end
44
+ end
45
+ end
46
+ io = StringIO.new
47
+ report = Rerun.new(double, io, double)
48
+
49
+ execute [gherkin], report, [WithSteps.new]
50
+
51
+ expect( io.string ).to eq 'foo.feature:3:6'
52
+ end
53
+ end
54
+
55
+ context 'with failures in multiple files' do
56
+ it 'prints the location of the failed scenarios in each file' do
57
+ foo = gherkin('foo.feature') do
58
+ feature do
59
+ scenario do
60
+ step 'failing'
61
+ end
62
+
63
+ scenario do
64
+ step 'failing'
65
+ end
66
+
67
+ scenario do
68
+ step 'passing'
69
+ end
70
+ end
71
+ end
72
+
73
+ bar = gherkin('bar.feature') do
74
+ feature do
75
+ scenario do
76
+ step 'failing'
77
+ end
78
+ end
79
+ end
80
+
81
+ io = StringIO.new
82
+ report = Rerun.new(double, io, double)
83
+
84
+ execute [foo, bar], report, [WithSteps.new]
85
+
86
+ expect(io.string).to eq 'foo.feature:3:6 bar.feature:3'
87
+ end
88
+ end
89
+
90
+ context 'when there are no failing scenarios' do
91
+ it 'prints nothing' do
92
+ gherkin = gherkin('foo.feature') do
93
+ feature do
94
+ scenario do
95
+ step 'passing'
96
+ end
97
+ end
98
+ end
99
+
100
+ io = StringIO.new
101
+ report = Rerun.new(double, io, double)
102
+
103
+ execute [gherkin], report, [WithSteps.new]
104
+ end
105
+ end
106
+ end
107
+ end
@@ -20,17 +20,26 @@ module Cucumber
20
20
  def run_defined_feature
21
21
  define_steps
22
22
  runtime.visitor = report
23
- execute [gherkin_doc], mappings, report
24
- end
25
23
 
26
- require 'cucumber/mappings'
27
- def mappings
28
- @mappings ||= Mappings.new
24
+ receiver = Test::Runner.new(report)
25
+ filters = [
26
+ Filters::ActivateSteps.new(runtime.support_code),
27
+ Filters::ApplyAfterStepHooks.new(runtime.support_code),
28
+ Filters::ApplyBeforeHooks.new(runtime.support_code),
29
+ Filters::ApplyAfterHooks.new(runtime.support_code),
30
+ Filters::ApplyAroundHooks.new(runtime.support_code),
31
+ Filters::PrepareWorld.new(runtime)
32
+ ]
33
+ compile [gherkin_doc], receiver, filters
29
34
  end
30
35
 
31
- require 'cucumber/reports/legacy_formatter'
36
+ require 'cucumber/formatter/legacy_api/adapter'
32
37
  def report
33
- @report ||= Cucumber::Reports::LegacyFormatter.new runtime, [@formatter]
38
+ @report ||= LegacyApi::Adapter.new(
39
+ Fanout.new([@formatter]),
40
+ runtime.results,
41
+ runtime.support_code,
42
+ runtime.configuration)
34
43
  end
35
44
 
36
45
  require 'cucumber/core/gherkin/document'
@@ -43,7 +52,7 @@ module Cucumber
43
52
  end
44
53
 
45
54
  def runtime
46
- mappings.runtime
55
+ @runtime ||= Runtime.new
47
56
  end
48
57
 
49
58
  def define_steps
@@ -0,0 +1,30 @@
1
+ require 'cucumber/hooks'
2
+ module Cucumber::Hooks
3
+ shared_examples_for 'a source node' do
4
+ it "responds to name" do
5
+ expect( subject.name ).to be_a(String)
6
+ end
7
+
8
+ it "responds to location" do
9
+ expect( subject.location ).to eq(location)
10
+ end
11
+
12
+ it "responds to match_locations?" do
13
+ expect( subject.match_locations? [location] ).to be_truthy
14
+ expect( subject.match_locations? [] ).to be_falsey
15
+ end
16
+ end
17
+
18
+ require 'cucumber/core/ast/location'
19
+ describe BeforeHook do
20
+ subject { BeforeHook.new(location) }
21
+ let(:location) { Cucumber::Core::Ast::Location.new('hooks.rb', 1) }
22
+ it_behaves_like 'a source node'
23
+ end
24
+
25
+ describe AfterHook do
26
+ subject { AfterHook.new(location) }
27
+ let(:location) { Cucumber::Core::Ast::Location.new('hooks.rb', 1) }
28
+ it_behaves_like 'a source node'
29
+ end
30
+ end