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,504 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- # frozen_string_literal: true
3
- require 'cucumber/core/test/result'
4
- require 'cucumber/core/test/duration_matcher'
5
-
6
- module Cucumber::Core::Test
7
- describe Result do
8
-
9
- let(:visitor) { double('visitor') }
10
- let(:args) { double('args') }
11
-
12
- describe Result::Passed do
13
- subject(:result) { Result::Passed.new(duration) }
14
- let(:duration) { Result::Duration.new(1 * 1000 * 1000) }
15
-
16
- it "describes itself to a visitor" do
17
- expect( visitor ).to receive(:passed).with(args)
18
- expect( visitor ).to receive(:duration).with(duration, args)
19
- result.describe_to(visitor, args)
20
- end
21
-
22
- it "converts to a string" do
23
- expect( result.to_s ).to eq "✓"
24
- end
25
-
26
- it "converts to a Cucumber::Message::TestResult" do
27
- message = result.to_message
28
- expect(message.status).to eq(Cucumber::Messages::TestStepResultStatus::PASSED)
29
- end
30
-
31
- it "has a duration" do
32
- expect( result.duration ).to eq duration
33
- end
34
-
35
- it "requires the constructor argument" do
36
- expect { Result::Passed.new }.to raise_error(ArgumentError)
37
- end
38
-
39
- it "does nothing when appending the backtrace" do
40
- expect( result.with_appended_backtrace(double) ).to equal result
41
- end
42
-
43
- it "does nothing when filtering the backtrace" do
44
- expect( result.with_filtered_backtrace(double) ).to equal result
45
- end
46
-
47
- specify { expect( result.to_sym ).to eq :passed }
48
-
49
- specify { expect( result ).to be_passed }
50
- specify { expect( result ).not_to be_failed }
51
- specify { expect( result ).not_to be_undefined }
52
- specify { expect( result ).not_to be_unknown }
53
- specify { expect( result ).not_to be_skipped }
54
- specify { expect( result ).not_to be_flaky }
55
-
56
- specify { expect( result ).to be_ok }
57
- specify { expect( result.ok? ).to be_truthy }
58
- end
59
-
60
- describe Result::Failed do
61
- subject(:result) { Result::Failed.new(duration, exception) }
62
- let(:duration) { Result::Duration.new(1 * 1000 * 1000) }
63
- let(:exception) { StandardError.new("error message") }
64
-
65
- it "describes itself to a visitor" do
66
- expect( visitor ).to receive(:failed).with(args)
67
- expect( visitor ).to receive(:duration).with(duration, args)
68
- expect( visitor ).to receive(:exception).with(exception, args)
69
- result.describe_to(visitor, args)
70
- end
71
-
72
- it "has a duration" do
73
- expect( result.duration ).to eq duration
74
- end
75
-
76
- it "converts to a Cucumber::Message::TestResult" do
77
- message = result.to_message
78
- expect(message.status).to eq(Cucumber::Messages::TestStepResultStatus::FAILED)
79
- end
80
-
81
- it "requires both constructor arguments" do
82
- expect { Result::Failed.new }.to raise_error(ArgumentError)
83
- expect { Result::Failed.new(duration) }.to raise_error(ArgumentError)
84
- end
85
-
86
- it "does nothing if step has no backtrace line" do
87
- result.exception.set_backtrace("exception backtrace")
88
- step = "does not respond_to?(:backtrace_line)"
89
-
90
- expect( result.with_appended_backtrace(step).exception.backtrace ).to eq(["exception backtrace"])
91
- end
92
-
93
- it "appends the backtrace line of the step" do
94
- result.exception.set_backtrace("exception backtrace")
95
- step = double
96
- expect( step ).to receive(:backtrace_line).and_return("step_line")
97
-
98
- expect( result.with_appended_backtrace(step).exception.backtrace ).to eq(["exception backtrace", "step_line"])
99
- end
100
-
101
- it "apply filters to the exception" do
102
- filter_class = double
103
- filter = double
104
- filtered_exception = double
105
- expect( filter_class ).to receive(:new).with(result.exception).and_return(filter)
106
- expect( filter ).to receive(:exception).and_return(filtered_exception)
107
-
108
- expect( result.with_filtered_backtrace(filter_class).exception ).to equal filtered_exception
109
- end
110
-
111
- specify { expect( result.to_sym ).to eq :failed }
112
-
113
- specify { expect( result ).not_to be_passed }
114
- specify { expect( result ).to be_failed }
115
- specify { expect( result ).not_to be_undefined }
116
- specify { expect( result ).not_to be_unknown }
117
- specify { expect( result ).not_to be_skipped }
118
- specify { expect( result ).not_to be_flaky }
119
-
120
- specify { expect( result ).to_not be_ok }
121
- specify { expect( result.ok? ).to be_falsey }
122
- end
123
-
124
- describe Result::Unknown do
125
- subject(:result) { Result::Unknown.new }
126
-
127
- it "doesn't describe itself to a visitor" do
128
- visitor = double('never receives anything')
129
- result.describe_to(visitor, args)
130
- end
131
-
132
- it "defines a with_filtered_backtrace method" do
133
- expect(result.with_filtered_backtrace(double("filter"))).to eql result
134
- end
135
-
136
- specify { expect( result.to_sym ).to eq :unknown }
137
-
138
- specify { expect( result ).not_to be_passed }
139
- specify { expect( result ).not_to be_failed }
140
- specify { expect( result ).not_to be_undefined }
141
- specify { expect( result ).to be_unknown }
142
- specify { expect( result ).not_to be_skipped }
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::TestStepResultStatus::UNKNOWN)
148
- end
149
- end
150
-
151
- describe Result::Raisable do
152
- context "with or without backtrace" do
153
- subject(:result) { Result::Raisable.new }
154
-
155
- it "does nothing if step has no backtrace line" do
156
- step = "does not respond_to?(:backtrace_line)"
157
-
158
- expect( result.with_appended_backtrace(step).backtrace ).to eq(nil)
159
- end
160
- end
161
-
162
- context "without backtrace" do
163
- subject(:result) { Result::Raisable.new }
164
-
165
- it "set the backtrace to the backtrace line of the step" do
166
- step = double
167
- expect( step ).to receive(:backtrace_line).and_return("step_line")
168
-
169
- expect( result.with_appended_backtrace(step).backtrace ).to eq(["step_line"])
170
- end
171
-
172
- it "does nothing when filtering the backtrace" do
173
- expect( result.with_filtered_backtrace(double) ).to equal result
174
- end
175
- end
176
-
177
- context "with backtrace" do
178
- subject(:result) { Result::Raisable.new("message", 0, "backtrace") }
179
-
180
- it "appends the backtrace line of the step" do
181
- step = double
182
- expect( step ).to receive(:backtrace_line).and_return("step_line")
183
-
184
- expect( result.with_appended_backtrace(step).backtrace ).to eq(["backtrace", "step_line"])
185
- end
186
-
187
- it "apply filters to the backtrace" do
188
- filter_class = double
189
- filter = double
190
- filtered_result = double
191
- expect( filter_class ).to receive(:new).with(result.exception).and_return(filter)
192
- expect( filter ).to receive(:exception).and_return(filtered_result)
193
-
194
- expect( result.with_filtered_backtrace(filter_class) ).to equal filtered_result
195
- end
196
- end
197
- end
198
-
199
- describe Result::Undefined do
200
- subject(:result) { Result::Undefined.new }
201
-
202
- it "describes itself to a visitor" do
203
- expect( visitor ).to receive(:undefined).with(args)
204
- expect( visitor ).to receive(:duration).with(an_unknown_duration, args)
205
- result.describe_to(visitor, args)
206
- end
207
-
208
- it "converts to a Cucumber::Message::TestResult" do
209
- message = result.to_message
210
- expect(message.status).to eq(Cucumber::Messages::TestStepResultStatus::UNDEFINED)
211
- end
212
-
213
- specify { expect( result.to_sym ).to eq :undefined }
214
-
215
- specify { expect( result ).not_to be_passed }
216
- specify { expect( result ).not_to be_failed }
217
- specify { expect( result ).to be_undefined }
218
- specify { expect( result ).not_to be_unknown }
219
- specify { expect( result ).not_to be_skipped }
220
- specify { expect( result ).not_to be_flaky }
221
-
222
- specify { expect( result ).to be_ok }
223
- specify { expect( result.ok? ).to be_truthy }
224
- be_strict = Result::StrictConfiguration.new([:undefined])
225
- specify { expect( result.ok?(be_strict) ).to be_falsey }
226
- end
227
-
228
- describe Result::Skipped do
229
- subject(:result) { Result::Skipped.new }
230
-
231
- it "describes itself to a visitor" do
232
- expect( visitor ).to receive(:skipped).with(args)
233
- expect( visitor ).to receive(:duration).with(an_unknown_duration, args)
234
- result.describe_to(visitor, args)
235
- end
236
-
237
- it "converts to a Cucumber::Message::TestResult" do
238
- message = result.to_message
239
- expect(message.status).to eq(Cucumber::Messages::TestStepResultStatus::SKIPPED)
240
- end
241
-
242
- specify { expect( result.to_sym ).to eq :skipped }
243
-
244
- specify { expect( result ).not_to be_passed }
245
- specify { expect( result ).not_to be_failed }
246
- specify { expect( result ).not_to be_undefined }
247
- specify { expect( result ).not_to be_unknown }
248
- specify { expect( result ).to be_skipped }
249
- specify { expect( result ).not_to be_flaky }
250
-
251
- specify { expect( result ).to be_ok }
252
- specify { expect( result.ok? ).to be_truthy }
253
- end
254
-
255
- describe Result::Pending do
256
- subject(:result) { Result::Pending.new }
257
-
258
- it "describes itself to a visitor" do
259
- expect( visitor ).to receive(:pending).with(result, args)
260
- expect( visitor ).to receive(:duration).with(an_unknown_duration, args)
261
- result.describe_to(visitor, args)
262
- end
263
-
264
- it "converts to a Cucumber::Message::TestResult" do
265
- message = result.to_message
266
- expect(message.status).to eq(Cucumber::Messages::TestStepResultStatus::PENDING)
267
- end
268
-
269
- specify { expect( result.to_sym ).to eq :pending }
270
-
271
- specify { expect( result ).not_to be_passed }
272
- specify { expect( result ).not_to be_failed }
273
- specify { expect( result ).not_to be_undefined }
274
- specify { expect( result ).not_to be_unknown }
275
- specify { expect( result ).not_to be_skipped }
276
- specify { expect( result ).not_to be_flaky }
277
- specify { expect( result ).to be_pending }
278
-
279
- specify { expect( result ).to be_ok }
280
- specify { expect( result.ok? ).to be_truthy }
281
- be_strict = Result::StrictConfiguration.new([:pending])
282
- specify { expect( result.ok?(be_strict) ).to be_falsey }
283
- end
284
-
285
- describe Result::Flaky do
286
- specify { expect( Result::Flaky.ok?(false) ).to be_truthy }
287
- specify { expect( Result::Flaky.ok?(true) ).to be_falsey }
288
- end
289
-
290
- describe Result::StrictConfiguration do
291
- subject(:strict_configuration) { Result::StrictConfiguration.new}
292
-
293
- describe '#set_strict' do
294
- context 'no type argument' do
295
- it 'sets all result types to the setting argument' do
296
- strict_configuration.set_strict(true)
297
- expect( strict_configuration.strict?(:undefined) ).to be_truthy
298
- expect( strict_configuration.strict?(:pending) ).to be_truthy
299
- expect( strict_configuration.strict?(:flaky) ).to be_truthy
300
-
301
- strict_configuration.set_strict(false)
302
- expect( strict_configuration.strict?(:undefined) ).to be_falsey
303
- expect( strict_configuration.strict?(:pending) ).to be_falsey
304
- expect( strict_configuration.strict?(:flaky) ).to be_falsey
305
- end
306
- end
307
- context 'with type argument' do
308
- it 'sets the specified result type to the setting argument' do
309
- strict_configuration.set_strict(true, :undefined)
310
- expect( strict_configuration.strict?(:undefined) ).to be_truthy
311
- expect( strict_configuration.set?(:pending) ).to be_falsey
312
- expect( strict_configuration.set?(:flaky) ).to be_falsey
313
-
314
- strict_configuration.set_strict(false, :undefined)
315
- expect( strict_configuration.strict?(:undefined) ).to be_falsey
316
- expect( strict_configuration.set?(:pending) ).to be_falsey
317
- expect( strict_configuration.set?(:flaky) ).to be_falsey
318
- end
319
- end
320
- end
321
-
322
- describe '#strict?' do
323
- context 'no type argument' do
324
- it 'returns true if any result type is set to strict' do
325
- strict_configuration.set_strict(false, :pending)
326
- expect( strict_configuration.strict? ).to be_falsey
327
-
328
- strict_configuration.set_strict(true, :flaky)
329
- expect( strict_configuration.strict? ).to be_truthy
330
- end
331
- end
332
- context 'with type argument' do
333
- it 'returns true if the specified result type is set to strict' do
334
- strict_configuration.set_strict(false, :pending)
335
- strict_configuration.set_strict(true, :flaky)
336
-
337
- expect( strict_configuration.strict?(:undefined) ).to be_falsey
338
- expect( strict_configuration.strict?(:pending) ).to be_falsey
339
- expect( strict_configuration.strict?(:flaky) ).to be_truthy
340
- end
341
- end
342
- end
343
-
344
- describe '#merge!' do
345
- let(:merged_configuration) { Result::StrictConfiguration.new }
346
- it 'sets the not default values from the argument accordingly' do
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
357
- end
358
- end
359
- end
360
-
361
- describe Result::Summary do
362
- let(:summary) { Result::Summary.new }
363
- let(:failed) { Result::Failed.new(Result::Duration.new(10), exception) }
364
- let(:passed) { Result::Passed.new(Result::Duration.new(11)) }
365
- let(:skipped) { Result::Skipped.new }
366
- let(:unknown) { Result::Unknown.new }
367
- let(:pending) { Result::Pending.new }
368
- let(:undefined) { Result::Undefined.new }
369
- let(:exception) { StandardError.new }
370
-
371
- it "counts failed results" do
372
- failed.describe_to summary
373
- expect( summary.total_failed ).to eq 1
374
- expect( summary.total(:failed) ).to eq 1
375
- expect( summary.total ).to eq 1
376
- end
377
-
378
- it "counts passed results" do
379
- passed.describe_to summary
380
- expect( summary.total_passed ).to eq 1
381
- expect( summary.total(:passed) ).to eq 1
382
- expect( summary.total ).to eq 1
383
- end
384
-
385
- it "counts skipped results" do
386
- skipped.describe_to summary
387
- expect( summary.total_skipped ).to eq 1
388
- expect( summary.total(:skipped) ).to eq 1
389
- expect( summary.total ).to eq 1
390
- end
391
-
392
- it "counts undefined results" do
393
- undefined.describe_to summary
394
- expect( summary.total_undefined ).to eq 1
395
- expect( summary.total(:undefined) ).to eq 1
396
- expect( summary.total ).to eq 1
397
- end
398
-
399
- it "counts abitrary raisable results" do
400
- flickering = Class.new(Result::Raisable) do
401
- def describe_to(visitor, *args)
402
- visitor.flickering(*args)
403
- end
404
- end
405
-
406
- flickering.new.describe_to summary
407
- expect( summary.total_flickering ).to eq 1
408
- expect( summary.total(:flickering) ).to eq 1
409
- expect( summary.total ).to eq 1
410
- end
411
-
412
- it "returns zero for a status where no messges have been received" do
413
- expect( summary.total_passed ).to eq 0
414
- expect( summary.total(:passed) ).to eq 0
415
- expect( summary.total_ponies ).to eq 0
416
- expect( summary.total(:ponies) ).to eq 0
417
- end
418
-
419
- it "doesn't count unknown results" do
420
- unknown.describe_to summary
421
- expect( summary.total ).to eq 0
422
- end
423
-
424
- it "counts combinations" do
425
- [passed, passed, failed, skipped, undefined].each { |r| r.describe_to summary }
426
- expect( summary.total ).to eq 5
427
- expect( summary.total_passed ).to eq 2
428
- expect( summary.total_failed ).to eq 1
429
- expect( summary.total_skipped ).to eq 1
430
- expect( summary.total_undefined ).to eq 1
431
- end
432
-
433
- it "records durations" do
434
- [passed, failed].each { |r| r.describe_to summary }
435
- expect( summary.durations[0] ).to be_duration 11
436
- expect( summary.durations[1] ).to be_duration 10
437
- end
438
-
439
- it "records exceptions" do
440
- [passed, failed].each { |r| r.describe_to summary }
441
- expect( summary.exceptions ).to eq [exception]
442
- end
443
-
444
- context "ok? result" do
445
- it "passed result is ok" do
446
- passed.describe_to summary
447
- expect( summary.ok? ).to be true
448
- end
449
-
450
- it "skipped result is ok" do
451
- skipped.describe_to summary
452
- expect( summary.ok? ).to be true
453
- end
454
-
455
- it "failed result is not ok" do
456
- failed.describe_to summary
457
- expect( summary.ok? ).to be false
458
- end
459
-
460
- it "pending result is ok if not strict" do
461
- pending.describe_to summary
462
- expect( summary.ok? ).to be true
463
- be_strict = Result::StrictConfiguration.new([:pending])
464
- expect( summary.ok?(be_strict) ).to be false
465
- end
466
-
467
- it "undefined result is ok if not strict" do
468
- undefined.describe_to summary
469
- expect( summary.ok? ).to be true
470
- be_strict = Result::StrictConfiguration.new([:undefined])
471
- expect( summary.ok?(be_strict) ).to be false
472
- end
473
-
474
- it "flaky result is ok if not strict" do
475
- summary.flaky
476
- expect( summary.ok? ).to be true
477
- be_strict = Result::StrictConfiguration.new([:flaky])
478
- expect( summary.ok?(be_strict) ).to be false
479
- end
480
- end
481
- end
482
-
483
- describe Result::Duration do
484
- subject(:duration) { Result::Duration.new(10) }
485
-
486
- it "#nanoseconds can be accessed in #tap" do
487
- expect( duration.tap { |duration| @duration = duration.nanoseconds } ).to eq duration
488
- expect( @duration ).to eq 10
489
- end
490
- end
491
-
492
- describe Result::UnknownDuration do
493
- subject(:duration) { Result::UnknownDuration.new }
494
-
495
- it "#tap does not execute the passed block" do
496
- expect( duration.tap { raise "tap executed block" } ).to eq duration
497
- end
498
-
499
- it "accessing #nanoseconds outside #tap block raises exception" do
500
- expect { duration.nanoseconds }.to raise_error(RuntimeError)
501
- end
502
- end
503
- end
504
- end