cucumber-core 3.0.0 → 3.1.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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cucumber/core/version.rb +1 -1
  3. metadata +19 -85
  4. data/.coveralls.yml +0 -1
  5. data/.github/ISSUE_TEMPLATE.md +0 -48
  6. data/.github/PULL_REQUEST_TEMPLATE.md +0 -39
  7. data/.rspec +0 -1
  8. data/.ruby-gemset +0 -1
  9. data/.travis.yml +0 -30
  10. data/.yardopts +0 -6
  11. data/Gemfile +0 -2
  12. data/Rakefile +0 -28
  13. data/cucumber-core.gemspec +0 -36
  14. data/spec/capture_warnings.rb +0 -74
  15. data/spec/coverage.rb +0 -11
  16. data/spec/cucumber/core/ast/background_spec.rb +0 -11
  17. data/spec/cucumber/core/ast/data_table_spec.rb +0 -81
  18. data/spec/cucumber/core/ast/doc_string_spec.rb +0 -114
  19. data/spec/cucumber/core/ast/empty_multiline_argument_spec.rb +0 -28
  20. data/spec/cucumber/core/ast/examples_table_spec.rb +0 -113
  21. data/spec/cucumber/core/ast/location_spec.rb +0 -199
  22. data/spec/cucumber/core/ast/outline_step_spec.rb +0 -93
  23. data/spec/cucumber/core/ast/step_spec.rb +0 -174
  24. data/spec/cucumber/core/compiler_spec.rb +0 -267
  25. data/spec/cucumber/core/event_bus_spec.rb +0 -163
  26. data/spec/cucumber/core/event_spec.rb +0 -40
  27. data/spec/cucumber/core/filter_spec.rb +0 -101
  28. data/spec/cucumber/core/gherkin/parser_spec.rb +0 -261
  29. data/spec/cucumber/core/gherkin/writer_spec.rb +0 -333
  30. data/spec/cucumber/core/report/summary_spec.rb +0 -175
  31. data/spec/cucumber/core/test/action_spec.rb +0 -154
  32. data/spec/cucumber/core/test/case_spec.rb +0 -316
  33. data/spec/cucumber/core/test/duration_matcher.rb +0 -20
  34. data/spec/cucumber/core/test/filters/locations_filter_spec.rb +0 -405
  35. data/spec/cucumber/core/test/result_spec.rb +0 -474
  36. data/spec/cucumber/core/test/runner_spec.rb +0 -310
  37. data/spec/cucumber/core/test/step_spec.rb +0 -98
  38. data/spec/cucumber/core/test/timer_spec.rb +0 -25
  39. data/spec/cucumber/core_spec.rb +0 -262
  40. data/spec/readme_spec.rb +0 -37
  41. data/spec/report_api_spy.rb +0 -25
@@ -1,310 +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(:test_case) { Case.new(test_steps, source) }
11
- let(:source) { [double('ast node', location: double)] }
12
- let(:runner) { Runner.new(event_bus) }
13
- let(:event_bus) { double.as_null_object }
14
- let(:passing) { Step.new([source]).with_action {} }
15
- let(:failing) { Step.new([source]).with_action { raise exception } }
16
- let(:pending) { Step.new([source]).with_action { raise Result::Pending.new("TODO") } }
17
- let(:skipping) { Step.new([source]).with_action { raise Result::Skipped.new } }
18
- let(:undefined) { Step.new([source]) }
19
- let(:exception) { StandardError.new('test error') }
20
-
21
- before do
22
- allow(event_bus).to receive(:test_case_started)
23
- allow(source).to receive(:location)
24
- end
25
-
26
- context "reporting the duration of a test case" do
27
- before do
28
- allow( Timer::MonotonicTime ).to receive(:time_in_nanoseconds).and_return(525702744080000, 525702744080001)
29
- end
30
-
31
- context "for a passing test case" do
32
- let(:test_steps) { [passing] }
33
-
34
- it "records the nanoseconds duration of the execution on the result" do
35
- expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
36
- expect( result.duration ).to be_duration 1
37
- end
38
- test_case.describe_to runner
39
- end
40
- end
41
-
42
- context "for a failing test case" do
43
- let(:test_steps) { [failing] }
44
-
45
- it "records the duration" do
46
- expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
47
- expect(result.duration).to be_duration 1
48
- end
49
- test_case.describe_to runner
50
- end
51
- end
52
- end
53
-
54
- context "reporting the exception that failed a test case" do
55
- let(:test_steps) { [failing] }
56
- it "sets the exception on the result" do
57
- allow(event_bus).to receive(:before_test_case)
58
- expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
59
- expect( result.exception ).to eq exception
60
- end
61
- test_case.describe_to runner
62
- end
63
- end
64
-
65
- context "with a single case" do
66
- context "without steps" do
67
- let(:test_steps) { [] }
68
-
69
- it "emits a test_case_started event before running the test case" do
70
- expect(event_bus).to receive(:test_case_started).with(test_case)
71
- test_case.describe_to runner
72
- end
73
-
74
- it "emits the test_case_finished event after running the the test case" do
75
- expect(event_bus).to receive(:test_case_finished) do |reported_test_case, result|
76
- expect( reported_test_case ).to eq test_case
77
- expect( result ).to be_unknown
78
- end
79
- test_case.describe_to runner
80
- end
81
- end
82
-
83
- context 'with steps' do
84
- context 'that all pass' do
85
- let(:test_steps) { [ passing, passing ] }
86
-
87
- it 'emits the test_case_finished event with a passing result' do
88
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
89
- expect( result ).to be_passed
90
- end
91
- test_case.describe_to runner
92
- end
93
- end
94
-
95
- context 'an undefined step' do
96
- let(:test_steps) { [ undefined ] }
97
-
98
- it 'emits the test_case_finished event with an undefined result' do
99
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
100
- expect( result ).to be_undefined
101
- end
102
- allow( undefined.source.last ).to receive(:text)
103
- test_case.describe_to runner
104
- end
105
-
106
- it 'sets the message on the result' do
107
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
108
- expect( result.message ).to eq("Undefined step: \"step name\"")
109
- end
110
- expect( undefined.source.last ).to receive(:text).and_return("step name")
111
- test_case.describe_to runner
112
- end
113
-
114
- it 'appends the backtrace of the result' do
115
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
116
- expect( result.backtrace ).to eq(["step line"])
117
- end
118
- expect( undefined.source.last ).to receive(:backtrace_line).and_return("step line")
119
- allow( undefined.source.last ).to receive(:text)
120
- test_case.describe_to runner
121
- end
122
- end
123
-
124
- context 'a pending step' do
125
- let(:test_steps) { [ pending ] }
126
-
127
- it 'emits the test_case_finished event with a pending result' do
128
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
129
- expect( result ).to be_pending
130
- end
131
- test_case.describe_to runner
132
- end
133
-
134
- it 'appends the backtrace of the result' do
135
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
136
- expect( result.backtrace.last ).to eq("step line")
137
- end
138
- expect( pending.source.last ).to receive(:backtrace_line).and_return("step line")
139
- test_case.describe_to runner
140
- end
141
- end
142
-
143
- context "a skipping step" do
144
- let(:test_steps) { [skipping] }
145
-
146
- it "emits the test_case_finished event with a skipped result" do
147
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
148
- expect( result ).to be_skipped
149
- end
150
- test_case.describe_to runner
151
- end
152
-
153
- it 'appends the backtrace of the result' do
154
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
155
- expect( result.backtrace.last ).to eq("step line")
156
- end
157
- expect( skipping.source.last ).to receive(:backtrace_line).and_return("step line")
158
- test_case.describe_to runner
159
- end
160
- end
161
-
162
- context 'that fail' do
163
- let(:test_steps) { [ failing ] }
164
-
165
- it 'emits the test_case_finished event with a failing result' do
166
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
167
- expect( result ).to be_failed
168
- end
169
- test_case.describe_to runner
170
- end
171
-
172
- it 'appends the backtrace of the exception of the result' do
173
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
174
- expect( result.exception.backtrace.last ).to eq("step line")
175
- end
176
- expect( failing.source.last ).to receive(:backtrace_line).and_return("step line")
177
- test_case.describe_to runner
178
- end
179
- end
180
-
181
- context 'where the first step fails' do
182
- let(:test_steps) { [ failing, passing ] }
183
-
184
- it 'emits the test_step_finished event with a failed result' do
185
- expect(event_bus).to receive(:test_step_finished).with(failing, anything) do |test_step, result|
186
- expect( result ).to be_failed
187
- end
188
- test_case.describe_to runner
189
- end
190
-
191
- it 'emits a test_step_finished event with a skipped result' do
192
- expect(event_bus).to receive(:test_step_finished).with(passing, anything) do |test_step, result|
193
- expect( result ).to be_skipped
194
- end
195
- test_case.describe_to runner
196
- end
197
-
198
- it 'emits a test_case_finished event with a failed result' do
199
- expect(event_bus).to receive(:test_case_finished) do |test_case, result|
200
- expect( result ).to be_failed
201
- expect( result.exception ).to eq exception
202
- end
203
- test_case.describe_to runner
204
- end
205
-
206
- it 'skips, rather than executing the second step' do
207
- expect( passing ).not_to receive(:execute)
208
- expect( passing ).to receive(:skip)
209
- test_case.describe_to runner
210
- end
211
- end
212
-
213
- end
214
- end
215
-
216
- context 'with multiple test cases' do
217
- context 'when the first test case fails' do
218
- let(:first_test_case) { Case.new([failing], source) }
219
- let(:last_test_case) { Case.new([passing], source) }
220
- let(:test_cases) { [first_test_case, last_test_case] }
221
-
222
- it 'reports the results correctly for the following test case' do
223
- expect(event_bus).to receive(:test_case_finished) { |reported_test_case, result|
224
- expect(result).to be_failed if reported_test_case.equal?(first_test_case)
225
- expect(result).to be_passed if reported_test_case.equal?(last_test_case)
226
- }.twice
227
-
228
- test_cases.each { |c| c.describe_to runner }
229
- end
230
- end
231
- end
232
-
233
- context "passing latest result to a mapping" do
234
- it "passes a Failed result when the scenario is failing" do
235
- result_spy = nil
236
- hook_mapping = UnskippableAction.new do |last_result|
237
- result_spy = last_result
238
- end
239
- after_hook = Step.new([source], hook_mapping)
240
- failing_step = Step.new([source]).with_action { fail }
241
- test_case = Case.new([failing_step, after_hook], source)
242
- test_case.describe_to runner
243
- expect(result_spy).to be_failed
244
- end
245
- end
246
-
247
- require 'cucumber/core/test/around_hook'
248
- context "with around hooks" do
249
- it "passes normally when around hooks don't fail" do
250
- around_hook = AroundHook.new { |block| block.call }
251
- passing_step = Step.new([source]).with_action {}
252
- test_case = Case.new([passing_step], source, [around_hook])
253
- expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
254
- expect(result).to be_passed
255
- end
256
- test_case.describe_to runner
257
- end
258
-
259
- it "gets a failed result if the Around hook fails before the test case is run" do
260
- around_hook = AroundHook.new { |block| raise exception }
261
- passing_step = Step.new([source]).with_action {}
262
- test_case = Case.new([passing_step], source, [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_failed
265
- expect(result.exception).to eq exception
266
- end
267
- test_case.describe_to runner
268
- end
269
-
270
- it "gets a failed result if the Around hook fails after the test case is run" do
271
- around_hook = AroundHook.new { |block| block.call; raise exception }
272
- passing_step = Step.new([source]).with_action {}
273
- test_case = Case.new([passing_step], source, [around_hook])
274
- expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
275
- expect(result).to be_failed
276
- expect(result.exception).to eq exception
277
- end
278
- test_case.describe_to runner
279
- end
280
-
281
- it "fails when a step fails if the around hook works" do
282
- around_hook = AroundHook.new { |block| block.call }
283
- failing_step = Step.new([source]).with_action { raise exception }
284
- test_case = Case.new([failing_step], source, [around_hook])
285
- expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
286
- expect(result).to be_failed
287
- expect(result.exception).to eq exception
288
- end
289
- test_case.describe_to runner
290
- end
291
-
292
- it "sends after_test_step for a step interrupted by (a timeout in) the around hook" do
293
- around_hook = AroundHook.new { |block| block.call; raise exception }
294
- passing_step = Step.new([source]).with_action {}
295
- test_case = Case.new([], source, [around_hook])
296
- allow(runner).to receive(:running_test_step).and_return(passing_step)
297
- expect(event_bus).to receive(:test_step_finished).with(passing_step, anything) do |reported_test_case, result|
298
- expect(result).to be_failed
299
- expect(result.exception).to eq exception
300
- end
301
- expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
302
- expect(result).to be_failed
303
- expect(result.exception).to eq exception
304
- end
305
- test_case.describe_to runner
306
- end
307
- end
308
-
309
- end
310
- end
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core/test/step'
3
-
4
- module Cucumber::Core::Test
5
- describe Step do
6
-
7
- describe "describing itself" do
8
- let(:step_or_hook) { double }
9
- before(:each) do
10
- allow( step_or_hook ).to receive(:location)
11
- end
12
-
13
- it "describes itself to a visitor" do
14
- visitor = double
15
- args = double
16
- test_step = Step.new([step_or_hook])
17
- expect( visitor ).to receive(:test_step).with(test_step, args)
18
- test_step.describe_to(visitor, args)
19
- end
20
-
21
- it "describes its source to a visitor" do
22
- feature, scenario = double, double
23
- visitor = double
24
- args = double
25
- expect( feature ).to receive(:describe_to).with(visitor, args)
26
- expect( scenario ).to receive(:describe_to).with(visitor, args)
27
- expect( step_or_hook ).to receive(:describe_to).with(visitor, args)
28
- test_step = Step.new([feature, scenario, step_or_hook])
29
- test_step.describe_source_to(visitor, args)
30
- end
31
- end
32
-
33
- describe "executing" do
34
- let(:ast_step) { double }
35
- before(:each) do
36
- allow( ast_step ).to receive(:location)
37
- end
38
-
39
- it "passes arbitrary arguments to the action's block" do
40
- args_spy = nil
41
- expected_args = [double, double]
42
- test_step = Step.new([ast_step]).with_action do |*actual_args|
43
- args_spy = actual_args
44
- end
45
- test_step.execute(*expected_args)
46
- expect(args_spy).to eq expected_args
47
- end
48
-
49
- context "when a passing action exists" do
50
- it "returns a passing result" do
51
- test_step = Step.new([ast_step]).with_action {}
52
- expect( test_step.execute ).to be_passed
53
- end
54
- end
55
-
56
- context "when a failing action exists" do
57
- let(:exception) { StandardError.new('oops') }
58
-
59
- it "returns a failing result" do
60
- test_step = Step.new([ast_step]).with_action { raise exception }
61
- result = test_step.execute
62
- expect( result ).to be_failed
63
- expect( result.exception ).to eq exception
64
- end
65
- end
66
-
67
- context "with no action" do
68
- it "returns an Undefined result" do
69
- test_step = Step.new([ast_step])
70
- result = test_step.execute
71
- expect( result ).to be_undefined
72
- end
73
- end
74
- end
75
-
76
- it "exposes the text and location of the AST step or hook as attributes" do
77
- text, location = double, double
78
- step_or_hook = double(text: text, location: location)
79
- test_step = Step.new([step_or_hook])
80
- expect( test_step.text ).to eq text
81
- expect( test_step.location ).to eq location
82
- end
83
-
84
- it "exposes the location of the action as attribute" do
85
- location = double
86
- action = double(location: location)
87
- test_step = Step.new([double], action)
88
- expect( test_step.action_location ).to eq location
89
- end
90
-
91
- it "returns the text of the AST step when converted to a string" do
92
- ast_step = double(text: 'a passing step', location: double)
93
- test_step = Step.new([ast_step])
94
- expect( test_step.to_s ).to eq 'a passing step'
95
- end
96
-
97
- end
98
- 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
26
- end
27
- scenario do
28
- step
29
- end
30
- scenario do
31
- step
32
- step
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, bar (#1)'
54
- end.exactly(1).times
55
-
56
- gherkin = gherkin do
57
- feature do
58
- scenario tags: '@b' do
59
- step
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(test_case.source)
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
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
222
- end
223
-
224
- scenario tags: '@a @b' do
225
- step
226
- end
227
-
228
- scenario tags: '@a' do
229
- step
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