cucumber-core 11.0.0 → 11.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +204 -291
  3. data/README.md +0 -1
  4. data/lib/cucumber/core/test/case.rb +11 -1
  5. data/lib/cucumber/core/test/data_table.rb +4 -0
  6. data/lib/cucumber/core/test/doc_string.rb +4 -1
  7. data/lib/cucumber/core/test/empty_multiline_argument.rb +2 -2
  8. data/lib/cucumber/core/test/filters/locations_filter.rb +1 -1
  9. data/lib/cucumber/core/test/location.rb +7 -0
  10. data/lib/cucumber/core/test/step.rb +4 -0
  11. metadata +21 -86
  12. data/lib/cucumber/core/version.rb +0 -10
  13. data/spec/coverage.rb +0 -12
  14. data/spec/cucumber/core/compiler_spec.rb +0 -241
  15. data/spec/cucumber/core/event_bus_spec.rb +0 -163
  16. data/spec/cucumber/core/event_spec.rb +0 -40
  17. data/spec/cucumber/core/filter_spec.rb +0 -101
  18. data/spec/cucumber/core/gherkin/parser_spec.rb +0 -162
  19. data/spec/cucumber/core/gherkin/writer_spec.rb +0 -332
  20. data/spec/cucumber/core/report/summary_spec.rb +0 -178
  21. data/spec/cucumber/core/test/action_spec.rb +0 -153
  22. data/spec/cucumber/core/test/case_spec.rb +0 -125
  23. data/spec/cucumber/core/test/data_table_spec.rb +0 -79
  24. data/spec/cucumber/core/test/doc_string_spec.rb +0 -111
  25. data/spec/cucumber/core/test/duration_matcher.rb +0 -20
  26. data/spec/cucumber/core/test/empty_multiline_argument_spec.rb +0 -28
  27. data/spec/cucumber/core/test/filters/locations_filter_spec.rb +0 -271
  28. data/spec/cucumber/core/test/location_spec.rb +0 -129
  29. data/spec/cucumber/core/test/result_spec.rb +0 -504
  30. data/spec/cucumber/core/test/runner_spec.rb +0 -320
  31. data/spec/cucumber/core/test/step_spec.rb +0 -88
  32. data/spec/cucumber/core/test/timer_spec.rb +0 -25
  33. data/spec/cucumber/core_spec.rb +0 -262
  34. data/spec/report_api_spy.rb +0 -25
@@ -1,101 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core/gherkin/writer'
3
- require 'cucumber/core'
4
- require 'cucumber/core/filter'
5
-
6
- module Cucumber::Core
7
- describe Filter do
8
- include Cucumber::Core::Gherkin::Writer
9
- include Cucumber::Core
10
-
11
- describe ".new" do
12
- let(:receiver) { double.as_null_object }
13
-
14
- let(:doc) {
15
- gherkin do
16
- feature do
17
- scenario 'x' do
18
- step 'a step'
19
- end
20
-
21
- scenario 'y' do
22
- step 'a step'
23
- end
24
- end
25
- end
26
- }
27
-
28
- it "creates a filter class that can pass-through by default" do
29
- my_filter_class = Filter.new
30
- my_filter = my_filter_class.new
31
- expect(receiver).to receive(:test_case) { |test_case|
32
- expect(test_case.test_steps.length).to eq 1
33
- expect(test_case.test_steps.first.text).to eq 'a step'
34
- }.exactly(2).times
35
- compile [doc], receiver, [my_filter]
36
- end
37
-
38
- context "customizing by subclassing" do
39
-
40
- # Each filter imlicitly gets a :receiver attribute
41
- # that you need to call with the new test case
42
- # once you've received yours and modified it.
43
- class BasicBlankingFilter < Filter.new
44
- def test_case(test_case)
45
- test_case.with_steps([]).describe_to(receiver)
46
- end
47
- end
48
-
49
- # You can pass the names of attributes when building a
50
- # filter, allowing you to have custom attributes.
51
- class NamedBlankingFilter < Filter.new(:name_pattern)
52
- def test_case(test_case)
53
- if test_case.name =~ name_pattern
54
- test_case.with_steps([]).describe_to(receiver)
55
- else
56
- test_case.describe_to(receiver) # or just call `super`
57
- end
58
- self
59
- end
60
- end
61
-
62
- it "can override methods from the base class" do
63
- expect(receiver).to receive(:test_case) { |test_case|
64
- expect(test_case.test_steps.length).to eq 0
65
- }.exactly(2).times
66
- run BasicBlankingFilter.new
67
- end
68
-
69
- it "can take arguments" do
70
- expect(receiver).to receive(:test_case) { |test_case|
71
- expect(test_case.test_steps.length).to eq 0
72
- }.once.ordered
73
- expect(receiver).to receive(:test_case) { |test_case|
74
- expect(test_case.test_steps.length).to eq 1
75
- }.once.ordered
76
- run NamedBlankingFilter.new(/x/)
77
- end
78
-
79
- end
80
-
81
- context "customizing by using a block" do
82
- BlockBlankingFilter = Filter.new do
83
- def test_case(test_case)
84
- test_case.with_steps([]).describe_to(receiver)
85
- end
86
- end
87
-
88
- it "allows methods to be overridden" do
89
- expect(receiver).to receive(:test_case) { |test_case|
90
- expect(test_case.test_steps.length).to eq 0
91
- }.exactly(2).times
92
- run BlockBlankingFilter.new
93
- end
94
- end
95
-
96
- def run(filter)
97
- compile [doc], receiver, [filter]
98
- end
99
- end
100
- end
101
- end
@@ -1,162 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- # frozen_string_literal: true
3
- require 'cucumber/core/gherkin/parser'
4
- require 'cucumber/core/gherkin/writer'
5
-
6
- module Cucumber
7
- module Core
8
- module Gherkin
9
- describe Parser do
10
- let(:receiver) { double }
11
- let(:event_bus) { double }
12
- let(:gherkin_query) { double }
13
- let(:parser) { Parser.new(receiver, event_bus, gherkin_query) }
14
- let(:visitor) { double }
15
-
16
- before do
17
- allow( event_bus ).to receive(:gherkin_source_parsed)
18
- allow( event_bus).to receive(:envelope)
19
- allow( gherkin_query ).to receive(:update)
20
- end
21
-
22
- def parse
23
- parser.document(source)
24
- end
25
-
26
- context "for invalid gherkin" do
27
- let(:source) { Gherkin::Document.new(path, "\nnot gherkin\n\nFeature: \n") }
28
- let(:path) { 'path_to/the.feature' }
29
-
30
- it "raises an error" do
31
- expect { parse }.to raise_error(ParseError) do |error|
32
- expect( error.message ).to match(/not gherkin/)
33
- expect( error.message ).to match(/#{path}/)
34
- end
35
- end
36
- end
37
-
38
- context "for valid gherkin" do
39
- let(:source) { Gherkin::Document.new(path, 'Feature:') }
40
- let(:path) { 'path_to/the.feature' }
41
-
42
- it "issues a gherkin_source_parsed event" do
43
- expect( event_bus ).to receive(:gherkin_source_parsed)
44
- parse
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
52
- end
53
-
54
- context "for empty files" do
55
- let(:source) { Gherkin::Document.new(path, '') }
56
- let(:path) { 'path_to/the.feature' }
57
-
58
- it "passes on no pickles" do
59
- expect( receiver ).not_to receive(:pickle)
60
- parse
61
- end
62
- end
63
-
64
- include Writer
65
- def self.source(&block)
66
- let(:source) { gherkin(&block) }
67
- end
68
-
69
- RSpec::Matchers.define :pickle_with_language do |language|
70
- match { |actual| actual.language == language }
71
- end
72
-
73
- context "when the Gherkin has a language header" do
74
- source do
75
- feature(language: 'ja', keyword: '機能') do
76
- scenario(keyword: 'シナリオ')
77
- end
78
- end
79
-
80
- it "the pickles have the correct language" do
81
- expect( receiver ).to receive(:pickle).with(pickle_with_language('ja'))
82
- parse
83
- end
84
- end
85
-
86
- context "when the Gherkin produces one pickle" do
87
- source do
88
- feature do
89
- scenario do
90
- step 'text'
91
- end
92
- end
93
- end
94
-
95
- it "passes on the pickle" do
96
- expect( receiver ).to receive(:pickle)
97
- parse
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
106
- end
107
-
108
- context "when scenario is inside a rule" do
109
- source do
110
- feature do
111
- rule do
112
- scenario name: "My scenario"
113
- end
114
- end
115
- end
116
-
117
- it "passes on the pickle" do
118
- expect( receiver ).to receive(:pickle)
119
- parse
120
- end
121
- end
122
-
123
- context "when example is inside a rule" do
124
- source do
125
- feature do
126
- rule do
127
- example name: "My example"
128
- end
129
- end
130
- end
131
-
132
- it "passes on the pickle" do
133
- expect( receiver ).to receive(:pickle)
134
- parse
135
- end
136
- end
137
-
138
- context "when there are multiple rules and scenarios or examples" do
139
- source do
140
- feature do
141
- rule description: "First rule" do
142
- scenario name: "Do not talk about the fight club" do
143
- step 'text'
144
- end
145
- end
146
- rule description: "Second rule" do
147
- example name: "Do not talk about the fight club" do
148
- step 'text'
149
- end
150
- end
151
- end
152
- end
153
-
154
- it "passes on the pickles" do
155
- expect( receiver ).to receive(:pickle).twice
156
- parse
157
- end
158
- end
159
- end
160
- end
161
- end
162
- end
@@ -1,332 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core/gherkin/writer'
3
- require 'unindent'
4
-
5
- module Cucumber::Core::Gherkin
6
- describe Writer do
7
- include Writer
8
-
9
- context 'specifying uri' do
10
- it 'generates a uri by default' do
11
- source = gherkin { feature }
12
- expect( source.uri ).to eq 'features/test.feature'
13
- end
14
-
15
- it 'allows you to specify a URI' do
16
- source = gherkin('features/path/to/my.feature') { feature }
17
- expect( source.uri ).to eq 'features/path/to/my.feature'
18
- end
19
- end
20
-
21
- context 'a feature' do
22
-
23
- it 'generates the feature statement' do
24
- source = gherkin { feature }
25
- expect( source ).to eq "Feature:\n"
26
- end
27
-
28
- context 'when a name is provided' do
29
- it 'includes the name in the feature statement' do
30
- source = gherkin do
31
- feature "A Feature\n"
32
- end
33
- expect( source ).to eq "Feature: A Feature\n"
34
- end
35
- end
36
-
37
- context 'when a description is provided' do
38
- it 'includes the description in the feature statement' do
39
- source = gherkin do
40
- feature "A Feature", description: <<-END
41
- This is the description
42
- which can span
43
- multiple lines.
44
- END
45
- end
46
- expected = <<-END
47
- Feature: A Feature
48
- This is the description
49
- which can span
50
- multiple lines.
51
- END
52
-
53
- expect( source ).to eq expected.unindent
54
- end
55
- end
56
-
57
- context 'when a keyword is provided' do
58
- it 'uses the supplied keyword' do
59
- source = gherkin do
60
- feature "A Feature", keyword: "Business Need"
61
- end
62
- expect( source ).to eq "Business Need: A Feature\n"
63
- end
64
- end
65
-
66
- context 'when a language is supplied' do
67
- it 'inserts a language statement' do
68
- source = gherkin do
69
- feature language: 'ru'
70
- end
71
-
72
- expect( source ).to eq "# language: ru\nFeature:\n"
73
- end
74
- end
75
-
76
- context 'when a comment is supplied' do
77
- it 'inserts a comment' do
78
- source = gherkin do
79
- comment 'wow'
80
- comment 'great'
81
- feature
82
- end
83
-
84
- expect( source.to_s ).to eq "# wow\n# great\nFeature:\n"
85
- end
86
- end
87
-
88
- context 'with a scenario' do
89
- it 'includes the scenario statement' do
90
- source = gherkin do
91
- feature "A Feature" do
92
- scenario
93
- end
94
- end
95
-
96
- expect( source.to_s ).to match(/Scenario:/)
97
- end
98
-
99
- context 'when a comment is provided' do
100
- it 'includes the comment in the scenario statement' do
101
- source = gherkin do
102
- feature do
103
- comment 'wow'
104
- scenario
105
- end
106
- end
107
- expect( source.to_s ).to eq <<-END.unindent
108
- Feature:
109
-
110
- # wow
111
- Scenario:
112
- END
113
- end
114
- end
115
-
116
- context 'when a description is provided' do
117
- it 'includes the description in the scenario statement' do
118
- source = gherkin do
119
- feature do
120
- scenario description: <<-END
121
- This is the description
122
- which can span
123
- multiple lines.
124
- END
125
- end
126
- end
127
-
128
- expect( source ).to eq <<-END.unindent
129
- Feature:
130
-
131
- Scenario:
132
- This is the description
133
- which can span
134
- multiple lines.
135
- END
136
- end
137
- end
138
-
139
- context 'with a step' do
140
- it 'includes the step statement' do
141
- source = gherkin do
142
- feature "A Feature" do
143
- scenario do
144
- step 'passing'
145
- end
146
- end
147
- end
148
-
149
- expect( source.to_s ).to match(/Given passing\Z/m)
150
- end
151
-
152
- context 'when a docstring is provided' do
153
- it 'includes the content type when provided' do
154
- source = gherkin do
155
- feature do
156
- scenario do
157
- step 'failing' do
158
- doc_string 'some text', 'text/plain'
159
- end
160
- end
161
- end
162
-
163
- end
164
-
165
- expect( source ).to eq <<-END.unindent
166
- Feature:
167
-
168
- Scenario:
169
- Given failing
170
- """text/plain
171
- some text
172
- """
173
- END
174
- end
175
- end
176
- end
177
- end
178
-
179
- context 'with a background' do
180
- it 'can have a description' do
181
- source = gherkin do
182
- feature do
183
- background description: "One line,\nand two.."
184
- end
185
- end
186
-
187
- expect( source ).to eq <<-END.unindent
188
- Feature:
189
-
190
- Background:
191
- One line,
192
- and two..
193
- END
194
- end
195
- end
196
-
197
- context 'with a scenario outline' do
198
- it 'can have a description' do
199
- source = gherkin do
200
- feature do
201
- scenario_outline description: "Doesn't need to be multi-line."
202
- end
203
- end
204
-
205
- expect( source ).to eq <<-END.unindent
206
- Feature:
207
-
208
- Scenario Outline:
209
- Doesn't need to be multi-line.
210
- END
211
- end
212
-
213
- context 'and examples table' do
214
- it 'can have a description' do
215
- source = gherkin do
216
- feature do
217
- scenario_outline do
218
- examples description: "Doesn't need to be multi-line." do
219
-
220
- end
221
- end
222
- end
223
- end
224
-
225
- expect( source ).to eq <<-END.unindent
226
- Feature:
227
-
228
- Scenario Outline:
229
-
230
- Examples:
231
- Doesn't need to be multi-line.
232
- END
233
- end
234
- end
235
- end
236
- end
237
-
238
- it 'generates a complex feature' do
239
- source = gherkin do
240
- comment 'wow'
241
- feature 'Fully featured', language: 'en', tags: '@always' do
242
- comment 'cool'
243
- background do
244
- step 'passing'
245
- end
246
-
247
- scenario do
248
- step 'passing'
249
- end
250
-
251
- comment 'here'
252
- scenario 'with doc string', tags: '@first @second' do
253
- comment 'and here'
254
- step 'passing'
255
- step 'failing', keyword: 'When' do
256
- doc_string <<-END
257
- I wish I was a little bit taller.
258
- I wish I was a baller.
259
- END
260
- end
261
- end
262
-
263
- scenario 'with a table...' do
264
- step 'passes:' do
265
- table do
266
- row 'name', 'age', 'location'
267
- row 'Janine', '43', 'Antarctica'
268
- end
269
- end
270
- end
271
-
272
- comment 'yay'
273
- scenario_outline 'eating' do
274
- step 'there are <start> cucumbers'
275
- step 'I eat <eat> cucumbers', keyword: 'When'
276
- step 'I should have <left> cucumbers', keyword: 'Then'
277
-
278
- comment 'hmmm'
279
- examples do
280
- row 'start', 'eat', 'left'
281
- row '12', '5', '7'
282
- row '20', '5', '15'
283
- end
284
- end
285
- end
286
- end
287
-
288
- expect( source.to_s ).to eq <<-END.unindent
289
- # language: en
290
- # wow
291
- @always
292
- Feature: Fully featured
293
-
294
- # cool
295
- Background:
296
- Given passing
297
-
298
- Scenario:
299
- Given passing
300
-
301
- # here
302
- @first @second
303
- Scenario: with doc string
304
- # and here
305
- Given passing
306
- When failing
307
- """
308
- I wish I was a little bit taller.
309
- I wish I was a baller.
310
- """
311
-
312
- Scenario: with a table...
313
- Given passes:
314
- | name | age | location |
315
- | Janine | 43 | Antarctica |
316
-
317
- # yay
318
- Scenario Outline: eating
319
- Given there are <start> cucumbers
320
- When I eat <eat> cucumbers
321
- Then I should have <left> cucumbers
322
-
323
- # hmmm
324
- Examples:
325
- | start | eat | left |
326
- | 12 | 5 | 7 |
327
- | 20 | 5 | 15 |
328
- END
329
-
330
- end
331
- end
332
- end