cucumber 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/Gemfile +3 -1
- data/History.md +18 -2
- data/README.md +5 -1
- data/cucumber.gemspec +3 -4
- data/cucumber.yml +2 -2
- data/features/docs/api/run_cli_main_with_existing_runtime.feature +4 -7
- data/features/docs/defining_steps/skip_scenario.feature +6 -2
- data/features/docs/formatters/api_methods.feature +36 -0
- data/features/docs/profiles.feature +2 -2
- data/features/lib/step_definitions/profile_steps.rb +1 -1
- data/lib/cucumber.rb +11 -4
- data/lib/cucumber/cli/configuration.rb +2 -2
- data/lib/cucumber/cli/options.rb +2 -2
- data/lib/cucumber/configuration.rb +25 -3
- data/lib/cucumber/deprecate.rb +29 -0
- data/lib/cucumber/filters/activate_steps.rb +39 -5
- data/lib/cucumber/formatter/console.rb +4 -4
- data/lib/cucumber/formatter/io.rb +1 -1
- data/lib/cucumber/formatter/legacy_api/adapter.rb +30 -30
- data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +4 -9
- data/lib/cucumber/platform.rb +2 -7
- data/lib/cucumber/rb_support/rb_language.rb +72 -26
- data/lib/cucumber/rb_support/rb_step_definition.rb +2 -2
- data/lib/cucumber/rb_support/rb_world.rb +6 -1
- data/lib/cucumber/rb_support/snippet.rb +21 -0
- data/lib/cucumber/running_test_case.rb +5 -1
- data/lib/cucumber/runtime.rb +11 -15
- data/lib/cucumber/runtime/support_code.rb +20 -128
- data/lib/cucumber/step_argument.rb +25 -0
- data/lib/cucumber/step_match.rb +6 -12
- data/lib/cucumber/step_match_search.rb +67 -0
- data/lib/cucumber/version +1 -0
- data/spec/cucumber/configuration_spec.rb +3 -2
- data/spec/cucumber/filters/activate_steps_spec.rb +95 -3
- data/spec/cucumber/formatter/html_spec.rb +1 -1
- data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +55 -28
- data/spec/cucumber/formatter/pretty_spec.rb +2 -2
- data/spec/cucumber/formatter/spec_helper.rb +22 -12
- data/spec/cucumber/rb_support/rb_language_spec.rb +9 -45
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +2 -2
- data/spec/cucumber/rb_support/rb_world_spec.rb +47 -0
- data/spec/cucumber/runtime/for_programming_languages_spec.rb +1 -1
- data/spec/cucumber/runtime/support_code_spec.rb +4 -111
- data/spec/cucumber/step_argument_spec.rb +18 -0
- data/spec/cucumber/step_match_search_spec.rb +122 -0
- data/spec/cucumber/step_match_spec.rb +8 -2
- data/spec/cucumber/world/pending_spec.rb +2 -1
- data/spec/cucumber_spec.rb +39 -0
- metadata +45 -50
- data/features/docs/wire_protocol/erb_configuration.feature +0 -56
- data/features/docs/wire_protocol/handle_unexpected_response.feature +0 -30
- data/features/docs/wire_protocol/invoke_message.feature +0 -216
- data/features/docs/wire_protocol/readme.md +0 -26
- data/features/docs/wire_protocol/snippets_message.feature +0 -51
- data/features/docs/wire_protocol/step_matches_message.feature +0 -81
- data/features/docs/wire_protocol/table_diffing.feature +0 -126
- data/features/docs/wire_protocol/tags.feature +0 -87
- data/features/docs/wire_protocol/timeouts.feature +0 -64
- data/lib/cucumber/events/bus.rb +0 -86
- data/lib/cucumber/gherkin/formatter/argument.rb +0 -17
- data/lib/cucumber/gherkin/formatter/hashable.rb +0 -27
- data/lib/cucumber/language_support.rb +0 -30
- data/lib/cucumber/language_support/language_methods.rb +0 -72
- data/lib/cucumber/rb_support/regexp_argument_matcher.rb +0 -21
- data/lib/cucumber/wire_support/configuration.rb +0 -38
- data/lib/cucumber/wire_support/connection.rb +0 -61
- data/lib/cucumber/wire_support/request_handler.rb +0 -32
- data/lib/cucumber/wire_support/wire_exception.rb +0 -32
- data/lib/cucumber/wire_support/wire_language.rb +0 -68
- data/lib/cucumber/wire_support/wire_packet.rb +0 -34
- data/lib/cucumber/wire_support/wire_protocol.rb +0 -43
- data/lib/cucumber/wire_support/wire_protocol/requests.rb +0 -133
- data/lib/cucumber/wire_support/wire_step_definition.rb +0 -21
- data/spec/cucumber/events/bus_spec.rb +0 -94
- data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +0 -22
- data/spec/cucumber/wire_support/configuration_spec.rb +0 -64
- data/spec/cucumber/wire_support/connection_spec.rb +0 -64
- data/spec/cucumber/wire_support/wire_exception_spec.rb +0 -50
- data/spec/cucumber/wire_support/wire_language_spec.rb +0 -46
- data/spec/cucumber/wire_support/wire_packet_spec.rb +0 -44
@@ -0,0 +1 @@
|
|
1
|
+
2.2.0
|
@@ -136,8 +136,9 @@ module Cucumber
|
|
136
136
|
|
137
137
|
describe "#with_options" do
|
138
138
|
it "returns a copy of the configuration with new options" do
|
139
|
-
|
140
|
-
|
139
|
+
old_out_stream = double('Old out_stream')
|
140
|
+
new_out_stream = double('New out_stream')
|
141
|
+
config = Configuration.new(out_stream: old_out_stream).with_options(out_stream: new_out_stream)
|
141
142
|
expect(config.out_stream).to eq new_out_stream
|
142
143
|
end
|
143
144
|
end
|
@@ -6,10 +6,12 @@ describe Cucumber::Filters::ActivateSteps do
|
|
6
6
|
include Cucumber::Core::Gherkin::Writer
|
7
7
|
include Cucumber::Core
|
8
8
|
|
9
|
-
let(:step_definitions) { double(find_match: step_match) }
|
10
9
|
let(:step_match) { double(activate: activated_test_step) }
|
11
10
|
let(:activated_test_step) { double }
|
12
11
|
let(:receiver) { double.as_null_object }
|
12
|
+
let(:filter) { Cucumber::Filters::ActivateSteps.new(step_match_search, configuration) }
|
13
|
+
let(:step_match_search) { Proc.new { [step_match] } }
|
14
|
+
let(:configuration) { double(dry_run?: false, notify: nil) }
|
13
15
|
|
14
16
|
context "a scenario with a single step" do
|
15
17
|
let(:doc) do
|
@@ -26,7 +28,15 @@ describe Cucumber::Filters::ActivateSteps do
|
|
26
28
|
expect(step_match).to receive(:activate) do |test_step|
|
27
29
|
expect(test_step.name).to eq 'a passing step'
|
28
30
|
end
|
29
|
-
compile [doc], receiver, [
|
31
|
+
compile [doc], receiver, [filter]
|
32
|
+
end
|
33
|
+
|
34
|
+
it "notifies with a StepMatch event" do
|
35
|
+
expect(configuration).to receive(:notify) do |event|
|
36
|
+
expect(event.test_step.name).to eq 'a passing step'
|
37
|
+
expect(event.step_match).to eq step_match
|
38
|
+
end
|
39
|
+
compile [doc], receiver, [filter]
|
30
40
|
end
|
31
41
|
end
|
32
42
|
|
@@ -50,7 +60,89 @@ describe Cucumber::Filters::ActivateSteps do
|
|
50
60
|
expect(step_match).to receive(:activate) do |test_step|
|
51
61
|
expect(test_step.name).to eq 'a passing step'
|
52
62
|
end
|
53
|
-
compile [doc], receiver, [
|
63
|
+
compile [doc], receiver, [filter]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "undefined step" do
|
68
|
+
let(:step_match_search) { Proc.new { [] } }
|
69
|
+
|
70
|
+
let(:doc) do
|
71
|
+
gherkin do
|
72
|
+
feature do
|
73
|
+
scenario do
|
74
|
+
step 'an undefined step'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it "does not activate the step" do
|
81
|
+
expect(receiver).to receive(:test_case) do |test_case|
|
82
|
+
expect(test_case.test_steps[0].execute).to be_undefined
|
83
|
+
end
|
84
|
+
compile [doc], receiver, [filter]
|
85
|
+
end
|
86
|
+
|
87
|
+
it "does not notify" do
|
88
|
+
expect(configuration).not_to receive(:notify)
|
89
|
+
compile [doc], receiver, [filter]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "dry run" do
|
94
|
+
let(:configuration) { double(dry_run?: true, notify: nil) }
|
95
|
+
|
96
|
+
let(:doc) do
|
97
|
+
gherkin do
|
98
|
+
feature do
|
99
|
+
scenario do
|
100
|
+
step 'a passing step'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it "activates each step with a skipping action" do
|
107
|
+
expect(receiver).to receive(:test_case) do |test_case|
|
108
|
+
expect(test_case.test_steps[0].execute).to be_skipped
|
109
|
+
end
|
110
|
+
compile [doc], receiver, [filter]
|
111
|
+
end
|
112
|
+
|
113
|
+
it "notifies with a StepMatch event" do
|
114
|
+
expect(configuration).to receive(:notify) do |event|
|
115
|
+
expect(event.test_step.name).to eq 'a passing step'
|
116
|
+
expect(event.step_match).to eq step_match
|
117
|
+
end
|
118
|
+
compile [doc], receiver, [filter]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context "undefined step in a dry run" do
|
123
|
+
let(:step_match_search) { Proc.new { [] } }
|
124
|
+
let(:configuration) { double(dry_run?: true, notify: nil) }
|
125
|
+
|
126
|
+
let(:doc) do
|
127
|
+
gherkin do
|
128
|
+
feature do
|
129
|
+
scenario do
|
130
|
+
step 'an undefined step'
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
it "does not activate the step" do
|
137
|
+
expect(receiver).to receive(:test_case) do |test_case|
|
138
|
+
expect(test_case.test_steps[0].execute).to be_undefined
|
139
|
+
end
|
140
|
+
compile [doc], receiver, [filter]
|
141
|
+
end
|
142
|
+
|
143
|
+
it "does not notify" do
|
144
|
+
expect(configuration).not_to receive(:notify)
|
145
|
+
compile [doc], receiver, [filter]
|
54
146
|
end
|
55
147
|
end
|
56
148
|
|
@@ -486,7 +486,7 @@ module Cucumber
|
|
486
486
|
end
|
487
487
|
end
|
488
488
|
context "in --expand mode" do
|
489
|
-
let(:
|
489
|
+
let(:options) { { expand: true } }
|
490
490
|
before(:each) do
|
491
491
|
@out = StringIO.new
|
492
492
|
@formatter = Html.new(runtime, @out, {:expand => true})
|
@@ -5,6 +5,7 @@ require 'cucumber/runtime/step_hooks'
|
|
5
5
|
require 'cucumber/runtime/before_hooks'
|
6
6
|
require 'cucumber/runtime/after_hooks'
|
7
7
|
require 'cucumber/filters'
|
8
|
+
require 'spec_helper'
|
8
9
|
|
9
10
|
module Cucumber
|
10
11
|
module Formatter::LegacyApi
|
@@ -12,9 +13,10 @@ module Cucumber
|
|
12
13
|
include Core::Gherkin::Writer
|
13
14
|
include Core
|
14
15
|
|
15
|
-
let(:report) { Adapter.new(formatter, runtime.results, runtime.
|
16
|
+
let(:report) { Adapter.new(formatter, runtime.results, runtime.configuration) }
|
16
17
|
let(:formatter) { double('formatter').as_null_object }
|
17
18
|
let(:runtime) { Runtime.new }
|
19
|
+
let(:step_match_search) { SimpleStepDefinitionSearch.new }
|
18
20
|
|
19
21
|
Failure = Class.new(StandardError)
|
20
22
|
|
@@ -28,17 +30,17 @@ module Cucumber
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
|
-
class
|
32
|
-
def
|
33
|
-
if
|
34
|
-
return SimpleStepMatch.new {}
|
33
|
+
class SimpleStepDefinitionSearch
|
34
|
+
def call(name)
|
35
|
+
if name =~ /pass/
|
36
|
+
return [SimpleStepMatch.new {}]
|
35
37
|
end
|
36
38
|
|
37
|
-
if
|
38
|
-
return SimpleStepMatch.new { raise Failure }
|
39
|
+
if name =~ /fail/
|
40
|
+
return [SimpleStepMatch.new { raise Failure }]
|
39
41
|
end
|
40
42
|
|
41
|
-
|
43
|
+
[]
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
@@ -1545,7 +1547,7 @@ module Cucumber
|
|
1545
1547
|
|
1546
1548
|
it 'prints the exception within the step' do
|
1547
1549
|
filters = [
|
1548
|
-
Filters::ActivateSteps.new(
|
1550
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
1549
1551
|
Filters::ApplyAfterStepHooks.new(FailingAfterStepHook.new),
|
1550
1552
|
AddBeforeAndAfterHooks.new
|
1551
1553
|
]
|
@@ -1591,7 +1593,7 @@ module Cucumber
|
|
1591
1593
|
|
1592
1594
|
it 'prints the exception after the scenario name' do
|
1593
1595
|
filters = [
|
1594
|
-
Filters::ActivateSteps.new(
|
1596
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
1595
1597
|
Filters::ApplyBeforeHooks.new(FailingBeforeHook.new),
|
1596
1598
|
AddBeforeAndAfterHooks.new
|
1597
1599
|
]
|
@@ -1629,7 +1631,7 @@ module Cucumber
|
|
1629
1631
|
|
1630
1632
|
it 'prints the exception after the background name' do
|
1631
1633
|
filters = [
|
1632
|
-
Filters::ActivateSteps.new(
|
1634
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
1633
1635
|
Filters::ApplyBeforeHooks.new(FailingBeforeHook.new),
|
1634
1636
|
AddBeforeAndAfterHooks.new
|
1635
1637
|
]
|
@@ -1681,7 +1683,7 @@ module Cucumber
|
|
1681
1683
|
|
1682
1684
|
it 'prints the exception before the examples table row' do
|
1683
1685
|
filters = [
|
1684
|
-
Filters::ActivateSteps.new(
|
1686
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
1685
1687
|
Filters::ApplyBeforeHooks.new(FailingBeforeHook.new),
|
1686
1688
|
AddBeforeAndAfterHooks.new
|
1687
1689
|
]
|
@@ -1754,7 +1756,7 @@ module Cucumber
|
|
1754
1756
|
|
1755
1757
|
it 'prints the exception after the scenario name' do
|
1756
1758
|
filters = [
|
1757
|
-
Filters::ActivateSteps.new(
|
1759
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
1758
1760
|
Filters::ApplyBeforeHooks.new(FailingAndPassingBeforeHooks.new),
|
1759
1761
|
AddBeforeAndAfterHooks.new
|
1760
1762
|
]
|
@@ -1802,7 +1804,7 @@ module Cucumber
|
|
1802
1804
|
|
1803
1805
|
it 'prints the exception after the steps' do
|
1804
1806
|
filters = [
|
1805
|
-
Filters::ActivateSteps.new(
|
1807
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
1806
1808
|
Filters::ApplyAfterHooks.new(FailingAfterHook.new),
|
1807
1809
|
AddBeforeAndAfterHooks.new
|
1808
1810
|
]
|
@@ -1840,7 +1842,7 @@ module Cucumber
|
|
1840
1842
|
|
1841
1843
|
it 'prints the exception after the examples table row' do
|
1842
1844
|
filters = [
|
1843
|
-
Filters::ActivateSteps.new(
|
1845
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
1844
1846
|
Filters::ApplyAfterHooks.new(FailingAfterHook.new),
|
1845
1847
|
AddBeforeAndAfterHooks.new
|
1846
1848
|
]
|
@@ -1911,7 +1913,7 @@ module Cucumber
|
|
1911
1913
|
|
1912
1914
|
it 'prints the exception after the steps' do
|
1913
1915
|
filters = [
|
1914
|
-
Filters::ActivateSteps.new(
|
1916
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
1915
1917
|
Filters::ApplyAfterHooks.new(FailingThenPassingAfterHooks.new),
|
1916
1918
|
AddBeforeAndAfterHooks.new
|
1917
1919
|
]
|
@@ -1951,7 +1953,7 @@ module Cucumber
|
|
1951
1953
|
context 'with an exception in an after hook but no steps' do
|
1952
1954
|
it 'prints the exception after the scenario name' do
|
1953
1955
|
filters = [
|
1954
|
-
Filters::ActivateSteps.new(
|
1956
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
1955
1957
|
Filters::ApplyAfterHooks.new(FailingAfterHook.new),
|
1956
1958
|
AddBeforeAndAfterHooks.new
|
1957
1959
|
]
|
@@ -1991,7 +1993,7 @@ module Cucumber
|
|
1991
1993
|
|
1992
1994
|
it 'prints the exception after the scenario name' do
|
1993
1995
|
filters = [
|
1994
|
-
Filters::ActivateSteps.new(
|
1996
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
1995
1997
|
Filters::ApplyAroundHooks.new(FailingAroundHookBeforeRunningTestCase.new),
|
1996
1998
|
AddBeforeAndAfterHooks.new
|
1997
1999
|
]
|
@@ -2031,7 +2033,7 @@ module Cucumber
|
|
2031
2033
|
|
2032
2034
|
it 'prints the exception after the scenario name' do
|
2033
2035
|
filters = [
|
2034
|
-
Filters::ActivateSteps.new(
|
2036
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
2035
2037
|
Filters::ApplyAroundHooks.new(FailingAroundHookAfterRunningTestCase.new),
|
2036
2038
|
AddBeforeAndAfterHooks.new
|
2037
2039
|
]
|
@@ -2069,6 +2071,28 @@ module Cucumber
|
|
2069
2071
|
end
|
2070
2072
|
end
|
2071
2073
|
|
2074
|
+
describe 'before_step_result message' do
|
2075
|
+
context 'when the step matches' do
|
2076
|
+
it "sends the step match to the formatter" do
|
2077
|
+
expect(formatter).to receive(:before_step_result) do |_, step_match, *|
|
2078
|
+
expect(step_match).to be_a SimpleStepMatch
|
2079
|
+
end
|
2080
|
+
execute_gherkin do
|
2081
|
+
feature do
|
2082
|
+
scenario do
|
2083
|
+
step 'passing'
|
2084
|
+
end
|
2085
|
+
end
|
2086
|
+
end
|
2087
|
+
end
|
2088
|
+
end
|
2089
|
+
|
2090
|
+
context "when the step doesn't match" do
|
2091
|
+
it "sends a null object to the formatter" do
|
2092
|
+
end
|
2093
|
+
end
|
2094
|
+
end
|
2095
|
+
|
2072
2096
|
it 'passes nil as the multiline arg when there is none' do
|
2073
2097
|
expect(formatter).to receive(:after_step_result) do |keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line|
|
2074
2098
|
expect(multiline_arg).to be_nil
|
@@ -2082,14 +2106,17 @@ module Cucumber
|
|
2082
2106
|
end
|
2083
2107
|
end
|
2084
2108
|
|
2085
|
-
|
2086
|
-
|
2087
|
-
expect(
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2109
|
+
context "after_feature_element callback" do
|
2110
|
+
it 'passes an object reflecting the status of the scenario' do
|
2111
|
+
expect( formatter ).to receive(:after_feature_element).once do |scenario|
|
2112
|
+
expect( scenario ).to be_failed
|
2113
|
+
end
|
2114
|
+
execute_gherkin do
|
2115
|
+
feature do
|
2116
|
+
scenario do
|
2117
|
+
step 'failing'
|
2118
|
+
step 'this will be skipped'
|
2119
|
+
end
|
2093
2120
|
end
|
2094
2121
|
end
|
2095
2122
|
end
|
@@ -2145,7 +2172,7 @@ module Cucumber
|
|
2145
2172
|
|
2146
2173
|
def default_filters
|
2147
2174
|
[
|
2148
|
-
Filters::ActivateSteps.new(
|
2175
|
+
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
|
2149
2176
|
AddBeforeAndAfterHooks.new
|
2150
2177
|
]
|
2151
2178
|
end
|
@@ -642,7 +642,7 @@ OUTPUT
|
|
642
642
|
end
|
643
643
|
|
644
644
|
context "In --expand mode" do
|
645
|
-
let(:
|
645
|
+
let(:options) { { expand: true } }
|
646
646
|
before(:each) do
|
647
647
|
Cucumber::Term::ANSIColor.coloring = false
|
648
648
|
@out = StringIO.new
|
@@ -731,7 +731,7 @@ OUTPUT
|
|
731
731
|
end
|
732
732
|
|
733
733
|
context "In --expand mode with --source as an option" do
|
734
|
-
let(:
|
734
|
+
let(:options) { { expand: true } }
|
735
735
|
before(:each) do
|
736
736
|
Cucumber::Term::ANSIColor.coloring = false
|
737
737
|
@out = StringIO.new
|
@@ -19,16 +19,19 @@ module Cucumber
|
|
19
19
|
|
20
20
|
def run_defined_feature
|
21
21
|
define_steps
|
22
|
-
|
22
|
+
actual_runtime.visitor = report
|
23
23
|
|
24
24
|
receiver = Test::Runner.new(report)
|
25
25
|
filters = [
|
26
|
-
Filters::ActivateSteps.new(
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
Filters::
|
31
|
-
Filters::
|
26
|
+
Filters::ActivateSteps.new(
|
27
|
+
StepMatchSearch.new(actual_runtime.support_code.ruby.method(:step_matches), actual_runtime.configuration),
|
28
|
+
actual_runtime.configuration
|
29
|
+
),
|
30
|
+
Filters::ApplyAfterStepHooks.new(actual_runtime.support_code),
|
31
|
+
Filters::ApplyBeforeHooks.new(actual_runtime.support_code),
|
32
|
+
Filters::ApplyAfterHooks.new(actual_runtime.support_code),
|
33
|
+
Filters::ApplyAroundHooks.new(actual_runtime.support_code),
|
34
|
+
Filters::PrepareWorld.new(actual_runtime)
|
32
35
|
]
|
33
36
|
compile [gherkin_doc], receiver, filters
|
34
37
|
end
|
@@ -37,9 +40,8 @@ module Cucumber
|
|
37
40
|
def report
|
38
41
|
@report ||= LegacyApi::Adapter.new(
|
39
42
|
Fanout.new([@formatter]),
|
40
|
-
|
41
|
-
|
42
|
-
runtime.configuration)
|
43
|
+
actual_runtime.results,
|
44
|
+
actual_runtime.configuration)
|
43
45
|
end
|
44
46
|
|
45
47
|
require 'cucumber/core/gherkin/document'
|
@@ -52,16 +54,24 @@ module Cucumber
|
|
52
54
|
end
|
53
55
|
|
54
56
|
def runtime
|
55
|
-
@
|
57
|
+
@runtime_facade ||= LegacyApi::RuntimeFacade.new(actual_runtime.results, actual_runtime.support_code, actual_runtime.configuration)
|
58
|
+
end
|
59
|
+
|
60
|
+
def actual_runtime
|
61
|
+
@runtime ||= Runtime.new(options)
|
56
62
|
end
|
57
63
|
|
58
64
|
def define_steps
|
59
65
|
return unless step_defs = self.class.step_defs
|
60
|
-
rb = runtime.
|
66
|
+
rb = runtime.support_code.ruby
|
61
67
|
dsl = Object.new
|
62
68
|
dsl.extend RbSupport::RbDsl
|
63
69
|
dsl.instance_exec &step_defs
|
64
70
|
end
|
71
|
+
|
72
|
+
def options
|
73
|
+
{}
|
74
|
+
end
|
65
75
|
end
|
66
76
|
end
|
67
77
|
end
|
@@ -5,58 +5,15 @@ module Cucumber
|
|
5
5
|
module RbSupport
|
6
6
|
describe RbStepDefinition do
|
7
7
|
let(:user_interface) { double('user interface') }
|
8
|
-
let(:rb) { support_code.
|
8
|
+
let(:rb) { support_code.ruby }
|
9
9
|
let(:support_code) do
|
10
|
-
Cucumber::Runtime::SupportCode.new(user_interface
|
10
|
+
Cucumber::Runtime::SupportCode.new(user_interface)
|
11
11
|
end
|
12
12
|
let(:dsl) do
|
13
13
|
rb
|
14
14
|
Object.new.extend(RbSupport::RbDsl)
|
15
15
|
end
|
16
16
|
|
17
|
-
describe "snippets" do
|
18
|
-
let(:snippet) { double.as_null_object }
|
19
|
-
|
20
|
-
it "creates a regexp Snippet class by default" do
|
21
|
-
expect(Snippet::Regexp).to receive(:new) { snippet }
|
22
|
-
|
23
|
-
rb.snippet_text('Given', 'A "string" with 4 spaces', nil)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "creates a regexp Snippet class explicitly" do
|
27
|
-
expect(Snippet::Regexp).to receive(:new) { snippet }
|
28
|
-
|
29
|
-
rb.snippet_text('Given', 'A "string" with 4 spaces', nil, :regexp)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "creates a classic Snippet class" do
|
33
|
-
expect(Snippet::Classic).to receive(:new) { snippet }
|
34
|
-
|
35
|
-
rb.snippet_text('Given', 'A "string" with 4 spaces', nil, :classic)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "creates a percent Snippet class" do
|
39
|
-
expect(Snippet::Percent).to receive(:new) { snippet }
|
40
|
-
|
41
|
-
rb.snippet_text('Given', 'A "string" with 4 spaces', nil, :percent)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "passes all parameters to Snippet contructor" do
|
45
|
-
code_keyword, pattern, multiline_argument_class = double, double, double
|
46
|
-
|
47
|
-
expect(Snippet::Regexp).to receive(:new).with(code_keyword, pattern, multiline_argument_class)
|
48
|
-
|
49
|
-
rb.snippet_text(code_keyword, pattern, multiline_argument_class)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "renders the snippet" do
|
53
|
-
allow(Snippet::Regexp).to receive(:new) { snippet }
|
54
|
-
expect(snippet).to receive(:to_s)
|
55
|
-
|
56
|
-
rb.snippet_text('Given', 'A "string" with 4 spaces', nil)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
17
|
describe "#load_code_file" do
|
61
18
|
after do
|
62
19
|
FileUtils.rm_rf('tmp.rb')
|
@@ -84,6 +41,13 @@ module Cucumber
|
|
84
41
|
|
85
42
|
expect($foo).to eq 2
|
86
43
|
end
|
44
|
+
|
45
|
+
it "only loads ruby files" do
|
46
|
+
a_file_called("readme.md") do
|
47
|
+
"yo"
|
48
|
+
end
|
49
|
+
rb.load_code_file('readme.md')
|
50
|
+
end
|
87
51
|
end
|
88
52
|
|
89
53
|
describe "Handling the World" do
|