flipper 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/Gemfile +1 -1
- data/docs/Adapters.md +2 -1
- data/examples/enabled_for_actor.rb +43 -0
- data/lib/flipper/spec/shared_adapter_specs.rb +71 -71
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/adapters/instrumented_spec.rb +44 -44
- data/spec/flipper/adapters/memoizable_spec.rb +21 -21
- data/spec/flipper/adapters/memory_spec.rb +1 -1
- data/spec/flipper/adapters/operation_logger_spec.rb +11 -11
- data/spec/flipper/adapters/pstore_spec.rb +2 -2
- data/spec/flipper/dsl_spec.rb +34 -34
- data/spec/flipper/feature_spec.rb +167 -167
- data/spec/flipper/gate_spec.rb +5 -5
- data/spec/flipper/gate_values_spec.rb +17 -17
- data/spec/flipper/gates/actor_spec.rb +1 -1
- data/spec/flipper/gates/boolean_spec.rb +13 -13
- data/spec/flipper/gates/group_spec.rb +6 -6
- data/spec/flipper/gates/percentage_of_actors_spec.rb +3 -3
- data/spec/flipper/gates/percentage_of_time_spec.rb +1 -1
- data/spec/flipper/instrumentation/log_subscriber_spec.rb +10 -10
- data/spec/flipper/instrumentation/metriks_subscriber_spec.rb +14 -14
- data/spec/flipper/instrumentation/statsd_subscriber_spec.rb +5 -3
- data/spec/flipper/instrumenters/memory_spec.rb +4 -4
- data/spec/flipper/instrumenters/noop_spec.rb +3 -3
- data/spec/flipper/middleware/memoizer_spec.rb +8 -8
- data/spec/flipper/registry_spec.rb +17 -17
- data/spec/flipper/typecast_spec.rb +4 -4
- data/spec/flipper/types/actor_spec.rb +14 -14
- data/spec/flipper/types/boolean_spec.rb +5 -5
- data/spec/flipper/types/group_spec.rb +8 -8
- data/spec/flipper/types/percentage_of_actors_spec.rb +1 -1
- data/spec/flipper/types/percentage_of_time_spec.rb +1 -1
- data/spec/flipper/types/percentage_spec.rb +8 -8
- data/spec/flipper_spec.rb +19 -19
- data/spec/helper.rb +14 -14
- data/spec/integration_spec.rb +80 -80
- metadata +4 -3
@@ -3,7 +3,7 @@ require 'flipper/feature'
|
|
3
3
|
require 'flipper/adapters/memory'
|
4
4
|
require 'flipper/instrumenters/memory'
|
5
5
|
|
6
|
-
describe Flipper::Feature do
|
6
|
+
RSpec.describe Flipper::Feature do
|
7
7
|
subject { described_class.new(:search, adapter) }
|
8
8
|
|
9
9
|
let(:adapter) { Flipper::Adapters::Memory.new }
|
@@ -11,17 +11,17 @@ describe Flipper::Feature do
|
|
11
11
|
describe "#initialize" do
|
12
12
|
it "sets name" do
|
13
13
|
feature = described_class.new(:search, adapter)
|
14
|
-
feature.name.
|
14
|
+
expect(feature.name).to eq(:search)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "sets adapter" do
|
18
18
|
feature = described_class.new(:search, adapter)
|
19
|
-
feature.adapter.
|
19
|
+
expect(feature.adapter).to eq(adapter)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "defaults instrumenter" do
|
23
23
|
feature = described_class.new(:search, adapter)
|
24
|
-
feature.instrumenter.
|
24
|
+
expect(feature.instrumenter).to be(Flipper::Instrumenters::Noop)
|
25
25
|
end
|
26
26
|
|
27
27
|
context "with overriden instrumenter" do
|
@@ -31,7 +31,7 @@ describe Flipper::Feature do
|
|
31
31
|
feature = described_class.new(:search, adapter, {
|
32
32
|
:instrumenter => instrumenter,
|
33
33
|
})
|
34
|
-
feature.instrumenter.
|
34
|
+
expect(feature.instrumenter).to be(instrumenter)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -39,14 +39,14 @@ describe Flipper::Feature do
|
|
39
39
|
describe "#to_s" do
|
40
40
|
it "returns name as string" do
|
41
41
|
feature = described_class.new(:search, adapter)
|
42
|
-
feature.to_s.
|
42
|
+
expect(feature.to_s).to eq("search")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "#to_param" do
|
47
47
|
it "returns name as string" do
|
48
48
|
feature = described_class.new(:search, adapter)
|
49
|
-
feature.to_param.
|
49
|
+
expect(feature.to_param).to eq("search")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -55,7 +55,7 @@ describe Flipper::Feature do
|
|
55
55
|
it "returns percentage of actors gate" do
|
56
56
|
percentage = Flipper::Types::PercentageOfActors.new(10)
|
57
57
|
gate = subject.gate_for(percentage)
|
58
|
-
gate.
|
58
|
+
expect(gate).to be_instance_of(Flipper::Gates::PercentageOfActors)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -63,30 +63,30 @@ describe Flipper::Feature do
|
|
63
63
|
describe "#gates" do
|
64
64
|
it "returns array of gates" do
|
65
65
|
instance = described_class.new(:search, adapter)
|
66
|
-
instance.gates.
|
66
|
+
expect(instance.gates).to be_instance_of(Array)
|
67
67
|
instance.gates.each do |gate|
|
68
|
-
gate.
|
68
|
+
expect(gate).to be_a(Flipper::Gate)
|
69
69
|
end
|
70
|
-
instance.gates.size.
|
70
|
+
expect(instance.gates.size).to be(5)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
describe "#gate" do
|
75
75
|
context "with symbol name" do
|
76
76
|
it "returns gate by name" do
|
77
|
-
subject.gate(:boolean).
|
77
|
+
expect(subject.gate(:boolean)).to be_instance_of(Flipper::Gates::Boolean)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
context "with string name" do
|
82
82
|
it "returns gate by name" do
|
83
|
-
subject.gate('boolean').
|
83
|
+
expect(subject.gate('boolean')).to be_instance_of(Flipper::Gates::Boolean)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
context "with name that does not exist" do
|
88
88
|
it "returns nil" do
|
89
|
-
subject.gate(:poo).
|
89
|
+
expect(subject.gate(:poo)).to be_nil
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
@@ -94,16 +94,16 @@ describe Flipper::Feature do
|
|
94
94
|
describe "#inspect" do
|
95
95
|
it "returns easy to read string representation" do
|
96
96
|
string = subject.inspect
|
97
|
-
string.
|
98
|
-
string.
|
99
|
-
string.
|
100
|
-
string.
|
101
|
-
string.
|
97
|
+
expect(string).to include('Flipper::Feature')
|
98
|
+
expect(string).to include('name=:search')
|
99
|
+
expect(string).to include('state=:off')
|
100
|
+
expect(string).to include('enabled_gate_names=[]')
|
101
|
+
expect(string).to include("adapter=#{subject.adapter.name.inspect}")
|
102
102
|
|
103
103
|
subject.enable
|
104
104
|
string = subject.inspect
|
105
|
-
string.
|
106
|
-
string.
|
105
|
+
expect(string).to include('state=:on')
|
106
|
+
expect(string).to include('enabled_gate_names=[:boolean]')
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -121,12 +121,12 @@ describe Flipper::Feature do
|
|
121
121
|
subject.enable(thing)
|
122
122
|
|
123
123
|
event = instrumenter.events.last
|
124
|
-
event.
|
125
|
-
event.name.
|
126
|
-
event.payload[:feature_name].
|
127
|
-
event.payload[:operation].
|
128
|
-
event.payload[:thing].
|
129
|
-
event.payload[:result].
|
124
|
+
expect(event).not_to be_nil
|
125
|
+
expect(event.name).to eq('feature_operation.flipper')
|
126
|
+
expect(event.payload[:feature_name]).to eq(:search)
|
127
|
+
expect(event.payload[:operation]).to eq(:enable)
|
128
|
+
expect(event.payload[:thing]).to eq(thing)
|
129
|
+
expect(event.payload[:result]).not_to be_nil
|
130
130
|
end
|
131
131
|
|
132
132
|
it "always instruments flipper type instance for enable" do
|
@@ -136,8 +136,8 @@ describe Flipper::Feature do
|
|
136
136
|
subject.enable(thing)
|
137
137
|
|
138
138
|
event = instrumenter.events.last
|
139
|
-
event.
|
140
|
-
event.payload[:thing].
|
139
|
+
expect(event).not_to be_nil
|
140
|
+
expect(event.payload[:thing]).to eq(Flipper::Types::Actor.new(thing))
|
141
141
|
end
|
142
142
|
|
143
143
|
it "is recorded for disable" do
|
@@ -147,12 +147,12 @@ describe Flipper::Feature do
|
|
147
147
|
subject.disable(thing)
|
148
148
|
|
149
149
|
event = instrumenter.events.last
|
150
|
-
event.
|
151
|
-
event.name.
|
152
|
-
event.payload[:feature_name].
|
153
|
-
event.payload[:operation].
|
154
|
-
event.payload[:thing].
|
155
|
-
event.payload[:result].
|
150
|
+
expect(event).not_to be_nil
|
151
|
+
expect(event.name).to eq('feature_operation.flipper')
|
152
|
+
expect(event.payload[:feature_name]).to eq(:search)
|
153
|
+
expect(event.payload[:operation]).to eq(:disable)
|
154
|
+
expect(event.payload[:thing]).to eq(thing)
|
155
|
+
expect(event.payload[:result]).not_to be_nil
|
156
156
|
end
|
157
157
|
|
158
158
|
user = Struct.new(:flipper_id).new("1")
|
@@ -179,9 +179,9 @@ describe Flipper::Feature do
|
|
179
179
|
subject.enable(thing)
|
180
180
|
|
181
181
|
event = instrumenter.events.last
|
182
|
-
event.
|
183
|
-
event.payload[:operation].
|
184
|
-
event.payload[:thing].
|
182
|
+
expect(event).not_to be_nil
|
183
|
+
expect(event.payload[:operation]).to eq(:enable)
|
184
|
+
expect(event.payload[:thing]).to eq(wrapped_thing)
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
@@ -192,9 +192,9 @@ describe Flipper::Feature do
|
|
192
192
|
subject.disable(thing)
|
193
193
|
|
194
194
|
event = instrumenter.events.last
|
195
|
-
event.
|
196
|
-
event.payload[:operation].
|
197
|
-
event.payload[:thing].
|
195
|
+
expect(event).not_to be_nil
|
196
|
+
expect(event.payload[:operation]).to eq(:disable)
|
197
|
+
expect(event.payload[:thing]).to eq(Flipper::Types::Actor.new(thing))
|
198
198
|
end
|
199
199
|
|
200
200
|
it "is recorded for enabled?" do
|
@@ -204,12 +204,12 @@ describe Flipper::Feature do
|
|
204
204
|
subject.enabled?(thing)
|
205
205
|
|
206
206
|
event = instrumenter.events.last
|
207
|
-
event.
|
208
|
-
event.name.
|
209
|
-
event.payload[:feature_name].
|
210
|
-
event.payload[:operation].
|
211
|
-
event.payload[:thing].
|
212
|
-
event.payload[:result].
|
207
|
+
expect(event).not_to be_nil
|
208
|
+
expect(event.name).to eq('feature_operation.flipper')
|
209
|
+
expect(event.payload[:feature_name]).to eq(:search)
|
210
|
+
expect(event.payload[:operation]).to eq(:enabled?)
|
211
|
+
expect(event.payload[:thing]).to eq(thing)
|
212
|
+
expect(event.payload[:result]).to eq(false)
|
213
213
|
end
|
214
214
|
|
215
215
|
user = Struct.new(:flipper_id).new("1")
|
@@ -223,9 +223,9 @@ describe Flipper::Feature do
|
|
223
223
|
subject.enabled?(thing)
|
224
224
|
|
225
225
|
event = instrumenter.events.last
|
226
|
-
event.
|
227
|
-
event.payload[:operation].
|
228
|
-
event.payload[:thing].
|
226
|
+
expect(event).not_to be_nil
|
227
|
+
expect(event.payload[:operation]).to eq(:enabled?)
|
228
|
+
expect(event.payload[:thing]).to eq(wrapped_thing)
|
229
229
|
end
|
230
230
|
end
|
231
231
|
end
|
@@ -237,19 +237,19 @@ describe Flipper::Feature do
|
|
237
237
|
end
|
238
238
|
|
239
239
|
it "returns :on" do
|
240
|
-
subject.state.
|
240
|
+
expect(subject.state).to be(:on)
|
241
241
|
end
|
242
242
|
|
243
243
|
it "returns true for on?" do
|
244
|
-
subject.on
|
244
|
+
expect(subject.on?).to be(true)
|
245
245
|
end
|
246
246
|
|
247
247
|
it "returns false for off?" do
|
248
|
-
subject.off
|
248
|
+
expect(subject.off?).to be(false)
|
249
249
|
end
|
250
250
|
|
251
251
|
it "returns false for conditional?" do
|
252
|
-
subject.conditional
|
252
|
+
expect(subject.conditional?).to be(false)
|
253
253
|
end
|
254
254
|
end
|
255
255
|
|
@@ -259,19 +259,19 @@ describe Flipper::Feature do
|
|
259
259
|
end
|
260
260
|
|
261
261
|
it "returns :on" do
|
262
|
-
subject.state.
|
262
|
+
expect(subject.state).to be(:on)
|
263
263
|
end
|
264
264
|
|
265
265
|
it "returns true for on?" do
|
266
|
-
subject.on
|
266
|
+
expect(subject.on?).to be(true)
|
267
267
|
end
|
268
268
|
|
269
269
|
it "returns false for off?" do
|
270
|
-
subject.off
|
270
|
+
expect(subject.off?).to be(false)
|
271
271
|
end
|
272
272
|
|
273
273
|
it "returns false for conditional?" do
|
274
|
-
subject.conditional
|
274
|
+
expect(subject.conditional?).to be(false)
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
@@ -281,19 +281,19 @@ describe Flipper::Feature do
|
|
281
281
|
end
|
282
282
|
|
283
283
|
it "returns :on" do
|
284
|
-
subject.state.
|
284
|
+
expect(subject.state).to be(:on)
|
285
285
|
end
|
286
286
|
|
287
287
|
it "returns true for on?" do
|
288
|
-
subject.on
|
288
|
+
expect(subject.on?).to be(true)
|
289
289
|
end
|
290
290
|
|
291
291
|
it "returns false for off?" do
|
292
|
-
subject.off
|
292
|
+
expect(subject.off?).to be(false)
|
293
293
|
end
|
294
294
|
|
295
295
|
it "returns false for conditional?" do
|
296
|
-
subject.conditional
|
296
|
+
expect(subject.conditional?).to be(false)
|
297
297
|
end
|
298
298
|
end
|
299
299
|
|
@@ -303,19 +303,19 @@ describe Flipper::Feature do
|
|
303
303
|
end
|
304
304
|
|
305
305
|
it "returns :off" do
|
306
|
-
subject.state.
|
306
|
+
expect(subject.state).to be(:off)
|
307
307
|
end
|
308
308
|
|
309
309
|
it "returns false for on?" do
|
310
|
-
subject.on
|
310
|
+
expect(subject.on?).to be(false)
|
311
311
|
end
|
312
312
|
|
313
313
|
it "returns true for off?" do
|
314
|
-
subject.off
|
314
|
+
expect(subject.off?).to be(true)
|
315
315
|
end
|
316
316
|
|
317
317
|
it "returns false for conditional?" do
|
318
|
-
subject.conditional
|
318
|
+
expect(subject.conditional?).to be(false)
|
319
319
|
end
|
320
320
|
end
|
321
321
|
|
@@ -325,19 +325,19 @@ describe Flipper::Feature do
|
|
325
325
|
end
|
326
326
|
|
327
327
|
it "returns :conditional" do
|
328
|
-
subject.state.
|
328
|
+
expect(subject.state).to be(:conditional)
|
329
329
|
end
|
330
330
|
|
331
331
|
it "returns false for on?" do
|
332
|
-
subject.on
|
332
|
+
expect(subject.on?).to be(false)
|
333
333
|
end
|
334
334
|
|
335
335
|
it "returns false for off?" do
|
336
|
-
subject.off
|
336
|
+
expect(subject.off?).to be(false)
|
337
337
|
end
|
338
338
|
|
339
339
|
it "returns true for conditional?" do
|
340
|
-
subject.conditional
|
340
|
+
expect(subject.conditional?).to be(true)
|
341
341
|
end
|
342
342
|
end
|
343
343
|
end
|
@@ -345,7 +345,7 @@ describe Flipper::Feature do
|
|
345
345
|
describe "#enabled_groups" do
|
346
346
|
context "when no groups enabled" do
|
347
347
|
it "returns empty set" do
|
348
|
-
subject.enabled_groups.
|
348
|
+
expect(subject.enabled_groups).to eq(Set.new)
|
349
349
|
end
|
350
350
|
end
|
351
351
|
|
@@ -361,22 +361,22 @@ describe Flipper::Feature do
|
|
361
361
|
end
|
362
362
|
|
363
363
|
it "returns set of enabled groups" do
|
364
|
-
subject.enabled_groups.
|
365
|
-
|
366
|
-
|
367
|
-
|
364
|
+
expect(subject.enabled_groups).to eq(Set.new([
|
365
|
+
@staff,
|
366
|
+
@preview_features,
|
367
|
+
]))
|
368
368
|
end
|
369
369
|
|
370
370
|
it "does not include groups that have not been enabled" do
|
371
|
-
subject.enabled_groups.
|
371
|
+
expect(subject.enabled_groups).not_to include(@not_enabled)
|
372
372
|
end
|
373
373
|
|
374
374
|
it "does not include disabled groups" do
|
375
|
-
subject.enabled_groups.
|
375
|
+
expect(subject.enabled_groups).not_to include(@disabled)
|
376
376
|
end
|
377
377
|
|
378
378
|
it "is aliased to groups" do
|
379
|
-
subject.enabled_groups.
|
379
|
+
expect(subject.enabled_groups).to eq(subject.groups)
|
380
380
|
end
|
381
381
|
end
|
382
382
|
end
|
@@ -384,7 +384,7 @@ describe Flipper::Feature do
|
|
384
384
|
describe "#disabled_groups" do
|
385
385
|
context "when no groups enabled" do
|
386
386
|
it "returns empty set" do
|
387
|
-
subject.disabled_groups.
|
387
|
+
expect(subject.disabled_groups).to eq(Set.new)
|
388
388
|
end
|
389
389
|
end
|
390
390
|
|
@@ -400,10 +400,10 @@ describe Flipper::Feature do
|
|
400
400
|
end
|
401
401
|
|
402
402
|
it "returns set of groups that are not enabled" do
|
403
|
-
subject.disabled_groups.
|
404
|
-
|
405
|
-
|
406
|
-
|
403
|
+
expect(subject.disabled_groups).to eq(Set[
|
404
|
+
@not_enabled,
|
405
|
+
@disabled,
|
406
|
+
])
|
407
407
|
end
|
408
408
|
end
|
409
409
|
end
|
@@ -411,7 +411,7 @@ describe Flipper::Feature do
|
|
411
411
|
describe "#groups_value" do
|
412
412
|
context "when no groups enabled" do
|
413
413
|
it "returns empty set" do
|
414
|
-
subject.groups_value.
|
414
|
+
expect(subject.groups_value).to eq(Set.new)
|
415
415
|
end
|
416
416
|
end
|
417
417
|
|
@@ -427,18 +427,18 @@ describe Flipper::Feature do
|
|
427
427
|
end
|
428
428
|
|
429
429
|
it "returns set of enabled groups" do
|
430
|
-
subject.groups_value.
|
431
|
-
|
432
|
-
|
433
|
-
|
430
|
+
expect(subject.groups_value).to eq(Set.new([
|
431
|
+
@staff.name.to_s,
|
432
|
+
@preview_features.name.to_s,
|
433
|
+
]))
|
434
434
|
end
|
435
435
|
|
436
436
|
it "does not include groups that have not been enabled" do
|
437
|
-
subject.groups_value.
|
437
|
+
expect(subject.groups_value).not_to include(@not_enabled.name.to_s)
|
438
438
|
end
|
439
439
|
|
440
440
|
it "does not include disabled groups" do
|
441
|
-
subject.groups_value.
|
441
|
+
expect(subject.groups_value).not_to include(@disabled.name.to_s)
|
442
442
|
end
|
443
443
|
end
|
444
444
|
end
|
@@ -446,7 +446,7 @@ describe Flipper::Feature do
|
|
446
446
|
describe "#actors_value" do
|
447
447
|
context "when no groups enabled" do
|
448
448
|
it "returns empty set" do
|
449
|
-
subject.actors_value.
|
449
|
+
expect(subject.actors_value).to eq(Set.new)
|
450
450
|
end
|
451
451
|
end
|
452
452
|
|
@@ -457,7 +457,7 @@ describe Flipper::Feature do
|
|
457
457
|
end
|
458
458
|
|
459
459
|
it "returns set of actor ids" do
|
460
|
-
subject.actors_value.
|
460
|
+
expect(subject.actors_value).to eq(Set.new(["User:5", "User:22"]))
|
461
461
|
end
|
462
462
|
end
|
463
463
|
end
|
@@ -465,7 +465,7 @@ describe Flipper::Feature do
|
|
465
465
|
describe "#boolean_value" do
|
466
466
|
context "when not enabled or disabled" do
|
467
467
|
it "returns false" do
|
468
|
-
subject.boolean_value.
|
468
|
+
expect(subject.boolean_value).to be(false)
|
469
469
|
end
|
470
470
|
end
|
471
471
|
|
@@ -475,7 +475,7 @@ describe Flipper::Feature do
|
|
475
475
|
end
|
476
476
|
|
477
477
|
it "returns true" do
|
478
|
-
subject.boolean_value.
|
478
|
+
expect(subject.boolean_value).to be(true)
|
479
479
|
end
|
480
480
|
end
|
481
481
|
|
@@ -485,7 +485,7 @@ describe Flipper::Feature do
|
|
485
485
|
end
|
486
486
|
|
487
487
|
it "returns false" do
|
488
|
-
subject.boolean_value.
|
488
|
+
expect(subject.boolean_value).to be(false)
|
489
489
|
end
|
490
490
|
end
|
491
491
|
end
|
@@ -493,7 +493,7 @@ describe Flipper::Feature do
|
|
493
493
|
describe "#percentage_of_actors_value" do
|
494
494
|
context "when not enabled or disabled" do
|
495
495
|
it "returns nil" do
|
496
|
-
subject.percentage_of_actors_value.
|
496
|
+
expect(subject.percentage_of_actors_value).to be(0)
|
497
497
|
end
|
498
498
|
end
|
499
499
|
|
@@ -503,7 +503,7 @@ describe Flipper::Feature do
|
|
503
503
|
end
|
504
504
|
|
505
505
|
it "returns true" do
|
506
|
-
subject.percentage_of_actors_value.
|
506
|
+
expect(subject.percentage_of_actors_value).to eq(5)
|
507
507
|
end
|
508
508
|
end
|
509
509
|
|
@@ -513,7 +513,7 @@ describe Flipper::Feature do
|
|
513
513
|
end
|
514
514
|
|
515
515
|
it "returns nil" do
|
516
|
-
subject.percentage_of_actors_value.
|
516
|
+
expect(subject.percentage_of_actors_value).to be(0)
|
517
517
|
end
|
518
518
|
end
|
519
519
|
end
|
@@ -521,7 +521,7 @@ describe Flipper::Feature do
|
|
521
521
|
describe "#percentage_of_time_value" do
|
522
522
|
context "when not enabled or disabled" do
|
523
523
|
it "returns nil" do
|
524
|
-
subject.percentage_of_time_value.
|
524
|
+
expect(subject.percentage_of_time_value).to be(0)
|
525
525
|
end
|
526
526
|
end
|
527
527
|
|
@@ -531,7 +531,7 @@ describe Flipper::Feature do
|
|
531
531
|
end
|
532
532
|
|
533
533
|
it "returns true" do
|
534
|
-
subject.percentage_of_time_value.
|
534
|
+
expect(subject.percentage_of_time_value).to eq(5)
|
535
535
|
end
|
536
536
|
end
|
537
537
|
|
@@ -541,7 +541,7 @@ describe Flipper::Feature do
|
|
541
541
|
end
|
542
542
|
|
543
543
|
it "returns nil" do
|
544
|
-
subject.percentage_of_time_value.
|
544
|
+
expect(subject.percentage_of_time_value).to be(0)
|
545
545
|
end
|
546
546
|
end
|
547
547
|
end
|
@@ -549,13 +549,13 @@ describe Flipper::Feature do
|
|
549
549
|
describe "#gate_values" do
|
550
550
|
context "when no gates are set in adapter" do
|
551
551
|
it "returns default gate values" do
|
552
|
-
subject.gate_values.
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
552
|
+
expect(subject.gate_values).to eq(Flipper::GateValues.new({
|
553
|
+
:actors => Set.new,
|
554
|
+
:groups => Set.new,
|
555
|
+
:boolean => nil,
|
556
|
+
:percentage_of_actors => nil,
|
557
|
+
:percentage_of_time => nil,
|
558
|
+
}))
|
559
559
|
end
|
560
560
|
end
|
561
561
|
|
@@ -569,13 +569,13 @@ describe Flipper::Feature do
|
|
569
569
|
end
|
570
570
|
|
571
571
|
it "returns gate values" do
|
572
|
-
subject.gate_values.
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
572
|
+
expect(subject.gate_values).to eq(Flipper::GateValues.new({
|
573
|
+
:actors => Set.new(["5"]),
|
574
|
+
:groups => Set.new(["admins"]),
|
575
|
+
:boolean => "true",
|
576
|
+
:percentage_of_time => "50",
|
577
|
+
:percentage_of_actors => "25",
|
578
|
+
}))
|
579
579
|
end
|
580
580
|
end
|
581
581
|
end
|
@@ -584,11 +584,11 @@ describe Flipper::Feature do
|
|
584
584
|
context "with object that responds to flipper_id" do
|
585
585
|
it "updates the gate values to include the actor" do
|
586
586
|
actor = Struct.new(:flipper_id).new(5)
|
587
|
-
subject.gate_values.actors.
|
587
|
+
expect(subject.gate_values.actors).to be_empty
|
588
588
|
subject.enable_actor(actor)
|
589
|
-
subject.gate_values.actors.
|
589
|
+
expect(subject.gate_values.actors).to eq(Set["5"])
|
590
590
|
subject.disable_actor(actor)
|
591
|
-
subject.gate_values.actors.
|
591
|
+
expect(subject.gate_values.actors).to be_empty
|
592
592
|
end
|
593
593
|
end
|
594
594
|
|
@@ -596,11 +596,11 @@ describe Flipper::Feature do
|
|
596
596
|
it "updates the gate values to include the actor" do
|
597
597
|
actor = Struct.new(:flipper_id).new(5)
|
598
598
|
instance = Flipper::Types::Actor.wrap(actor)
|
599
|
-
subject.gate_values.actors.
|
599
|
+
expect(subject.gate_values.actors).to be_empty
|
600
600
|
subject.enable_actor(instance)
|
601
|
-
subject.gate_values.actors.
|
601
|
+
expect(subject.gate_values.actors).to eq(Set["5"])
|
602
602
|
subject.disable_actor(instance)
|
603
|
-
subject.gate_values.actors.
|
603
|
+
expect(subject.gate_values.actors).to be_empty
|
604
604
|
end
|
605
605
|
end
|
606
606
|
end
|
@@ -610,11 +610,11 @@ describe Flipper::Feature do
|
|
610
610
|
it "updates the gate values to include the group" do
|
611
611
|
actor = Struct.new(:flipper_id).new(5)
|
612
612
|
group = Flipper.register(:five_only) { |actor| actor.flipper_id == 5 }
|
613
|
-
subject.gate_values.groups.
|
613
|
+
expect(subject.gate_values.groups).to be_empty
|
614
614
|
subject.enable_group(:five_only)
|
615
|
-
subject.gate_values.groups.
|
615
|
+
expect(subject.gate_values.groups).to eq(Set["five_only"])
|
616
616
|
subject.disable_group(:five_only)
|
617
|
-
subject.gate_values.groups.
|
617
|
+
expect(subject.gate_values.groups).to be_empty
|
618
618
|
end
|
619
619
|
end
|
620
620
|
|
@@ -622,11 +622,11 @@ describe Flipper::Feature do
|
|
622
622
|
it "updates the gate values to include the group" do
|
623
623
|
actor = Struct.new(:flipper_id).new(5)
|
624
624
|
group = Flipper.register(:five_only) { |actor| actor.flipper_id == 5 }
|
625
|
-
subject.gate_values.groups.
|
625
|
+
expect(subject.gate_values.groups).to be_empty
|
626
626
|
subject.enable_group("five_only")
|
627
|
-
subject.gate_values.groups.
|
627
|
+
expect(subject.gate_values.groups).to eq(Set["five_only"])
|
628
628
|
subject.disable_group("five_only")
|
629
|
-
subject.gate_values.groups.
|
629
|
+
expect(subject.gate_values.groups).to be_empty
|
630
630
|
end
|
631
631
|
end
|
632
632
|
|
@@ -634,11 +634,11 @@ describe Flipper::Feature do
|
|
634
634
|
it "updates the gate values for the group" do
|
635
635
|
actor = Struct.new(:flipper_id).new(5)
|
636
636
|
group = Flipper.register(:five_only) { |actor| actor.flipper_id == 5 }
|
637
|
-
subject.gate_values.groups.
|
637
|
+
expect(subject.gate_values.groups).to be_empty
|
638
638
|
subject.enable_group(group)
|
639
|
-
subject.gate_values.groups.
|
639
|
+
expect(subject.gate_values.groups).to eq(Set["five_only"])
|
640
640
|
subject.disable_group(group)
|
641
|
-
subject.gate_values.groups.
|
641
|
+
expect(subject.gate_values.groups).to be_empty
|
642
642
|
end
|
643
643
|
end
|
644
644
|
end
|
@@ -646,32 +646,32 @@ describe Flipper::Feature do
|
|
646
646
|
describe "#enable_percentage_of_time/disable_percentage_of_time" do
|
647
647
|
context "with integer" do
|
648
648
|
it "updates the gate values" do
|
649
|
-
subject.gate_values.percentage_of_time.
|
649
|
+
expect(subject.gate_values.percentage_of_time).to be(0)
|
650
650
|
subject.enable_percentage_of_time(56)
|
651
|
-
subject.gate_values.percentage_of_time.
|
651
|
+
expect(subject.gate_values.percentage_of_time).to be(56)
|
652
652
|
subject.disable_percentage_of_time
|
653
|
-
subject.gate_values.percentage_of_time.
|
653
|
+
expect(subject.gate_values.percentage_of_time).to be(0)
|
654
654
|
end
|
655
655
|
end
|
656
656
|
|
657
657
|
context "with string" do
|
658
658
|
it "updates the gate values" do
|
659
|
-
subject.gate_values.percentage_of_time.
|
659
|
+
expect(subject.gate_values.percentage_of_time).to be(0)
|
660
660
|
subject.enable_percentage_of_time("56")
|
661
|
-
subject.gate_values.percentage_of_time.
|
661
|
+
expect(subject.gate_values.percentage_of_time).to be(56)
|
662
662
|
subject.disable_percentage_of_time
|
663
|
-
subject.gate_values.percentage_of_time.
|
663
|
+
expect(subject.gate_values.percentage_of_time).to be(0)
|
664
664
|
end
|
665
665
|
end
|
666
666
|
|
667
667
|
context "with percentage of time instance" do
|
668
668
|
it "updates the gate values" do
|
669
669
|
percentage = Flipper::Types::PercentageOfTime.new(56)
|
670
|
-
subject.gate_values.percentage_of_time.
|
670
|
+
expect(subject.gate_values.percentage_of_time).to be(0)
|
671
671
|
subject.enable_percentage_of_time(percentage)
|
672
|
-
subject.gate_values.percentage_of_time.
|
672
|
+
expect(subject.gate_values.percentage_of_time).to be(56)
|
673
673
|
subject.disable_percentage_of_time
|
674
|
-
subject.gate_values.percentage_of_time.
|
674
|
+
expect(subject.gate_values.percentage_of_time).to be(0)
|
675
675
|
end
|
676
676
|
end
|
677
677
|
end
|
@@ -679,32 +679,32 @@ describe Flipper::Feature do
|
|
679
679
|
describe "#enable_percentage_of_actors/disable_percentage_of_actors" do
|
680
680
|
context "with integer" do
|
681
681
|
it "updates the gate values" do
|
682
|
-
subject.gate_values.percentage_of_actors.
|
682
|
+
expect(subject.gate_values.percentage_of_actors).to be(0)
|
683
683
|
subject.enable_percentage_of_actors(56)
|
684
|
-
subject.gate_values.percentage_of_actors.
|
684
|
+
expect(subject.gate_values.percentage_of_actors).to be(56)
|
685
685
|
subject.disable_percentage_of_actors
|
686
|
-
subject.gate_values.percentage_of_actors.
|
686
|
+
expect(subject.gate_values.percentage_of_actors).to be(0)
|
687
687
|
end
|
688
688
|
end
|
689
689
|
|
690
690
|
context "with string" do
|
691
691
|
it "updates the gate values" do
|
692
|
-
subject.gate_values.percentage_of_actors.
|
692
|
+
expect(subject.gate_values.percentage_of_actors).to be(0)
|
693
693
|
subject.enable_percentage_of_actors("56")
|
694
|
-
subject.gate_values.percentage_of_actors.
|
694
|
+
expect(subject.gate_values.percentage_of_actors).to be(56)
|
695
695
|
subject.disable_percentage_of_actors
|
696
|
-
subject.gate_values.percentage_of_actors.
|
696
|
+
expect(subject.gate_values.percentage_of_actors).to be(0)
|
697
697
|
end
|
698
698
|
end
|
699
699
|
|
700
700
|
context "with percentage of actors instance" do
|
701
701
|
it "updates the gate values" do
|
702
702
|
percentage = Flipper::Types::PercentageOfActors.new(56)
|
703
|
-
subject.gate_values.percentage_of_actors.
|
703
|
+
expect(subject.gate_values.percentage_of_actors).to be(0)
|
704
704
|
subject.enable_percentage_of_actors(percentage)
|
705
|
-
subject.gate_values.percentage_of_actors.
|
705
|
+
expect(subject.gate_values.percentage_of_actors).to be(56)
|
706
706
|
subject.disable_percentage_of_actors
|
707
|
-
subject.gate_values.percentage_of_actors.
|
707
|
+
expect(subject.gate_values.percentage_of_actors).to be(0)
|
708
708
|
end
|
709
709
|
end
|
710
710
|
end
|
@@ -716,29 +716,29 @@ describe Flipper::Feature do
|
|
716
716
|
end
|
717
717
|
|
718
718
|
it "can return enabled gates" do
|
719
|
-
subject.enabled_gates.map(&:name).to_set.
|
720
|
-
|
721
|
-
|
722
|
-
|
719
|
+
expect(subject.enabled_gates.map(&:name).to_set).to eq(Set[
|
720
|
+
:percentage_of_actors,
|
721
|
+
:percentage_of_time,
|
722
|
+
])
|
723
723
|
|
724
|
-
subject.enabled_gate_names.to_set.
|
725
|
-
|
726
|
-
|
727
|
-
|
724
|
+
expect(subject.enabled_gate_names.to_set).to eq(Set[
|
725
|
+
:percentage_of_actors,
|
726
|
+
:percentage_of_time,
|
727
|
+
])
|
728
728
|
end
|
729
729
|
|
730
730
|
it "can return disabled gates" do
|
731
|
-
subject.disabled_gates.map(&:name).to_set.
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
subject.disabled_gate_names.to_set.
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
731
|
+
expect(subject.disabled_gates.map(&:name).to_set).to eq(Set[
|
732
|
+
:actor,
|
733
|
+
:boolean,
|
734
|
+
:group,
|
735
|
+
])
|
736
|
+
|
737
|
+
expect(subject.disabled_gate_names.to_set).to eq(Set[
|
738
|
+
:actor,
|
739
|
+
:boolean,
|
740
|
+
:group,
|
741
|
+
])
|
742
742
|
end
|
743
743
|
end
|
744
744
|
end
|