cucumber-core 5.0.2 → 9.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +73 -0
- data/CONTRIBUTING.md +3 -3
- data/README.md +0 -2
- data/lib/cucumber/core.rb +8 -6
- data/lib/cucumber/core/compiler.rb +35 -14
- data/lib/cucumber/core/event.rb +3 -5
- data/lib/cucumber/core/event_bus.rb +1 -1
- data/lib/cucumber/core/events.rb +25 -1
- data/lib/cucumber/core/gherkin/parser.rb +10 -8
- data/lib/cucumber/core/gherkin/writer.rb +15 -5
- data/lib/cucumber/core/gherkin/writer/helpers.rb +2 -2
- data/lib/cucumber/core/test/action.rb +1 -2
- data/lib/cucumber/core/test/case.rb +5 -4
- data/lib/cucumber/core/test/data_table.rb +6 -10
- data/lib/cucumber/core/test/doc_string.rb +3 -6
- data/lib/cucumber/core/test/filters/activate_steps_for_self_test.rb +0 -1
- data/lib/cucumber/core/test/result.rb +68 -7
- data/lib/cucumber/core/test/step.rb +6 -5
- data/lib/cucumber/core/test/timer.rb +2 -2
- data/lib/cucumber/core/version.rb +1 -1
- data/spec/coverage.rb +1 -0
- data/spec/cucumber/core/compiler_spec.rb +66 -3
- data/spec/cucumber/core/event_bus_spec.rb +2 -2
- data/spec/cucumber/core/event_spec.rb +3 -3
- data/spec/cucumber/core/filter_spec.rb +2 -2
- data/spec/cucumber/core/gherkin/parser_spec.rb +18 -2
- data/spec/cucumber/core/gherkin/writer_spec.rb +0 -1
- data/spec/cucumber/core/test/action_spec.rb +1 -2
- data/spec/cucumber/core/test/case_spec.rb +3 -2
- data/spec/cucumber/core/test/data_table_spec.rb +10 -12
- data/spec/cucumber/core/test/doc_string_spec.rb +8 -11
- data/spec/cucumber/core/test/location_spec.rb +7 -7
- data/spec/cucumber/core/test/result_spec.rb +41 -11
- data/spec/cucumber/core/test/runner_spec.rb +23 -21
- data/spec/cucumber/core/test/step_spec.rb +10 -9
- data/spec/cucumber/core_spec.rb +2 -2
- metadata +91 -53
- data/spec/capture_warnings.rb +0 -74
@@ -74,7 +74,7 @@ module Cucumber
|
|
74
74
|
|
75
75
|
context "#broadcast method" do
|
76
76
|
it "must be passed an instance of a registered event type" do
|
77
|
-
expect {
|
77
|
+
expect {
|
78
78
|
event_bus.broadcast Events::UnregisteredEvent
|
79
79
|
}.to raise_error(ArgumentError)
|
80
80
|
end
|
@@ -95,7 +95,7 @@ module Cucumber
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it "raises an error if you use an unknown Event ID" do
|
98
|
-
expect {
|
98
|
+
expect {
|
99
99
|
event_bus.on(:some_unknown_event) { :whatever }
|
100
100
|
}.to raise_error(ArgumentError)
|
101
101
|
end
|
@@ -13,7 +13,7 @@ module Cucumber
|
|
13
13
|
|
14
14
|
it "generates events with attributes" do
|
15
15
|
my_event_type = Event.new(:foo, :bar)
|
16
|
-
my_event = my_event_type.new(1,2)
|
16
|
+
my_event = my_event_type.new(1, 2)
|
17
17
|
expect(my_event.attributes).to eq [1, 2]
|
18
18
|
expect(my_event.foo).to eq 1
|
19
19
|
expect(my_event.bar).to eq 2
|
@@ -25,13 +25,13 @@ module Cucumber
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "can be converted to a hash" do
|
28
|
-
my_event = MyEventType.new(1,2)
|
28
|
+
my_event = MyEventType.new(1, 2)
|
29
29
|
expect(my_event.to_h).to eq foo: 1, bar: 2
|
30
30
|
end
|
31
31
|
|
32
32
|
it "has an event_id" do
|
33
33
|
expect(MyEventType.event_id).to eq :my_event_type
|
34
|
-
expect(MyEventType.new(1,2).event_id).to eq :my_event_type
|
34
|
+
expect(MyEventType.new(1, 2).event_id).to eq :my_event_type
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -11,7 +11,7 @@ module Cucumber::Core
|
|
11
11
|
describe ".new" do
|
12
12
|
let(:receiver) { double.as_null_object }
|
13
13
|
|
14
|
-
let(:doc) {
|
14
|
+
let(:doc) {
|
15
15
|
gherkin do
|
16
16
|
feature do
|
17
17
|
scenario 'x' do
|
@@ -46,7 +46,7 @@ module Cucumber::Core
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
# You can pass the names of attributes when building a
|
49
|
+
# You can pass the names of attributes when building a
|
50
50
|
# filter, allowing you to have custom attributes.
|
51
51
|
class NamedBlankingFilter < Filter.new(:name_pattern)
|
52
52
|
def test_case(test_case)
|
@@ -9,11 +9,14 @@ module Cucumber
|
|
9
9
|
describe Parser do
|
10
10
|
let(:receiver) { double }
|
11
11
|
let(:event_bus) { double }
|
12
|
-
let(:
|
12
|
+
let(:gherkin_query) { double }
|
13
|
+
let(:parser) { Parser.new(receiver, event_bus, gherkin_query) }
|
13
14
|
let(:visitor) { double }
|
14
15
|
|
15
16
|
before do
|
16
17
|
allow( event_bus ).to receive(:gherkin_source_parsed)
|
18
|
+
allow( event_bus).to receive(:envelope)
|
19
|
+
allow( gherkin_query ).to receive(:update)
|
17
20
|
end
|
18
21
|
|
19
22
|
def parse
|
@@ -40,6 +43,12 @@ module Cucumber
|
|
40
43
|
expect( event_bus ).to receive(:gherkin_source_parsed)
|
41
44
|
parse
|
42
45
|
end
|
46
|
+
|
47
|
+
it "emits an 'envelope' event for every message produced by Gherkin" do
|
48
|
+
# Only one message emited, there's no pickles generated
|
49
|
+
expect( event_bus ).to receive(:envelope).once
|
50
|
+
parse
|
51
|
+
end
|
43
52
|
end
|
44
53
|
|
45
54
|
context "for empty files" do
|
@@ -87,6 +96,13 @@ module Cucumber
|
|
87
96
|
expect( receiver ).to receive(:pickle)
|
88
97
|
parse
|
89
98
|
end
|
99
|
+
|
100
|
+
it "emits an 'envelope' event containing the pickle" do
|
101
|
+
allow( receiver ).to receive(:pickle)
|
102
|
+
# Once for the gherkin document, once with the pickle
|
103
|
+
expect( event_bus ).to receive(:envelope).twice
|
104
|
+
parse
|
105
|
+
end
|
90
106
|
end
|
91
107
|
|
92
108
|
context "when scenario is inside a rule" do
|
@@ -127,7 +143,7 @@ module Cucumber
|
|
127
143
|
step 'text'
|
128
144
|
end
|
129
145
|
end
|
130
|
-
rule description: "Second rule"do
|
146
|
+
rule description: "Second rule" do
|
131
147
|
example name: "Do not talk about the fight club" do
|
132
148
|
step 'text'
|
133
149
|
end
|
@@ -17,7 +17,7 @@ module Cucumber
|
|
17
17
|
context "location" do
|
18
18
|
|
19
19
|
context "with location passed to the constructor" do
|
20
|
-
|
20
|
+
let(:location) { double }
|
21
21
|
|
22
22
|
it "returns the location passed to the constructor" do
|
23
23
|
action = Action.new(location) {}
|
@@ -151,4 +151,3 @@ module Cucumber
|
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|
154
|
-
|
@@ -13,11 +13,12 @@ module Cucumber
|
|
13
13
|
include Core
|
14
14
|
include Core::Gherkin::Writer
|
15
15
|
|
16
|
+
let(:id) { double }
|
16
17
|
let(:name) { double }
|
17
18
|
let(:location) { double }
|
18
19
|
let(:tags) { double }
|
19
20
|
let(:language) { double }
|
20
|
-
let(:test_case) { Test::Case.new(name, test_steps, location, tags, language) }
|
21
|
+
let(:test_case) { Test::Case.new(id, name, test_steps, location, tags, language) }
|
21
22
|
let(:test_steps) { [double, double] }
|
22
23
|
|
23
24
|
context 'describing itself' do
|
@@ -45,7 +46,7 @@ module Cucumber
|
|
45
46
|
expect( first_hook ).to receive(:describe_to).ordered.and_yield
|
46
47
|
expect( second_hook ).to receive(:describe_to).ordered.and_yield
|
47
48
|
around_hooks = [first_hook, second_hook]
|
48
|
-
Test::Case.new(name, [], location, tags, language, around_hooks).describe_to(visitor, double)
|
49
|
+
Test::Case.new(id, name, [], location, tags, language, around_hooks).describe_to(visitor, double)
|
49
50
|
end
|
50
51
|
|
51
52
|
end
|
@@ -6,31 +6,29 @@ module Cucumber
|
|
6
6
|
module Core
|
7
7
|
module Test
|
8
8
|
describe DataTable do
|
9
|
-
let(:location) { Test::Location.new('foo.feature', 9..12) }
|
10
|
-
|
11
9
|
before do
|
12
10
|
@table = DataTable.new([
|
13
11
|
%w{one four seven},
|
14
12
|
%w{4444 55555 666666}
|
15
|
-
]
|
13
|
+
])
|
16
14
|
end
|
17
15
|
|
18
16
|
describe "equality" do
|
19
17
|
it "is equal to another table with the same data" do
|
20
|
-
expect( DataTable.new([[1,2],[3,4]]
|
18
|
+
expect( DataTable.new([[1, 2], [3, 4]]) ).to eq DataTable.new([[1, 2], [3, 4]])
|
21
19
|
end
|
22
20
|
|
23
21
|
it "is not equal to another table with different data" do
|
24
|
-
expect( DataTable.new([[1,2],[3,4]]
|
22
|
+
expect( DataTable.new([[1, 2], [3, 4]]) ).not_to eq DataTable.new([[1, 2]])
|
25
23
|
end
|
26
24
|
|
27
25
|
it "is not equal to a non table" do
|
28
|
-
expect( DataTable.new([[1,2],[3,4]]
|
26
|
+
expect( DataTable.new([[1, 2], [3, 4]]) ).not_to eq Object.new
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
32
30
|
describe "#data_table?" do
|
33
|
-
let(:table) { DataTable.new([[1,2],[3,4]]
|
31
|
+
let(:table) { DataTable.new([[1, 2], [3, 4]]) }
|
34
32
|
|
35
33
|
it "returns true" do
|
36
34
|
expect(table).to be_data_table
|
@@ -38,7 +36,7 @@ module Cucumber
|
|
38
36
|
end
|
39
37
|
|
40
38
|
describe "#doc_string" do
|
41
|
-
let(:table) { DataTable.new([[1,2],[3,4]]
|
39
|
+
let(:table) { DataTable.new([[1, 2], [3, 4]]) }
|
42
40
|
|
43
41
|
it "returns false" do
|
44
42
|
expect(table).not_to be_doc_string
|
@@ -46,7 +44,7 @@ module Cucumber
|
|
46
44
|
end
|
47
45
|
|
48
46
|
describe "#map" do
|
49
|
-
let(:table) { DataTable.new([ %w{foo bar}, %w{1 2} ]
|
47
|
+
let(:table) { DataTable.new([ %w{foo bar}, %w{1 2} ]) }
|
50
48
|
|
51
49
|
it 'yields the contents of each cell to the block' do
|
52
50
|
|
@@ -54,7 +52,7 @@ module Cucumber
|
|
54
52
|
end
|
55
53
|
|
56
54
|
it 'returns a new table with the cells modified by the block' do
|
57
|
-
expect( table.map { |cell| "*#{cell}*" } ).to eq
|
55
|
+
expect( table.map { |cell| "*#{cell}*" } ).to eq DataTable.new([%w{*foo* *bar*}, %w{*1* *2*}])
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
@@ -63,14 +61,14 @@ module Cucumber
|
|
63
61
|
@table = DataTable.new([
|
64
62
|
%w{one 1111},
|
65
63
|
%w{two 22222}
|
66
|
-
]
|
64
|
+
])
|
67
65
|
end
|
68
66
|
|
69
67
|
it "should transpose the table" do
|
70
68
|
transposed = DataTable.new([
|
71
69
|
%w{one two},
|
72
70
|
%w{1111 22222}
|
73
|
-
]
|
71
|
+
])
|
74
72
|
expect( @table.transpose ).to eq( transposed )
|
75
73
|
end
|
76
74
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/test/location'
|
3
2
|
require 'cucumber/core/test/doc_string'
|
4
3
|
require 'unindent'
|
5
4
|
|
@@ -7,11 +6,10 @@ module Cucumber
|
|
7
6
|
module Core
|
8
7
|
module Test
|
9
8
|
describe DocString do
|
10
|
-
let(:
|
11
|
-
let(:doc_string) { DocString.new(content, content_type, location) }
|
9
|
+
let(:doc_string) { DocString.new(content, content_type) }
|
12
10
|
|
13
11
|
describe "#data_table?" do
|
14
|
-
let(:doc_string) { DocString.new("test", "text/plain"
|
12
|
+
let(:doc_string) { DocString.new("test", "text/plain" ) }
|
15
13
|
|
16
14
|
it "returns false" do
|
17
15
|
expect(doc_string).not_to be_data_table
|
@@ -19,7 +17,7 @@ module Cucumber
|
|
19
17
|
end
|
20
18
|
|
21
19
|
describe "#doc_string" do
|
22
|
-
let(:doc_string) { DocString.new("test", "text/plain"
|
20
|
+
let(:doc_string) { DocString.new("test", "text/plain" ) }
|
23
21
|
|
24
22
|
it "returns true" do
|
25
23
|
expect(doc_string).to be_doc_string
|
@@ -48,15 +46,15 @@ module Cucumber
|
|
48
46
|
let(:content_type) { 'text/plain' }
|
49
47
|
|
50
48
|
it 'is equal to another DocString with the same content and content_type' do
|
51
|
-
expect( doc_string ).to eq DocString.new(content, content_type
|
49
|
+
expect( doc_string ).to eq DocString.new(content, content_type)
|
52
50
|
end
|
53
51
|
|
54
52
|
it 'is not equal to another DocString with different content' do
|
55
|
-
expect( doc_string ).not_to eq DocString.new('bar', content_type
|
53
|
+
expect( doc_string ).not_to eq DocString.new('bar', content_type)
|
56
54
|
end
|
57
55
|
|
58
56
|
it 'is not equal to another DocString with different content_type' do
|
59
|
-
expect( doc_string ).not_to eq DocString.new(content, 'text/html'
|
57
|
+
expect( doc_string ).not_to eq DocString.new(content, 'text/html')
|
60
58
|
end
|
61
59
|
|
62
60
|
it 'is equal to a string with the same content' do
|
@@ -96,13 +94,12 @@ module Cucumber
|
|
96
94
|
end
|
97
95
|
|
98
96
|
context "inspect" do
|
99
|
-
let(:location) { Test::Location.new("features/feature.feature", 8) }
|
100
97
|
let(:content_type) { 'text/plain' }
|
101
98
|
|
102
99
|
it "provides a useful inspect method" do
|
103
|
-
doc_string = DocString.new("some text", content_type
|
100
|
+
doc_string = DocString.new("some text", content_type)
|
104
101
|
expect(doc_string.inspect).to eq <<-END.chomp.unindent
|
105
|
-
#<Cucumber::Core::Test::DocString
|
102
|
+
#<Cucumber::Core::Test::DocString
|
106
103
|
"""text/plain
|
107
104
|
some text
|
108
105
|
""">
|
@@ -19,9 +19,9 @@ module Cucumber::Core::Test
|
|
19
19
|
expect( one_location ).to eq another_location
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
it "is not equal to a wild card of the same file" do
|
23
|
+
expect( Location.new(file, line) ).not_to eq Location.new(file)
|
24
|
+
end
|
25
25
|
|
26
26
|
context "collections of locations" do
|
27
27
|
it "behave as expected with uniq" do
|
@@ -45,7 +45,7 @@ module Cucumber::Core::Test
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it "is file:line:line:line for an arbitrary set of lines" do
|
48
|
-
expect( Location.new("foo.feature", [1,3,5]).to_s ).to eq "foo.feature:1:3:5"
|
48
|
+
expect( Location.new("foo.feature", [1, 3, 5]).to_s ).to eq "foo.feature:1:3:5"
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -88,7 +88,7 @@ module Cucumber::Core::Test
|
|
88
88
|
describe "created from source location" do
|
89
89
|
context "when the location is in the tree below pwd" do
|
90
90
|
it "create a relative path from pwd" do
|
91
|
-
expect( Location.from_source_location(Dir.pwd
|
91
|
+
expect( Location.from_source_location("#{Dir.pwd}/path/file.rb", 1).file ).to eq "path/file.rb"
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -109,7 +109,7 @@ module Cucumber::Core::Test
|
|
109
109
|
|
110
110
|
describe "created from file-colon-line" do
|
111
111
|
it "handles also Windows paths" do
|
112
|
-
#
|
112
|
+
# NOTE: running this test on Windows will produce "c:/path/file.rb", but "c:\path\file.rb" on Linux.
|
113
113
|
expect( Location.from_file_colon_line("c:\\path\\file.rb:123").file ).to match(/c:(\\|\/)path(\\|\/)file.rb/)
|
114
114
|
end
|
115
115
|
end
|
@@ -119,7 +119,7 @@ module Cucumber::Core::Test
|
|
119
119
|
expect( Location.of_caller.to_s ).to be_included_in caller[0]
|
120
120
|
end
|
121
121
|
|
122
|
-
context "when specifying additional caller depth"do
|
122
|
+
context "when specifying additional caller depth" do
|
123
123
|
it "use the location of the n:th caller" do
|
124
124
|
expect( Location.of_caller(1).to_s ).to be_included_in caller[1]
|
125
125
|
end
|
@@ -23,6 +23,11 @@ module Cucumber::Core::Test
|
|
23
23
|
expect( result.to_s ).to eq "✓"
|
24
24
|
end
|
25
25
|
|
26
|
+
it "converts to a Cucumber::Message::TestResult" do
|
27
|
+
message = result.to_message
|
28
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::PASSED)
|
29
|
+
end
|
30
|
+
|
26
31
|
it "has a duration" do
|
27
32
|
expect( result.duration ).to eq duration
|
28
33
|
end
|
@@ -68,6 +73,11 @@ module Cucumber::Core::Test
|
|
68
73
|
expect( result.duration ).to eq duration
|
69
74
|
end
|
70
75
|
|
76
|
+
it "converts to a Cucumber::Message::TestResult" do
|
77
|
+
message = result.to_message
|
78
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::FAILED)
|
79
|
+
end
|
80
|
+
|
71
81
|
it "requires both constructor arguments" do
|
72
82
|
expect { Result::Failed.new }.to raise_error(ArgumentError)
|
73
83
|
expect { Result::Failed.new(duration) }.to raise_error(ArgumentError)
|
@@ -131,6 +141,11 @@ module Cucumber::Core::Test
|
|
131
141
|
specify { expect( result ).to be_unknown }
|
132
142
|
specify { expect( result ).not_to be_skipped }
|
133
143
|
specify { expect( result ).not_to be_flaky }
|
144
|
+
|
145
|
+
it "converts to a Cucumber::Message::TestResult" do
|
146
|
+
message = result.to_message
|
147
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::UNKNOWN)
|
148
|
+
end
|
134
149
|
end
|
135
150
|
|
136
151
|
describe Result::Raisable do
|
@@ -190,6 +205,11 @@ module Cucumber::Core::Test
|
|
190
205
|
result.describe_to(visitor, args)
|
191
206
|
end
|
192
207
|
|
208
|
+
it "converts to a Cucumber::Message::TestResult" do
|
209
|
+
message = result.to_message
|
210
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::UNDEFINED)
|
211
|
+
end
|
212
|
+
|
193
213
|
specify { expect( result.to_sym ).to eq :undefined }
|
194
214
|
|
195
215
|
specify { expect( result ).not_to be_passed }
|
@@ -214,6 +234,11 @@ module Cucumber::Core::Test
|
|
214
234
|
result.describe_to(visitor, args)
|
215
235
|
end
|
216
236
|
|
237
|
+
it "converts to a Cucumber::Message::TestResult" do
|
238
|
+
message = result.to_message
|
239
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::SKIPPED)
|
240
|
+
end
|
241
|
+
|
217
242
|
specify { expect( result.to_sym ).to eq :skipped }
|
218
243
|
|
219
244
|
specify { expect( result ).not_to be_passed }
|
@@ -236,6 +261,11 @@ module Cucumber::Core::Test
|
|
236
261
|
result.describe_to(visitor, args)
|
237
262
|
end
|
238
263
|
|
264
|
+
it "converts to a Cucumber::Message::TestResult" do
|
265
|
+
message = result.to_message
|
266
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::PENDING)
|
267
|
+
end
|
268
|
+
|
239
269
|
specify { expect( result.to_sym ).to eq :pending }
|
240
270
|
|
241
271
|
specify { expect( result ).not_to be_passed }
|
@@ -259,7 +289,7 @@ module Cucumber::Core::Test
|
|
259
289
|
|
260
290
|
describe Result::StrictConfiguration do
|
261
291
|
subject(:strict_configuration) { Result::StrictConfiguration.new}
|
262
|
-
|
292
|
+
|
263
293
|
describe '#set_strict' do
|
264
294
|
context 'no type argument' do
|
265
295
|
it 'sets all result types to the setting argument' do
|
@@ -314,16 +344,16 @@ module Cucumber::Core::Test
|
|
314
344
|
describe '#merge!' do
|
315
345
|
let(:merged_configuration) { Result::StrictConfiguration.new }
|
316
346
|
it 'sets the not default values from the argument accordingly' do
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
347
|
+
strict_configuration.set_strict(false, :undefined)
|
348
|
+
strict_configuration.set_strict(false, :pending)
|
349
|
+
strict_configuration.set_strict(true, :flaky)
|
350
|
+
merged_configuration.set_strict(true, :pending)
|
351
|
+
merged_configuration.set_strict(false, :flaky)
|
352
|
+
strict_configuration.merge!(merged_configuration)
|
353
|
+
|
354
|
+
expect( strict_configuration.strict?(:undefined) ).to be_falsey
|
355
|
+
expect( strict_configuration.strict?(:pending) ).to be_truthy
|
356
|
+
expect( strict_configuration.strict?(:flaky) ).to be_falsey
|
327
357
|
end
|
328
358
|
end
|
329
359
|
end
|