flipper 0.27.1 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,17 +7,17 @@ RSpec.describe Flipper do
7
7
  let(:admin_group) { flipper.group(:admins) }
8
8
  let(:dev_group) { flipper.group(:devs) }
9
9
 
10
- let(:admin_thing) do
10
+ let(:admin_actor) do
11
11
  double 'Non Flipper Thing', flipper_id: 1, admin?: true, dev?: false
12
12
  end
13
- let(:dev_thing) do
13
+ let(:dev_actor) do
14
14
  double 'Non Flipper Thing', flipper_id: 10, admin?: false, dev?: true
15
15
  end
16
16
 
17
- let(:admin_truthy_thing) do
17
+ let(:admin_truthy_actor) do
18
18
  double 'Non Flipper Thing', flipper_id: 1, admin?: 'true-ish', dev?: false
19
19
  end
20
- let(:admin_falsey_thing) do
20
+ let(:admin_falsey_actor) do
21
21
  double 'Non Flipper Thing', flipper_id: 1, admin?: nil, dev?: false
22
22
  end
23
23
 
@@ -60,20 +60,20 @@ RSpec.describe Flipper do
60
60
  expect(@result).to eq(true)
61
61
  end
62
62
 
63
- it 'enables feature for non flipper thing in group' do
64
- expect(feature.enabled?(admin_thing)).to eq(true)
63
+ it 'enables feature for non flipper actor in group' do
64
+ expect(feature.enabled?(admin_actor)).to eq(true)
65
65
  end
66
66
 
67
- it 'does not enable feature for non flipper thing in other group' do
68
- expect(feature.enabled?(dev_thing)).to eq(false)
67
+ it 'does not enable feature for non flipper actor in other group' do
68
+ expect(feature.enabled?(dev_actor)).to eq(false)
69
69
  end
70
70
 
71
71
  it 'enables feature for flipper actor in group' do
72
- expect(feature.enabled?(flipper.actor(admin_thing))).to eq(true)
72
+ expect(feature.enabled?(flipper.actor(admin_actor))).to eq(true)
73
73
  end
74
74
 
75
75
  it 'does not enable for flipper actor not in group' do
76
- expect(feature.enabled?(flipper.actor(dev_thing))).to eq(false)
76
+ expect(feature.enabled?(flipper.actor(dev_actor))).to eq(false)
77
77
  end
78
78
 
79
79
  it 'does not enable feature for all' do
@@ -118,8 +118,8 @@ RSpec.describe Flipper do
118
118
 
119
119
  it 'enables feature for actor within percentage' do
120
120
  enabled = (1..100).select do |i|
121
- thing = Flipper::Actor.new(i)
122
- feature.enabled?(thing)
121
+ actor = Flipper::Actor.new(i)
122
+ feature.enabled?(actor)
123
123
  end.size
124
124
 
125
125
  expect(enabled).to be_within(2).of(5)
@@ -141,8 +141,8 @@ RSpec.describe Flipper do
141
141
 
142
142
  it 'enables feature for actor within percentage' do
143
143
  enabled = (1..100).select do |i|
144
- thing = Flipper::Actor.new(i)
145
- feature.enabled?(thing)
144
+ actor = Flipper::Actor.new(i)
145
+ feature.enabled?(actor)
146
146
  end.size
147
147
 
148
148
  expect(enabled).to be_within(2).of(5)
@@ -180,10 +180,10 @@ RSpec.describe Flipper do
180
180
 
181
181
  context 'with argument that has no gate' do
182
182
  it 'raises error' do
183
- thing = Object.new
183
+ actor = Object.new
184
184
  expect do
185
- feature.enable(thing)
186
- end.to raise_error(Flipper::GateNotFound, "Could not find gate for #{thing.inspect}")
185
+ feature.enable(actor)
186
+ end.to raise_error(Flipper::GateNotFound, "Could not find gate for #{actor.inspect}")
187
187
  end
188
188
  end
189
189
  end
@@ -215,13 +215,13 @@ RSpec.describe Flipper do
215
215
  end
216
216
 
217
217
  it 'disables actor in group' do
218
- expect(feature.enabled?(admin_thing)).to eq(false)
218
+ expect(feature.enabled?(admin_actor)).to eq(false)
219
219
  end
220
220
 
221
221
  it 'disables actor in percentage of actors' do
222
222
  enabled = (1..100).select do |i|
223
- thing = Flipper::Actor.new(i)
224
- feature.enabled?(thing)
223
+ actor = Flipper::Actor.new(i)
224
+ feature.enabled?(actor)
225
225
  end.size
226
226
 
227
227
  expect(enabled).to be(0)
@@ -247,20 +247,20 @@ RSpec.describe Flipper do
247
247
  expect(@result).to eq(true)
248
248
  end
249
249
 
250
- it 'disables the feature for non flipper thing in the group' do
251
- expect(feature.enabled?(admin_thing)).to eq(false)
250
+ it 'disables the feature for non flipper actor in the group' do
251
+ expect(feature.enabled?(admin_actor)).to eq(false)
252
252
  end
253
253
 
254
- it 'does not disable feature for non flipper thing in other groups' do
255
- expect(feature.enabled?(dev_thing)).to eq(true)
254
+ it 'does not disable feature for non flipper actor in other groups' do
255
+ expect(feature.enabled?(dev_actor)).to eq(true)
256
256
  end
257
257
 
258
258
  it 'disables feature for flipper actor in group' do
259
- expect(feature.enabled?(flipper.actor(admin_thing))).to eq(false)
259
+ expect(feature.enabled?(flipper.actor(admin_actor))).to eq(false)
260
260
  end
261
261
 
262
262
  it 'does not disable feature for flipper actor in other groups' do
263
- expect(feature.enabled?(flipper.actor(dev_thing))).to eq(true)
263
+ expect(feature.enabled?(flipper.actor(dev_actor))).to eq(true)
264
264
  end
265
265
 
266
266
  it 'adds feature to set of features' do
@@ -303,8 +303,8 @@ RSpec.describe Flipper do
303
303
 
304
304
  it 'disables feature' do
305
305
  enabled = (1..100).select do |i|
306
- thing = Flipper::Actor.new(i)
307
- feature.enabled?(thing)
306
+ actor = Flipper::Actor.new(i)
307
+ feature.enabled?(actor)
308
308
  end.size
309
309
 
310
310
  expect(enabled).to be(0)
@@ -342,10 +342,10 @@ RSpec.describe Flipper do
342
342
 
343
343
  context 'with argument that has no gate' do
344
344
  it 'raises error' do
345
- thing = Object.new
345
+ actor = Object.new
346
346
  expect do
347
- feature.disable(thing)
348
- end.to raise_error(Flipper::GateNotFound, "Could not find gate for #{thing.inspect}")
347
+ feature.disable(actor)
348
+ end.to raise_error(Flipper::GateNotFound, "Could not find gate for #{actor.inspect}")
349
349
  end
350
350
  end
351
351
  end
@@ -373,23 +373,27 @@ RSpec.describe Flipper do
373
373
  end
374
374
 
375
375
  it 'returns true' do
376
- expect(feature.enabled?(flipper.actor(admin_thing))).to eq(true)
377
- expect(feature.enabled?(admin_thing)).to eq(true)
376
+ expect(feature.enabled?(flipper.actor(admin_actor))).to eq(true)
377
+ expect(feature.enabled?(admin_actor)).to eq(true)
378
378
  end
379
379
 
380
380
  it 'returns true for truthy block values' do
381
- expect(feature.enabled?(flipper.actor(admin_truthy_thing))).to eq(true)
381
+ expect(feature.enabled?(flipper.actor(admin_truthy_actor))).to eq(true)
382
+ end
383
+
384
+ it 'returns true if any actor is in enabled group' do
385
+ expect(feature.enabled?(dev_actor, admin_actor)).to be(true)
382
386
  end
383
387
  end
384
388
 
385
389
  context 'for actor in disabled group' do
386
390
  it 'returns false' do
387
- expect(feature.enabled?(flipper.actor(dev_thing))).to eq(false)
388
- expect(feature.enabled?(dev_thing)).to eq(false)
391
+ expect(feature.enabled?(flipper.actor(dev_actor))).to eq(false)
392
+ expect(feature.enabled?(dev_actor)).to eq(false)
389
393
  end
390
394
 
391
395
  it 'returns false for falsey block values' do
392
- expect(feature.enabled?(flipper.actor(admin_falsey_thing))).to eq(false)
396
+ expect(feature.enabled?(flipper.actor(admin_falsey_actor))).to eq(false)
393
397
  end
394
398
  end
395
399
 
@@ -408,6 +412,10 @@ RSpec.describe Flipper do
408
412
  expect(feature.enabled?(clooney)).to eq(false)
409
413
  end
410
414
 
415
+ it 'returns false if all actors are disabled' do
416
+ expect(feature.enabled?(clooney, pitt)).to be(false)
417
+ end
418
+
411
419
  it 'returns true if boolean enabled' do
412
420
  feature.enable
413
421
  expect(feature.enabled?(clooney)).to eq(true)
@@ -428,7 +436,7 @@ RSpec.describe Flipper do
428
436
  expect(feature.enabled?).to eq(true)
429
437
  expect(feature.enabled?(nil)).to eq(true)
430
438
  expect(feature.enabled?(pitt)).to eq(true)
431
- expect(feature.enabled?(admin_thing)).to eq(true)
439
+ expect(feature.enabled?(admin_actor)).to eq(true)
432
440
  end
433
441
  end
434
442
 
@@ -446,7 +454,7 @@ RSpec.describe Flipper do
446
454
  expect(feature.enabled?).to eq(true)
447
455
  expect(feature.enabled?(nil)).to eq(true)
448
456
  expect(feature.enabled?(pitt)).to eq(true)
449
- expect(feature.enabled?(admin_thing)).to eq(true)
457
+ expect(feature.enabled?(admin_actor)).to eq(true)
450
458
  end
451
459
  end
452
460
 
@@ -463,7 +471,7 @@ RSpec.describe Flipper do
463
471
  expect(feature.enabled?).to eq(false)
464
472
  expect(feature.enabled?(nil)).to eq(false)
465
473
  expect(feature.enabled?(pitt)).to eq(false)
466
- expect(feature.enabled?(admin_thing)).to eq(false)
474
+ expect(feature.enabled?(admin_actor)).to eq(false)
467
475
  end
468
476
 
469
477
  it 'returns true if boolean enabled' do
@@ -471,7 +479,7 @@ RSpec.describe Flipper do
471
479
  expect(feature.enabled?).to eq(true)
472
480
  expect(feature.enabled?(nil)).to eq(true)
473
481
  expect(feature.enabled?(pitt)).to eq(true)
474
- expect(feature.enabled?(admin_thing)).to eq(true)
482
+ expect(feature.enabled?(admin_actor)).to eq(true)
475
483
  end
476
484
  end
477
485
 
@@ -488,7 +496,7 @@ RSpec.describe Flipper do
488
496
  expect(feature.enabled?).to eq(false)
489
497
  expect(feature.enabled?(nil)).to eq(false)
490
498
  expect(feature.enabled?(pitt)).to eq(false)
491
- expect(feature.enabled?(admin_thing)).to eq(false)
499
+ expect(feature.enabled?(admin_actor)).to eq(false)
492
500
  end
493
501
 
494
502
  it 'returns true if boolean enabled' do
@@ -496,27 +504,31 @@ RSpec.describe Flipper do
496
504
  expect(feature.enabled?).to eq(true)
497
505
  expect(feature.enabled?(nil)).to eq(true)
498
506
  expect(feature.enabled?(pitt)).to eq(true)
499
- expect(feature.enabled?(admin_thing)).to eq(true)
507
+ expect(feature.enabled?(admin_actor)).to eq(true)
500
508
  end
501
509
  end
502
510
 
503
- context 'for a non flipper thing' do
511
+ context 'for a non flipper actor' do
504
512
  before do
505
513
  feature.enable admin_group
506
514
  end
507
515
 
508
516
  it 'returns true if in enabled group' do
509
- expect(feature.enabled?(admin_thing)).to eq(true)
517
+ expect(feature.enabled?(admin_actor)).to eq(true)
510
518
  end
511
519
 
512
520
  it 'returns false if not in enabled group' do
513
- expect(feature.enabled?(dev_thing)).to eq(false)
521
+ expect(feature.enabled?(dev_actor)).to eq(false)
522
+ end
523
+
524
+ it 'retruns true if any actor is true' do
525
+ expect(feature.enabled?(admin_actor, dev_actor)).to eq(true)
514
526
  end
515
527
 
516
528
  it 'returns true if boolean enabled' do
517
529
  feature.enable
518
- expect(feature.enabled?(admin_thing)).to eq(true)
519
- expect(feature.enabled?(dev_thing)).to eq(true)
530
+ expect(feature.enabled?(admin_actor)).to eq(true)
531
+ expect(feature.enabled?(dev_actor)).to eq(true)
520
532
  end
521
533
  end
522
534
  end
@@ -530,11 +542,11 @@ RSpec.describe Flipper do
530
542
  end
531
543
 
532
544
  it 'enables feature for object in enabled group' do
533
- expect(feature.enabled?(admin_thing)).to eq(true)
545
+ expect(feature.enabled?(admin_actor)).to eq(true)
534
546
  end
535
547
 
536
548
  it 'does not enable feature for object in not enabled group' do
537
- expect(feature.enabled?(dev_thing)).to eq(false)
549
+ expect(feature.enabled?(dev_actor)).to eq(false)
538
550
  end
539
551
  end
540
552
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.1
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-20 00:00:00.000000000 Z
11
+ date: 2023-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -45,6 +45,7 @@ files:
45
45
  - README.md
46
46
  - Rakefile
47
47
  - benchmark/enabled_ips.rb
48
+ - benchmark/enabled_multiple_actors_ips.rb
48
49
  - benchmark/enabled_profile.rb
49
50
  - benchmark/instrumentation_ips.rb
50
51
  - benchmark/typecast_ips.rb