@@ -49,8 +49,7 @@ module Cucumber::Core::Test
49
49
specify { expect ( result ) . not_to be_flaky }
50
50
51
51
specify { expect ( result ) . to be_ok }
52
- specify { expect ( result . ok? ( false ) ) . to be_truthy }
53
- specify { expect ( result . ok? ( true ) ) . to be_truthy }
52
+ specify { expect ( result . ok? ) . to be_truthy }
54
53
end
55
54
56
55
describe Result ::Failed do
@@ -109,8 +108,7 @@ module Cucumber::Core::Test
109
108
specify { expect ( result ) . not_to be_flaky }
110
109
111
110
specify { expect ( result ) . to_not be_ok }
112
- specify { expect ( result . ok? ( false ) ) . to be_falsey }
113
- specify { expect ( result . ok? ( true ) ) . to be_falsey }
111
+ specify { expect ( result . ok? ) . to be_falsey }
114
112
end
115
113
116
114
describe Result ::Unknown do
@@ -202,8 +200,9 @@ module Cucumber::Core::Test
202
200
specify { expect ( result ) . not_to be_flaky }
203
201
204
202
specify { expect ( result ) . to be_ok }
205
- specify { expect ( result . ok? ( false ) ) . to be_truthy }
206
- specify { expect ( result . ok? ( true ) ) . to be_falsey }
203
+ specify { expect ( result . ok? ) . to be_truthy }
204
+ be_strict = Result ::StrictConfiguration . new ( [ :undefined ] )
205
+ specify { expect ( result . ok? ( be_strict ) ) . to be_falsey }
207
206
end
208
207
209
208
describe Result ::Skipped do
@@ -225,8 +224,7 @@ module Cucumber::Core::Test
225
224
specify { expect ( result ) . not_to be_flaky }
226
225
227
226
specify { expect ( result ) . to be_ok }
228
- specify { expect ( result . ok? ( false ) ) . to be_truthy }
229
- specify { expect ( result . ok? ( true ) ) . to be_truthy }
227
+ specify { expect ( result . ok? ) . to be_truthy }
230
228
end
231
229
232
230
describe Result ::Pending do
@@ -249,15 +247,87 @@ module Cucumber::Core::Test
249
247
specify { expect ( result ) . to be_pending }
250
248
251
249
specify { expect ( result ) . to be_ok }
252
- specify { expect ( result . ok? ( false ) ) . to be_truthy }
253
- specify { expect ( result . ok? ( true ) ) . to be_falsey }
250
+ specify { expect ( result . ok? ) . to be_truthy }
251
+ be_strict = Result ::StrictConfiguration . new ( [ :pending ] )
252
+ specify { expect ( result . ok? ( be_strict ) ) . to be_falsey }
254
253
end
255
254
256
255
describe Result ::Flaky do
257
256
specify { expect ( Result ::Flaky . ok? ( false ) ) . to be_truthy }
258
257
specify { expect ( Result ::Flaky . ok? ( true ) ) . to be_falsey }
259
258
end
260
259
260
+ describe Result ::StrictConfiguration do
261
+ subject ( :strict_configuration ) { Result ::StrictConfiguration . new }
262
+
263
+ describe '#set_strict' do
264
+ context 'no type argument' do
265
+ it 'sets all result types to the setting argument' do
266
+ strict_configuration . set_strict ( true )
267
+ expect ( strict_configuration . strict? ( :undefined ) ) . to be_truthy
268
+ expect ( strict_configuration . strict? ( :pending ) ) . to be_truthy
269
+ expect ( strict_configuration . strict? ( :flaky ) ) . to be_truthy
270
+
271
+ strict_configuration . set_strict ( false )
272
+ expect ( strict_configuration . strict? ( :undefined ) ) . to be_falsey
273
+ expect ( strict_configuration . strict? ( :pending ) ) . to be_falsey
274
+ expect ( strict_configuration . strict? ( :flaky ) ) . to be_falsey
275
+ end
276
+ end
277
+ context 'with type argument' do
278
+ it 'sets the specified result type to the setting argument' do
279
+ strict_configuration . set_strict ( true , :undefined )
280
+ expect ( strict_configuration . strict? ( :undefined ) ) . to be_truthy
281
+ expect ( strict_configuration . set? ( :pending ) ) . to be_falsey
282
+ expect ( strict_configuration . set? ( :flaky ) ) . to be_falsey
283
+
284
+ strict_configuration . set_strict ( false , :undefined )
285
+ expect ( strict_configuration . strict? ( :undefined ) ) . to be_falsey
286
+ expect ( strict_configuration . set? ( :pending ) ) . to be_falsey
287
+ expect ( strict_configuration . set? ( :flaky ) ) . to be_falsey
288
+ end
289
+ end
290
+ end
291
+
292
+ describe '#strict?' do
293
+ context 'no type argument' do
294
+ it 'returns true if any result type is set to strict' do
295
+ strict_configuration . set_strict ( false , :pending )
296
+ expect ( strict_configuration . strict? ) . to be_falsey
297
+
298
+ strict_configuration . set_strict ( true , :flaky )
299
+ expect ( strict_configuration . strict? ) . to be_truthy
300
+ end
301
+ end
302
+ context 'with type argument' do
303
+ it 'returns true if the specified result type is set to strict' do
304
+ strict_configuration . set_strict ( false , :pending )
305
+ strict_configuration . set_strict ( true , :flaky )
306
+
307
+ expect ( strict_configuration . strict? ( :undefined ) ) . to be_falsey
308
+ expect ( strict_configuration . strict? ( :pending ) ) . to be_falsey
309
+ expect ( strict_configuration . strict? ( :flaky ) ) . to be_truthy
310
+ end
311
+ end
312
+ end
313
+
314
+ describe '#merge!' do
315
+ let ( :merged_configuration ) { Result ::StrictConfiguration . new }
316
+ it 'sets the not default values from the argument accordingly' do
317
+ strict_configuration . set_strict ( false , :undefined )
318
+ strict_configuration . set_strict ( false , :pending )
319
+ strict_configuration . set_strict ( true , :flaky )
320
+ merged_configuration . set_strict ( true , :pending )
321
+ merged_configuration . set_strict ( false , :flaky )
322
+ strict_configuration . merge! ( merged_configuration )
323
+
324
+ expect ( strict_configuration . strict? ( :undefined ) ) . to be_falsey
325
+ expect ( strict_configuration . strict? ( :pending ) ) . to be_truthy
326
+ expect ( strict_configuration . strict? ( :flaky ) ) . to be_falsey
327
+ end
328
+ end
329
+ end
330
+
261
331
describe Result ::Summary do
262
332
let ( :summary ) { Result ::Summary . new }
263
333
let ( :failed ) { Result ::Failed . new ( Result ::Duration . new ( 10 ) , exception ) }
@@ -360,19 +430,22 @@ def describe_to(visitor, *args)
360
430
it "pending result is ok if not strict" do
361
431
pending . describe_to summary
362
432
expect ( summary . ok? ) . to be true
363
- expect ( summary . ok? ( true ) ) . to be false
433
+ be_strict = Result ::StrictConfiguration . new ( [ :pending ] )
434
+ expect ( summary . ok? ( be_strict ) ) . to be false
364
435
end
365
436
366
437
it "undefined result is ok if not strict" do
367
438
undefined . describe_to summary
368
439
expect ( summary . ok? ) . to be true
369
- expect ( summary . ok? ( true ) ) . to be false
440
+ be_strict = Result ::StrictConfiguration . new ( [ :undefined ] )
441
+ expect ( summary . ok? ( be_strict ) ) . to be false
370
442
end
371
443
372
444
it "flaky result is ok if not strict" do
373
445
summary . flaky
374
446
expect ( summary . ok? ) . to be true
375
- expect ( summary . ok? ( true ) ) . to be false
447
+ be_strict = Result ::StrictConfiguration . new ( [ :flaky ] )
448
+ expect ( summary . ok? ( be_strict ) ) . to be false
376
449
end
377
450
end
378
451
end
0 commit comments