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,320 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core/test/runner'
3
- require 'cucumber/core/test/case'
4
- require 'cucumber/core/test/step'
5
- require 'cucumber/core/test/duration_matcher'
6
-
7
- module Cucumber::Core::Test
8
- describe Runner do
9
-
10
- let(:step_id) { double }
11
- let(:test_id) { double }
12
- let(:name) { double }
13
- let(:location) { double }
14
- let(:tags) { double }
15
- let(:language) { double }
16
- let(:test_case) { Case.new(test_id, name, test_steps, location, tags, language) }
17
- let(:text) { double }
18
- let(:runner) { Runner.new(event_bus) }
19
- let(:event_bus) { double.as_null_object }
20
- let(:passing) { Step.new(step_id, text, location, location).with_action {} }
21
- let(:failing) { Step.new(step_id, text, location, location).with_action { raise exception } }
22
- let(:pending) { Step.new(step_id, text, location, location).with_action { raise Result::Pending.new("TODO") } }
23
- let(:skipping) { Step.new(step_id, text, location, location).with_action { raise Result::Skipped.new } }
24
- let(:undefined) { Step.new(step_id, text, location, location) }
25
- let(:exception) { StandardError.new('test error') }
26
-
27
- before do
28
- allow( event_bus ).to receive(:test_case_started)
29
- allow( text ).to receive(:empty?)
30
- end
31
-
32
- context "reporting the duration of a test case" do
33
- before do
34
- allow( Timer::MonotonicTime ).to receive(:time_in_nanoseconds).and_return(525702744080000, 525702744080001)
35
- end
36
-
37
- context "for a passing test case" do
38
- let(:test_steps) { [passing] }
39
-
40
- it "records the nanoseconds duration of the execution on the result" do
41
- expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
42
- expect( result.duration ).to be_duration 1
43
- end
44
- test_case.describe_to runner
45
- end
46
- end
47
-
48
- context "for a failing test case" do
49
- let(:test_steps) { [failing] }
50
-
51
- it "records the duration" do
52
- expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
53
- expect(result.duration).to be_duration 1
54
- end
55
- test_case.describe_to runner
56
- end
57
- end
58
- end
59
-
60
- context "reporting the exception that failed a test case" do
61
- let(:test_steps) { [failing] }
62
- it "sets the exception on the result" do
63
- allow(event_bus).to receive(:before_test_case)
64
- expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
65
- expect( result.exception ).to eq exception
66
- end
67
- test_case.describe_to runner
68
- end
69
- end
70
-
71
- context "with a single case" do
72
- context "without steps" do
73
- let(:test_steps) { [] }
74
-
75
- it "emits a test_case_started event before running the test case" do
76
- expect(event_bus).to receive(:test_case_started).with(test_case)
77
- test_case.describe_to runner
78
- end
79
-
80
- it "emits the test_case_finished event after running the the test case" do
81
- expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
82
- expect( reported_test_case ).to eq test_case
83
- expect( result ).to be_undefined
84
- end
85
- test_case.describe_to runner
86
- end
87
- end
88
-
89
- context 'with steps' do
90
- context 'that all pass' do
91
- let(:test_steps) { [ passing, passing ] }
92
-
93
- it 'emits the test_case_finished event with a passing result' do
94
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
95
- expect( result ).to be_passed
96
- end
97
- test_case.describe_to runner
98
- end
99
- end
100
-
101
- context 'an undefined step' do
102
- let(:test_steps) { [ undefined ] }
103
-
104
- it 'emits the test_case_finished event with an undefined result' do
105
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
106
- expect( result ).to be_undefined
107
- end
108
-
109
- test_case.describe_to runner
110
- end
111
-
112
- it 'sets the message on the result' do
113
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
114
- expect( result.message ).to eq("Undefined step: \"step name\"")
115
- end
116
- allow( undefined ).to receive(:text).and_return('step name')
117
-
118
- test_case.describe_to runner
119
- end
120
-
121
- it 'appends the backtrace of the result' do
122
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
123
- expect( result.backtrace ).to eq(["step line"])
124
- end
125
- expect( undefined ).to receive(:backtrace_line).and_return('step line')
126
-
127
- test_case.describe_to runner
128
- end
129
- end
130
-
131
- context 'a pending step' do
132
- let(:test_steps) { [ pending ] }
133
-
134
- it 'emits the test_case_finished event with a pending result' do
135
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
136
- expect( result ).to be_pending
137
- end
138
- test_case.describe_to runner
139
- end
140
-
141
- it 'appends the backtrace of the result' do
142
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
143
- expect( result.backtrace.last ).to eq("step line")
144
- end
145
- expect( pending ).to receive(:backtrace_line).and_return('step line')
146
-
147
- test_case.describe_to runner
148
- end
149
- end
150
-
151
- context "a skipping step" do
152
- let(:test_steps) { [skipping] }
153
-
154
- it "emits the test_case_finished event with a skipped result" do
155
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
156
- expect( result ).to be_skipped
157
- end
158
- test_case.describe_to runner
159
- end
160
-
161
- it 'appends the backtrace of the result' do
162
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
163
- expect( result.backtrace.last ).to eq("step line")
164
- end
165
- expect( skipping ).to receive(:backtrace_line).and_return('step line')
166
-
167
- test_case.describe_to runner
168
- end
169
- end
170
-
171
- context 'that fail' do
172
- let(:test_steps) { [ failing ] }
173
-
174
- it 'emits the test_case_finished event with a failing result' do
175
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
176
- expect( result ).to be_failed
177
- end
178
- test_case.describe_to runner
179
- end
180
-
181
- it 'appends the backtrace of the exception of the result' do
182
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
183
- expect( result.exception.backtrace.last ).to eq("step line")
184
- end
185
- expect( failing ).to receive(:backtrace_line).and_return('step line')
186
-
187
- test_case.describe_to runner
188
- end
189
- end
190
-
191
- context 'where the first step fails' do
192
- let(:test_steps) { [ failing, passing ] }
193
-
194
- it 'emits the test_step_finished event with a failed result' do
195
- expect(event_bus).to receive(:test_step_finished).with(failing, anything) do |test_step, result|
196
- expect( result ).to be_failed
197
- end
198
- test_case.describe_to runner
199
- end
200
-
201
- it 'emits a test_step_finished event with a skipped result' do
202
- expect(event_bus).to receive(:test_step_finished).with(passing, anything) do |test_step, result|
203
- expect( result ).to be_skipped
204
- end
205
- test_case.describe_to runner
206
- end
207
-
208
- it 'emits a test_case_finished event with a failed result' do
209
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
210
- expect( result ).to be_failed
211
- expect( result.exception ).to eq exception
212
- end
213
- test_case.describe_to runner
214
- end
215
-
216
- it 'skips, rather than executing the second step' do
217
- expect( passing ).not_to receive(:execute)
218
- expect( passing ).to receive(:skip).and_return(Result::Skipped.new)
219
- test_case.describe_to runner
220
- end
221
- end
222
-
223
- end
224
- end
225
-
226
- context 'with multiple test cases' do
227
- context 'when the first test case fails' do
228
- let(:first_test_case) { Case.new(test_id, name, [failing], location, tags, language) }
229
- let(:last_test_case) { Case.new(test_id, name, [passing], location, tags, language) }
230
- let(:test_cases) { [first_test_case, last_test_case] }
231
-
232
- it 'reports the results correctly for the following test case' do
233
- expect(event_bus).to receive(:test_case_finished) { |reported_test_case, result|
234
- expect(result).to be_failed if reported_test_case.equal?(first_test_case)
235
- expect(result).to be_passed if reported_test_case.equal?(last_test_case)
236
- }.twice
237
-
238
- test_cases.each { |c| c.describe_to runner }
239
- end
240
- end
241
- end
242
-
243
- context "passing latest result to a mapping" do
244
- it "passes a Failed result when the scenario is failing" do
245
- result_spy = nil
246
- hook_mapping = UnskippableAction.new do |last_result|
247
- result_spy = last_result
248
- end
249
- after_hook = HookStep.new(step_id, text, location, hook_mapping)
250
- failing_step = Step.new(step_id, text, location).with_action { fail }
251
- test_case = Case.new(test_id, name, [failing_step, after_hook], location, tags, language)
252
- test_case.describe_to runner
253
- expect(result_spy).to be_failed
254
- end
255
- end
256
-
257
- require 'cucumber/core/test/around_hook'
258
- context "with around hooks" do
259
- it "passes normally when around hooks don't fail" do
260
- around_hook = AroundHook.new { |block| block.call }
261
- passing_step = Step.new(step_id, text, location, location).with_action {}
262
- test_case = Case.new(test_id, name, [passing_step], location, tags, language, [around_hook])
263
- expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
264
- expect(result).to be_passed
265
- end
266
- test_case.describe_to runner
267
- end
268
-
269
- it "gets a failed result if the Around hook fails before the test case is run" do
270
- around_hook = AroundHook.new { |block| raise exception }
271
- passing_step = Step.new(step_id, text, location, location).with_action {}
272
- test_case = Case.new(test_id, name, [passing_step], location, tags, language, [around_hook])
273
- expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
274
- expect(result).to be_failed
275
- expect(result.exception).to eq exception
276
- end
277
- test_case.describe_to runner
278
- end
279
-
280
- it "gets a failed result if the Around hook fails after the test case is run" do
281
- around_hook = AroundHook.new { |block| block.call; raise exception }
282
- passing_step = Step.new(step_id, text, location, location).with_action {}
283
- test_case = Case.new(test_id, name, [passing_step], location, tags, language, [around_hook])
284
- expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
285
- expect(result).to be_failed
286
- expect(result.exception).to eq exception
287
- end
288
- test_case.describe_to runner
289
- end
290
-
291
- it "fails when a step fails if the around hook works" do
292
- around_hook = AroundHook.new { |block| block.call }
293
- failing_step = Step.new(step_id, text, location, location).with_action { raise exception }
294
- test_case = Case.new(test_id, name, [failing_step], location, tags, language, [around_hook])
295
- expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
296
- expect(result).to be_failed
297
- expect(result.exception).to eq exception
298
- end
299
- test_case.describe_to runner
300
- end
301
-
302
- it "sends after_test_step for a step interrupted by (a timeout in) the around hook" do
303
- around_hook = AroundHook.new { |block| block.call; raise exception }
304
- passing_step = Step.new(step_id, text, location, location).with_action {}
305
- test_case = Case.new(test_id, name, [], location, tags, language, [around_hook])
306
- allow(runner).to receive(:running_test_step).and_return(passing_step)
307
- expect(event_bus).to receive(:test_step_finished).with(passing_step, anything) do |reported_test_case, result|
308
- expect(result).to be_failed
309
- expect(result.exception).to eq exception
310
- end
311
- expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
312
- expect(result).to be_failed
313
- expect(result.exception).to eq exception
314
- end
315
- test_case.describe_to runner
316
- end
317
- end
318
-
319
- end
320
- end
@@ -1,88 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core/test/step'
3
-
4
- module Cucumber::Core::Test
5
- describe Step do
6
- let(:id) { 'some-random-uid' }
7
- let(:text) { 'step text' }
8
- let(:location) { double }
9
-
10
- describe "describing itself" do
11
- it "describes itself to a visitor" do
12
- visitor = double
13
- args = double
14
- test_step = Step.new(id, text, location)
15
- expect( visitor ).to receive(:test_step).with(test_step, args)
16
- test_step.describe_to(visitor, args)
17
- end
18
- end
19
-
20
- describe "backtrace line" do
21
- let(:text) { 'this step passes' }
22
- let(:location) { Location.new('path/file.feature', 10) }
23
- let(:test_step) { Step.new(id, text, location) }
24
-
25
- it "knows how to form the backtrace line" do
26
- expect( test_step.backtrace_line ).to eq("path/file.feature:10:in `this step passes'")
27
- end
28
- end
29
-
30
- describe "executing" do
31
- it "passes arbitrary arguments to the action's block" do
32
- args_spy = nil
33
- expected_args = [double, double]
34
- test_step = Step.new(id, text, location).with_action do |*actual_args|
35
- args_spy = actual_args
36
- end
37
- test_step.execute(*expected_args)
38
- expect(args_spy).to eq expected_args
39
- end
40
-
41
- context "when a passing action exists" do
42
- it "returns a passing result" do
43
- test_step = Step.new(id, text, location).with_action {}
44
- expect( test_step.execute ).to be_passed
45
- end
46
- end
47
-
48
- context "when a failing action exists" do
49
- let(:exception) { StandardError.new('oops') }
50
-
51
- it "returns a failing result" do
52
- test_step = Step.new(id, text, location).with_action { raise exception }
53
- result = test_step.execute
54
- expect( result ).to be_failed
55
- expect( result.exception ).to eq exception
56
- end
57
- end
58
-
59
- context "with no action" do
60
- it "returns an Undefined result" do
61
- test_step = Step.new(id, text, location)
62
- result = test_step.execute
63
- expect( result ).to be_undefined
64
- end
65
- end
66
- end
67
-
68
- it "exposes the text and location of as attributes" do
69
- test_step = Step.new(id, text, location)
70
- expect( test_step.text ).to eq text
71
- expect( test_step.location ).to eq location
72
- end
73
-
74
- it "exposes the location of the action as attribute" do
75
- location = double
76
- action = double(location: location)
77
- test_step = Step.new(id, text, location, action)
78
- expect( test_step.action_location ).to eq location
79
- end
80
-
81
- it "returns the text when converted to a string" do
82
- text = 'a passing step'
83
- test_step = Step.new(id, text, location)
84
- expect( test_step.to_s ).to eq 'a passing step'
85
- end
86
-
87
- end
88
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core/test/timer'
3
- require 'cucumber/core/test/duration_matcher'
4
-
5
- module Cucumber
6
- module Core
7
- module Test
8
- describe Timer do
9
- before do
10
- allow(Timer::MonotonicTime).to receive(:time_in_nanoseconds)
11
- .and_return(525702744080000, 525702744080001)
12
- end
13
-
14
- it "returns a Result::Duration object" do
15
- timer = Timer.new.start
16
- expect( timer.duration ).to be_duration 1
17
- end
18
-
19
- it "would be slow to test" do
20
- # so we won't
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,262 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'report_api_spy'
3
- require 'cucumber/core'
4
- require 'cucumber/core/filter'
5
- require 'cucumber/core/gherkin/writer'
6
- require 'cucumber/core/platform'
7
- require 'cucumber/core/report/summary'
8
- require 'cucumber/core/test/around_hook'
9
- require 'cucumber/core/test/filters/activate_steps_for_self_test'
10
-
11
- module Cucumber
12
- describe Core do
13
- include Core
14
- include Core::Gherkin::Writer
15
-
16
- describe "compiling features to a test suite" do
17
-
18
- it "compiles two scenarios into two test cases" do
19
- visitor = ReportAPISpy.new
20
-
21
- compile([
22
- gherkin do
23
- feature do
24
- background do
25
- step 'text'
26
- end
27
- scenario do
28
- step 'text'
29
- end
30
- scenario do
31
- step 'text'
32
- step 'text'
33
- end
34
- end
35
- end
36
- ], visitor)
37
-
38
- expect( visitor.messages ).to eq [
39
- :test_case,
40
- :test_step,
41
- :test_step,
42
- :test_case,
43
- :test_step,
44
- :test_step,
45
- :test_step,
46
- :done,
47
- ]
48
- end
49
-
50
- it "filters out test cases based on a tag expression" do
51
- visitor = double.as_null_object
52
- expect( visitor ).to receive(:test_case) do |test_case|
53
- expect( test_case.name ).to eq 'foo'
54
- end.exactly(1).times
55
-
56
- gherkin = gherkin do
57
- feature do
58
- scenario tags: '@b' do
59
- step 'text'
60
- end
61
-
62
- scenario_outline 'foo' do
63
- step '<arg>'
64
-
65
- examples tags: '@a' do
66
- row 'arg'
67
- row 'x'
68
- end
69
-
70
- examples 'bar', tags: '@a @b' do
71
- row 'arg'
72
- row 'y'
73
- end
74
- end
75
- end
76
- end
77
-
78
- compile [gherkin], visitor, [Cucumber::Core::Test::TagFilter.new(['@a', '@b'])]
79
- end
80
- end
81
-
82
- describe "executing a test suite" do
83
-
84
- it "fires events" do
85
- gherkin = gherkin do
86
- feature 'Feature name' do
87
- scenario 'The one that passes' do
88
- step 'passing'
89
- end
90
-
91
- scenario 'The one that fails' do
92
- step 'passing'
93
- step 'failing'
94
- step 'passing'
95
- step 'undefined'
96
- end
97
- end
98
- end
99
-
100
- observed_events = []
101
- execute [gherkin], [Core::Test::Filters::ActivateStepsForSelfTest.new] do |event_bus|
102
- event_bus.on(:test_case_started) do |event|
103
- test_case = event.test_case
104
- observed_events << [:test_case_started, test_case.name]
105
- end
106
- event_bus.on(:test_case_finished) do |event|
107
- test_case, result = *event.attributes
108
- observed_events << [:test_case_finished, test_case.name, result.to_sym]
109
- end
110
- event_bus.on(:test_step_started) do |event|
111
- test_step = event.test_step
112
- observed_events << [:test_step_started, test_step.text]
113
- end
114
- event_bus.on(:test_step_finished) do |event|
115
- test_step, result = *event.attributes
116
- observed_events << [:test_step_finished, test_step.text, result.to_sym]
117
- end
118
- end
119
-
120
- expect(observed_events).to eq [
121
- [:test_case_started, 'The one that passes'],
122
- [:test_step_started, 'passing'],
123
- [:test_step_finished, 'passing', :passed],
124
- [:test_case_finished, 'The one that passes', :passed],
125
- [:test_case_started, 'The one that fails'],
126
- [:test_step_started, 'passing'],
127
- [:test_step_finished, 'passing', :passed],
128
- [:test_step_started, 'failing'],
129
- [:test_step_finished, 'failing', :failed],
130
- [:test_step_started, 'passing'],
131
- [:test_step_finished, 'passing', :skipped],
132
- [:test_step_started, 'undefined'],
133
- [:test_step_finished, 'undefined', :undefined],
134
- [:test_case_finished, 'The one that fails', :failed],
135
- ]
136
- end
137
-
138
- context "without hooks" do
139
- it "executes the test cases in the suite" do
140
- gherkin = gherkin do
141
- feature 'Feature name' do
142
- scenario 'The one that passes' do
143
- step 'passing'
144
- end
145
-
146
- scenario 'The one that fails' do
147
- step 'passing'
148
- step 'failing'
149
- step 'passing'
150
- step 'undefined'
151
- end
152
- end
153
- end
154
-
155
- event_bus = Core::EventBus.new
156
- report = Core::Report::Summary.new(event_bus)
157
- execute [gherkin], [Core::Test::Filters::ActivateStepsForSelfTest.new], event_bus
158
-
159
- expect( report.test_cases.total ).to eq 2
160
- expect( report.test_cases.total_passed ).to eq 1
161
- expect( report.test_cases.total_failed ).to eq 1
162
- expect( report.test_steps.total ).to eq 5
163
- expect( report.test_steps.total_failed ).to eq 1
164
- expect( report.test_steps.total_passed ).to eq 2
165
- expect( report.test_steps.total_skipped ).to eq 1
166
- expect( report.test_steps.total_undefined ).to eq 1
167
- end
168
- end
169
-
170
- context "with around hooks" do
171
- class WithAroundHooks < Core::Filter.new(:logger)
172
- def test_case(test_case)
173
- base_step = Core::Test::Step.new('some-random-uid', 'text', nil, nil, nil)
174
- test_steps = [
175
- base_step.with_action { logger << :step },
176
- ]
177
-
178
- around_hook = Core::Test::AroundHook.new do |run_scenario|
179
- logger << :before_all
180
- run_scenario.call
181
- logger << :middle
182
- run_scenario.call
183
- logger << :after_all
184
- end
185
- test_case.with_steps(test_steps).with_around_hooks([around_hook]).describe_to(receiver)
186
- end
187
- end
188
-
189
- it "executes the test cases in the suite" do
190
- gherkin = gherkin do
191
- feature do
192
- scenario do
193
- step 'text'
194
- end
195
- end
196
- end
197
- logger = []
198
-
199
- event_bus = Core::EventBus.new
200
- report = Core::Report::Summary.new(event_bus)
201
- execute [gherkin], [WithAroundHooks.new(logger)], event_bus
202
-
203
- expect( report.test_cases.total ).to eq 1
204
- expect( report.test_cases.total_passed ).to eq 1
205
- expect( report.test_cases.total_failed ).to eq 0
206
- expect( logger ).to eq [
207
- :before_all,
208
- :step,
209
- :middle,
210
- :step,
211
- :after_all
212
- ]
213
- end
214
- end
215
-
216
- require 'cucumber/core/test/filters'
217
- it "filters test cases by tag" do
218
- gherkin = gherkin do
219
- feature do
220
- scenario do
221
- step 'text'
222
- end
223
-
224
- scenario tags: '@a @b' do
225
- step 'text'
226
- end
227
-
228
- scenario tags: '@a' do
229
- step 'text'
230
- end
231
- end
232
- end
233
-
234
- event_bus = Core::EventBus.new
235
- report = Core::Report::Summary.new(event_bus)
236
- execute [gherkin], [ Cucumber::Core::Test::TagFilter.new(['@a']) ], event_bus
237
-
238
- expect( report.test_cases.total ).to eq 2
239
- end
240
-
241
- it "filters test cases by name" do
242
- gherkin = gherkin do
243
- feature 'first feature' do
244
- scenario 'first scenario' do
245
- step 'missing'
246
- end
247
- scenario 'second' do
248
- step 'missing'
249
- end
250
- end
251
- end
252
-
253
- event_bus = Core::EventBus.new
254
- report = Core::Report::Summary.new(event_bus)
255
- execute [gherkin], [ Cucumber::Core::Test::NameFilter.new([/scenario/]) ], event_bus
256
-
257
- expect( report.test_cases.total ).to eq 1
258
- end
259
-
260
- end
261
- end
262
- end