flipper 0.10.2 → 0.11.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +42 -0
  3. data/.rubocop_todo.yml +188 -0
  4. data/Changelog.md +10 -0
  5. data/Gemfile +6 -3
  6. data/README.md +4 -3
  7. data/Rakefile +13 -13
  8. data/docs/Adapters.md +2 -1
  9. data/docs/DockerCompose.md +6 -3
  10. data/docs/Gates.md +25 -3
  11. data/docs/Optimization.md +27 -5
  12. data/docs/api/README.md +73 -32
  13. data/docs/http/README.md +34 -0
  14. data/docs/read-only/README.md +22 -0
  15. data/examples/percentage_of_actors_group.rb +49 -0
  16. data/flipper.gemspec +15 -15
  17. data/lib/flipper.rb +2 -5
  18. data/lib/flipper/adapter.rb +10 -0
  19. data/lib/flipper/adapters/http.rb +147 -0
  20. data/lib/flipper/adapters/http/client.rb +83 -0
  21. data/lib/flipper/adapters/http/error.rb +14 -0
  22. data/lib/flipper/adapters/instrumented.rb +36 -36
  23. data/lib/flipper/adapters/memoizable.rb +2 -6
  24. data/lib/flipper/adapters/memory.rb +10 -9
  25. data/lib/flipper/adapters/operation_logger.rb +1 -1
  26. data/lib/flipper/adapters/pstore.rb +12 -11
  27. data/lib/flipper/adapters/read_only.rb +6 -6
  28. data/lib/flipper/dsl.rb +1 -3
  29. data/lib/flipper/feature.rb +11 -16
  30. data/lib/flipper/gate.rb +3 -3
  31. data/lib/flipper/gate_values.rb +6 -6
  32. data/lib/flipper/gates/group.rb +2 -2
  33. data/lib/flipper/gates/percentage_of_actors.rb +2 -2
  34. data/lib/flipper/instrumentation/log_subscriber.rb +2 -4
  35. data/lib/flipper/instrumentation/metriks.rb +1 -1
  36. data/lib/flipper/instrumentation/statsd.rb +1 -1
  37. data/lib/flipper/instrumentation/statsd_subscriber.rb +1 -3
  38. data/lib/flipper/instrumentation/subscriber.rb +11 -10
  39. data/lib/flipper/instrumenters/memory.rb +1 -5
  40. data/lib/flipper/instrumenters/noop.rb +1 -1
  41. data/lib/flipper/middleware/memoizer.rb +11 -27
  42. data/lib/flipper/middleware/setup_env.rb +44 -0
  43. data/lib/flipper/registry.rb +8 -10
  44. data/lib/flipper/spec/shared_adapter_specs.rb +45 -67
  45. data/lib/flipper/test/shared_adapter_test.rb +25 -31
  46. data/lib/flipper/typecast.rb +2 -2
  47. data/lib/flipper/types/actor.rb +2 -4
  48. data/lib/flipper/types/group.rb +1 -1
  49. data/lib/flipper/types/percentage.rb +2 -1
  50. data/lib/flipper/version.rb +1 -1
  51. data/spec/fixtures/feature.json +31 -0
  52. data/spec/flipper/adapters/http_spec.rb +148 -0
  53. data/spec/flipper/adapters/instrumented_spec.rb +20 -20
  54. data/spec/flipper/adapters/memoizable_spec.rb +59 -59
  55. data/spec/flipper/adapters/operation_logger_spec.rb +16 -16
  56. data/spec/flipper/adapters/pstore_spec.rb +6 -6
  57. data/spec/flipper/adapters/read_only_spec.rb +28 -34
  58. data/spec/flipper/dsl_spec.rb +73 -84
  59. data/spec/flipper/feature_check_context_spec.rb +27 -27
  60. data/spec/flipper/feature_spec.rb +186 -196
  61. data/spec/flipper/gate_spec.rb +11 -11
  62. data/spec/flipper/gate_values_spec.rb +46 -45
  63. data/spec/flipper/gates/actor_spec.rb +2 -2
  64. data/spec/flipper/gates/boolean_spec.rb +24 -23
  65. data/spec/flipper/gates/group_spec.rb +19 -19
  66. data/spec/flipper/gates/percentage_of_actors_spec.rb +10 -10
  67. data/spec/flipper/gates/percentage_of_time_spec.rb +2 -2
  68. data/spec/flipper/instrumentation/log_subscriber_spec.rb +20 -20
  69. data/spec/flipper/instrumentation/metriks_subscriber_spec.rb +20 -20
  70. data/spec/flipper/instrumentation/statsd_subscriber_spec.rb +11 -11
  71. data/spec/flipper/instrumenters/memory_spec.rb +5 -5
  72. data/spec/flipper/instrumenters/noop_spec.rb +6 -6
  73. data/spec/flipper/middleware/memoizer_spec.rb +83 -100
  74. data/spec/flipper/middleware/setup_env_spec.rb +76 -0
  75. data/spec/flipper/registry_spec.rb +35 -39
  76. data/spec/flipper/typecast_spec.rb +18 -18
  77. data/spec/flipper/types/actor_spec.rb +30 -29
  78. data/spec/flipper/types/boolean_spec.rb +8 -8
  79. data/spec/flipper/types/group_spec.rb +28 -28
  80. data/spec/flipper/types/percentage_spec.rb +14 -14
  81. data/spec/flipper_spec.rb +61 -54
  82. data/spec/helper.rb +26 -21
  83. data/spec/integration_spec.rb +121 -113
  84. data/spec/support/fake_udp_socket.rb +1 -1
  85. data/spec/support/spec_helpers.rb +32 -4
  86. data/test/adapters/pstore_test.rb +3 -3
  87. data/test/test_helper.rb +1 -1
  88. metadata +20 -5
@@ -4,7 +4,7 @@ require 'flipper/adapters/memory'
4
4
 
5
5
  RSpec.describe Flipper do
6
6
  let(:adapter) { Flipper::Adapters::Memory.new }
7
- let(:flipper) { Flipper.new(adapter) }
7
+ let(:flipper) { described_class.new(adapter) }
8
8
  let(:feature) { flipper[:search] }
9
9
 
10
10
  let(:actor_class) { Struct.new(:flipper_id) }
@@ -12,11 +12,19 @@ RSpec.describe Flipper do
12
12
  let(:admin_group) { flipper.group(:admins) }
13
13
  let(:dev_group) { flipper.group(:devs) }
14
14
 
15
- let(:admin_thing) { double 'Non Flipper Thing', :flipper_id => 1, :admin? => true, :dev? => false }
16
- let(:dev_thing) { double 'Non Flipper Thing', :flipper_id => 10, :admin? => false, :dev? => true }
15
+ let(:admin_thing) do
16
+ double 'Non Flipper Thing', flipper_id: 1, admin?: true, dev?: false
17
+ end
18
+ let(:dev_thing) do
19
+ double 'Non Flipper Thing', flipper_id: 10, admin?: false, dev?: true
20
+ end
17
21
 
18
- let(:admin_truthy_thing) { double 'Non Flipper Thing', :flipper_id => 1, :admin? => "true-ish", :dev? => false }
19
- let(:admin_falsey_thing) { double 'Non Flipper Thing', :flipper_id => 1, :admin? => nil, :dev? => false }
22
+ let(:admin_truthy_thing) do
23
+ double 'Non Flipper Thing', flipper_id: 1, admin?: 'true-ish', dev?: false
24
+ end
25
+ let(:admin_falsey_thing) do
26
+ double 'Non Flipper Thing', flipper_id: 1, admin?: nil, dev?: false
27
+ end
20
28
 
21
29
  let(:pitt) { actor_class.new(1) }
22
30
  let(:clooney) { actor_class.new(10) }
@@ -25,149 +33,149 @@ RSpec.describe Flipper do
25
33
  let(:five_percent_of_time) { flipper.time(5) }
26
34
 
27
35
  before do
28
- Flipper.register(:admins) { |thing| thing.admin? }
29
- Flipper.register(:devs) { |thing| thing.dev? }
36
+ described_class.register(:admins, &:admin?)
37
+ described_class.register(:devs, &:dev?)
30
38
  end
31
39
 
32
- describe "#enable" do
33
- context "with no arguments" do
40
+ describe '#enable' do
41
+ context 'with no arguments' do
34
42
  before do
35
43
  @result = feature.enable
36
44
  end
37
45
 
38
- it "returns true" do
46
+ it 'returns true' do
39
47
  expect(@result).to eq(true)
40
48
  end
41
49
 
42
- it "enables feature for all" do
50
+ it 'enables feature for all' do
43
51
  expect(feature.enabled?).to eq(true)
44
52
  end
45
53
 
46
- it "adds feature to set of features" do
54
+ it 'adds feature to set of features' do
47
55
  expect(flipper.features.map(&:name)).to include(:search)
48
56
  end
49
57
  end
50
58
 
51
- context "with a group" do
59
+ context 'with a group' do
52
60
  before do
53
61
  @result = feature.enable(admin_group)
54
62
  end
55
63
 
56
- it "returns true" do
64
+ it 'returns true' do
57
65
  expect(@result).to eq(true)
58
66
  end
59
67
 
60
- it "enables feature for non flipper thing in group" do
68
+ it 'enables feature for non flipper thing in group' do
61
69
  expect(feature.enabled?(admin_thing)).to eq(true)
62
70
  end
63
71
 
64
- it "does not enable feature for non flipper thing in other group" do
72
+ it 'does not enable feature for non flipper thing in other group' do
65
73
  expect(feature.enabled?(dev_thing)).to eq(false)
66
74
  end
67
75
 
68
- it "enables feature for flipper actor in group" do
76
+ it 'enables feature for flipper actor in group' do
69
77
  expect(feature.enabled?(flipper.actor(admin_thing))).to eq(true)
70
78
  end
71
79
 
72
- it "does not enable for flipper actor not in group" do
80
+ it 'does not enable for flipper actor not in group' do
73
81
  expect(feature.enabled?(flipper.actor(dev_thing))).to eq(false)
74
82
  end
75
83
 
76
- it "does not enable feature for all" do
84
+ it 'does not enable feature for all' do
77
85
  expect(feature.enabled?).to eq(false)
78
86
  end
79
87
 
80
- it "adds feature to set of features" do
88
+ it 'adds feature to set of features' do
81
89
  expect(flipper.features.map(&:name)).to include(:search)
82
90
  end
83
91
  end
84
92
 
85
- context "with an actor" do
93
+ context 'with an actor' do
86
94
  before do
87
95
  @result = feature.enable(pitt)
88
96
  end
89
97
 
90
- it "returns true" do
98
+ it 'returns true' do
91
99
  expect(@result).to eq(true)
92
100
  end
93
101
 
94
- it "enables feature for actor" do
102
+ it 'enables feature for actor' do
95
103
  expect(feature.enabled?(pitt)).to eq(true)
96
104
  end
97
105
 
98
- it "does not enable feature for other actors" do
106
+ it 'does not enable feature for other actors' do
99
107
  expect(feature.enabled?(clooney)).to eq(false)
100
108
  end
101
109
 
102
- it "adds feature to set of features" do
110
+ it 'adds feature to set of features' do
103
111
  expect(flipper.features.map(&:name)).to include(:search)
104
112
  end
105
113
  end
106
114
 
107
- context "with a percentage of actors" do
115
+ context 'with a percentage of actors' do
108
116
  before do
109
117
  @result = feature.enable(five_percent_of_actors)
110
118
  end
111
119
 
112
- it "returns true" do
120
+ it 'returns true' do
113
121
  expect(@result).to eq(true)
114
122
  end
115
123
 
116
- it "enables feature for actor within percentage" do
117
- enabled = (1..100).select { |i|
124
+ it 'enables feature for actor within percentage' do
125
+ enabled = (1..100).select do |i|
118
126
  thing = actor_class.new(i)
119
127
  feature.enabled?(thing)
120
- }.size
128
+ end.size
121
129
 
122
130
  expect(enabled).to be_within(2).of(5)
123
131
  end
124
132
 
125
- it "adds feature to set of features" do
133
+ it 'adds feature to set of features' do
126
134
  expect(flipper.features.map(&:name)).to include(:search)
127
135
  end
128
136
  end
129
137
 
130
- context "with a percentage of time" do
138
+ context 'with a percentage of time' do
131
139
  before do
132
140
  @gate = feature.gate(:percentage_of_time)
133
141
  @result = feature.enable(five_percent_of_time)
134
142
  end
135
143
 
136
- it "returns true" do
144
+ it 'returns true' do
137
145
  expect(@result).to eq(true)
138
146
  end
139
147
 
140
- it "enables feature for time within percentage" do
141
- allow(@gate).to receive_messages(:rand => 0.04)
148
+ it 'enables feature for time within percentage' do
149
+ allow(@gate).to receive_messages(rand: 0.04)
142
150
  expect(feature.enabled?).to eq(true)
143
151
  end
144
152
 
145
- it "does not enable feature for time not within percentage" do
146
- allow(@gate).to receive_messages(:rand => 0.10)
153
+ it 'does not enable feature for time not within percentage' do
154
+ allow(@gate).to receive_messages(rand: 0.10)
147
155
  expect(feature.enabled?).to eq(false)
148
156
  end
149
157
 
150
- it "adds feature to set of features" do
158
+ it 'adds feature to set of features' do
151
159
  expect(flipper.features.map(&:name)).to include(:search)
152
160
  end
153
161
  end
154
162
 
155
- context "with argument that has no gate" do
156
- it "raises error" do
163
+ context 'with argument that has no gate' do
164
+ it 'raises error' do
157
165
  thing = Object.new
158
- expect {
166
+ expect do
159
167
  feature.enable(thing)
160
- }.to raise_error(Flipper::GateNotFound, "Could not find gate for #{thing.inspect}")
168
+ end.to raise_error(Flipper::GateNotFound, "Could not find gate for #{thing.inspect}")
161
169
  end
162
170
  end
163
171
  end
164
172
 
165
- describe "#disable" do
166
- context "with no arguments" do
173
+ describe '#disable' do
174
+ context 'with no arguments' do
167
175
  before do
168
176
  # ensures that time gate is stubbed with result that would be true for pitt
169
177
  @gate = feature.gate(:percentage_of_time)
170
- allow(@gate).to receive_messages(:rand => 0.04)
178
+ allow(@gate).to receive_messages(rand: 0.04)
171
179
 
172
180
  feature.enable admin_group
173
181
  feature.enable pitt
@@ -176,229 +184,229 @@ RSpec.describe Flipper do
176
184
  @result = feature.disable
177
185
  end
178
186
 
179
- it "returns true" do
187
+ it 'returns true' do
180
188
  expect(@result).to be(true)
181
189
  end
182
190
 
183
- it "disables feature" do
191
+ it 'disables feature' do
184
192
  expect(feature.enabled?).to eq(false)
185
193
  end
186
194
 
187
- it "disables for individual actor" do
195
+ it 'disables for individual actor' do
188
196
  expect(feature.enabled?(pitt)).to eq(false)
189
197
  end
190
198
 
191
- it "disables actor in group" do
199
+ it 'disables actor in group' do
192
200
  expect(feature.enabled?(admin_thing)).to eq(false)
193
201
  end
194
202
 
195
- it "disables actor in percentage of actors" do
196
- enabled = (1..100).select { |i|
203
+ it 'disables actor in percentage of actors' do
204
+ enabled = (1..100).select do |i|
197
205
  thing = actor_class.new(i)
198
206
  feature.enabled?(thing)
199
- }.size
207
+ end.size
200
208
 
201
209
  expect(enabled).to be(0)
202
210
  end
203
211
 
204
- it "disables percentage of time" do
212
+ it 'disables percentage of time' do
205
213
  expect(feature.enabled?(pitt)).to eq(false)
206
214
  end
207
215
 
208
- it "adds feature to set of features" do
216
+ it 'adds feature to set of features' do
209
217
  expect(flipper.features.map(&:name)).to include(:search)
210
218
  end
211
219
  end
212
220
 
213
- context "with a group" do
221
+ context 'with a group' do
214
222
  before do
215
223
  feature.enable dev_group
216
224
  feature.enable admin_group
217
225
  @result = feature.disable(admin_group)
218
226
  end
219
227
 
220
- it "returns true" do
228
+ it 'returns true' do
221
229
  expect(@result).to eq(true)
222
230
  end
223
231
 
224
- it "disables the feature for non flipper thing in the group" do
232
+ it 'disables the feature for non flipper thing in the group' do
225
233
  expect(feature.enabled?(admin_thing)).to eq(false)
226
234
  end
227
235
 
228
- it "does not disable feature for non flipper thing in other groups" do
236
+ it 'does not disable feature for non flipper thing in other groups' do
229
237
  expect(feature.enabled?(dev_thing)).to eq(true)
230
238
  end
231
239
 
232
- it "disables feature for flipper actor in group" do
240
+ it 'disables feature for flipper actor in group' do
233
241
  expect(feature.enabled?(flipper.actor(admin_thing))).to eq(false)
234
242
  end
235
243
 
236
- it "does not disable feature for flipper actor in other groups" do
244
+ it 'does not disable feature for flipper actor in other groups' do
237
245
  expect(feature.enabled?(flipper.actor(dev_thing))).to eq(true)
238
246
  end
239
247
 
240
- it "adds feature to set of features" do
248
+ it 'adds feature to set of features' do
241
249
  expect(flipper.features.map(&:name)).to include(:search)
242
250
  end
243
251
  end
244
252
 
245
- context "with an actor" do
253
+ context 'with an actor' do
246
254
  before do
247
255
  feature.enable pitt
248
256
  feature.enable clooney
249
257
  @result = feature.disable(pitt)
250
258
  end
251
259
 
252
- it "returns true" do
260
+ it 'returns true' do
253
261
  expect(@result).to eq(true)
254
262
  end
255
263
 
256
- it "disables feature for actor" do
264
+ it 'disables feature for actor' do
257
265
  expect(feature.enabled?(pitt)).to eq(false)
258
266
  end
259
267
 
260
- it "does not disable feature for other actors" do
268
+ it 'does not disable feature for other actors' do
261
269
  expect(feature.enabled?(clooney)).to eq(true)
262
270
  end
263
271
 
264
- it "adds feature to set of features" do
272
+ it 'adds feature to set of features' do
265
273
  expect(flipper.features.map(&:name)).to include(:search)
266
274
  end
267
275
  end
268
276
 
269
- context "with a percentage of actors" do
277
+ context 'with a percentage of actors' do
270
278
  before do
271
279
  @result = feature.disable(flipper.actors(0))
272
280
  end
273
281
 
274
- it "returns true" do
282
+ it 'returns true' do
275
283
  expect(@result).to eq(true)
276
284
  end
277
285
 
278
- it "disables feature" do
279
- enabled = (1..100).select { |i|
286
+ it 'disables feature' do
287
+ enabled = (1..100).select do |i|
280
288
  thing = actor_class.new(i)
281
289
  feature.enabled?(thing)
282
- }.size
290
+ end.size
283
291
 
284
292
  expect(enabled).to be(0)
285
293
  end
286
294
 
287
- it "adds feature to set of features" do
295
+ it 'adds feature to set of features' do
288
296
  expect(flipper.features.map(&:name)).to include(:search)
289
297
  end
290
298
  end
291
299
 
292
- context "with a percentage of time" do
300
+ context 'with a percentage of time' do
293
301
  before do
294
302
  @gate = feature.gate(:percentage_of_time)
295
303
  @result = feature.disable(flipper.time(0))
296
304
  end
297
305
 
298
- it "returns true" do
306
+ it 'returns true' do
299
307
  expect(@result).to eq(true)
300
308
  end
301
309
 
302
- it "disables feature for time within percentage" do
303
- allow(@gate).to receive_messages(:rand => 0.04)
310
+ it 'disables feature for time within percentage' do
311
+ allow(@gate).to receive_messages(rand: 0.04)
304
312
  expect(feature.enabled?).to eq(false)
305
313
  end
306
314
 
307
- it "disables feature for time not within percentage" do
308
- allow(@gate).to receive_messages(:rand => 0.10)
315
+ it 'disables feature for time not within percentage' do
316
+ allow(@gate).to receive_messages(rand: 0.10)
309
317
  expect(feature.enabled?).to eq(false)
310
318
  end
311
319
 
312
- it "adds feature to set of features" do
320
+ it 'adds feature to set of features' do
313
321
  expect(flipper.features.map(&:name)).to include(:search)
314
322
  end
315
323
  end
316
324
 
317
- context "with argument that has no gate" do
318
- it "raises error" do
325
+ context 'with argument that has no gate' do
326
+ it 'raises error' do
319
327
  thing = Object.new
320
- expect {
328
+ expect do
321
329
  feature.disable(thing)
322
- }.to raise_error(Flipper::GateNotFound, "Could not find gate for #{thing.inspect}")
330
+ end.to raise_error(Flipper::GateNotFound, "Could not find gate for #{thing.inspect}")
323
331
  end
324
332
  end
325
333
  end
326
334
 
327
- describe "#enabled?" do
328
- context "with no arguments" do
329
- it "defaults to false" do
335
+ describe '#enabled?' do
336
+ context 'with no arguments' do
337
+ it 'defaults to false' do
330
338
  expect(feature.enabled?).to eq(false)
331
339
  end
332
340
  end
333
341
 
334
- context "with no arguments, but boolean enabled" do
342
+ context 'with no arguments, but boolean enabled' do
335
343
  before do
336
344
  feature.enable
337
345
  end
338
346
 
339
- it "returns true" do
347
+ it 'returns true' do
340
348
  expect(feature.enabled?).to eq(true)
341
349
  end
342
350
  end
343
351
 
344
- context "for actor in enabled group" do
352
+ context 'for actor in enabled group' do
345
353
  before do
346
354
  feature.enable admin_group
347
355
  end
348
356
 
349
- it "returns true" do
357
+ it 'returns true' do
350
358
  expect(feature.enabled?(flipper.actor(admin_thing))).to eq(true)
351
359
  expect(feature.enabled?(admin_thing)).to eq(true)
352
360
  end
353
361
 
354
- it "returns true for truthy block values" do
362
+ it 'returns true for truthy block values' do
355
363
  expect(feature.enabled?(flipper.actor(admin_truthy_thing))).to eq(true)
356
364
  end
357
365
  end
358
366
 
359
- context "for actor in disabled group" do
360
- it "returns false" do
367
+ context 'for actor in disabled group' do
368
+ it 'returns false' do
361
369
  expect(feature.enabled?(flipper.actor(dev_thing))).to eq(false)
362
370
  expect(feature.enabled?(dev_thing)).to eq(false)
363
371
  end
364
372
 
365
- it "returns false for falsey block values" do
373
+ it 'returns false for falsey block values' do
366
374
  expect(feature.enabled?(flipper.actor(admin_falsey_thing))).to eq(false)
367
375
  end
368
376
  end
369
377
 
370
- context "for enabled actor" do
378
+ context 'for enabled actor' do
371
379
  before do
372
380
  feature.enable pitt
373
381
  end
374
382
 
375
- it "returns true" do
383
+ it 'returns true' do
376
384
  expect(feature.enabled?(pitt)).to eq(true)
377
385
  end
378
386
  end
379
387
 
380
- context "for not enabled actor" do
381
- it "returns false" do
388
+ context 'for not enabled actor' do
389
+ it 'returns false' do
382
390
  expect(feature.enabled?(clooney)).to eq(false)
383
391
  end
384
392
 
385
- it "returns true if boolean enabled" do
393
+ it 'returns true if boolean enabled' do
386
394
  feature.enable
387
395
  expect(feature.enabled?(clooney)).to eq(true)
388
396
  end
389
397
  end
390
398
 
391
- context "for enabled percentage of time" do
399
+ context 'for enabled percentage of time' do
392
400
  before do
393
401
  # ensure percentage of time returns percentage that makes five percent
394
402
  # of time true
395
403
  @gate = feature.gate(:percentage_of_time)
396
- allow(@gate).to receive_messages(:rand => 0.04)
404
+ allow(@gate).to receive_messages(rand: 0.04)
397
405
 
398
406
  feature.enable five_percent_of_time
399
407
  end
400
408
 
401
- it "returns true" do
409
+ it 'returns true' do
402
410
  expect(feature.enabled?).to eq(true)
403
411
  expect(feature.enabled?(nil)).to eq(true)
404
412
  expect(feature.enabled?(pitt)).to eq(true)
@@ -406,24 +414,24 @@ RSpec.describe Flipper do
406
414
  end
407
415
  end
408
416
 
409
- context "for not enabled percentage of time" do
417
+ context 'for not enabled percentage of time' do
410
418
  before do
411
419
  # ensure percentage of time returns percentage that makes five percent
412
420
  # of time false
413
421
  @gate = feature.gate(:percentage_of_time)
414
- allow(@gate).to receive_messages(:rand => 0.10)
422
+ allow(@gate).to receive_messages(rand: 0.10)
415
423
 
416
424
  feature.enable five_percent_of_time
417
425
  end
418
426
 
419
- it "returns false" do
427
+ it 'returns false' do
420
428
  expect(feature.enabled?).to eq(false)
421
429
  expect(feature.enabled?(nil)).to eq(false)
422
430
  expect(feature.enabled?(pitt)).to eq(false)
423
431
  expect(feature.enabled?(admin_thing)).to eq(false)
424
432
  end
425
433
 
426
- it "returns true if boolean enabled" do
434
+ it 'returns true if boolean enabled' do
427
435
  feature.enable
428
436
  expect(feature.enabled?).to eq(true)
429
437
  expect(feature.enabled?(nil)).to eq(true)
@@ -432,20 +440,20 @@ RSpec.describe Flipper do
432
440
  end
433
441
  end
434
442
 
435
- context "for a non flipper thing" do
443
+ context 'for a non flipper thing' do
436
444
  before do
437
445
  feature.enable admin_group
438
446
  end
439
447
 
440
- it "returns true if in enabled group" do
448
+ it 'returns true if in enabled group' do
441
449
  expect(feature.enabled?(admin_thing)).to eq(true)
442
450
  end
443
451
 
444
- it "returns false if not in enabled group" do
452
+ it 'returns false if not in enabled group' do
445
453
  expect(feature.enabled?(dev_thing)).to eq(false)
446
454
  end
447
455
 
448
- it "returns true if boolean enabled" do
456
+ it 'returns true if boolean enabled' do
449
457
  feature.enable
450
458
  expect(feature.enabled?(admin_thing)).to eq(true)
451
459
  expect(feature.enabled?(dev_thing)).to eq(true)
@@ -453,7 +461,7 @@ RSpec.describe Flipper do
453
461
  end
454
462
  end
455
463
 
456
- context "enabling multiple groups, disabling everything, then enabling one group" do
464
+ context 'enabling multiple groups, disabling everything, then enabling one group' do
457
465
  before do
458
466
  feature.enable(admin_group)
459
467
  feature.enable(dev_group)
@@ -461,11 +469,11 @@ RSpec.describe Flipper do
461
469
  feature.enable(admin_group)
462
470
  end
463
471
 
464
- it "enables feature for object in enabled group" do
472
+ it 'enables feature for object in enabled group' do
465
473
  expect(feature.enabled?(admin_thing)).to eq(true)
466
474
  end
467
475
 
468
- it "does not enable feature for object in not enabled group" do
476
+ it 'does not enable feature for object in not enabled group' do
469
477
  expect(feature.enabled?(dev_thing)).to eq(false)
470
478
  end
471
479
  end