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
@@ -0,0 +1,44 @@
1
+ module Flipper
2
+ module Middleware
3
+ class SetupEnv
4
+ # Public: Initializes an instance of the SetEnv middleware. Allows for
5
+ # lazy initialization of the flipper instance being set in the env by
6
+ # providing a block.
7
+ #
8
+ # app - The app this middleware is included in.
9
+ # flipper_or_block - The Flipper::DSL instance or a block that yields a
10
+ # Flipper::DSL instance to use for all operations.
11
+ #
12
+ # Examples
13
+ #
14
+ # flipper = Flipper.new(...)
15
+ #
16
+ # # using with a normal flipper instance
17
+ # use Flipper::Middleware::SetEnv, flipper
18
+ #
19
+ # # using with a block that yields a flipper instance
20
+ # use Flipper::Middleware::SetEnv, lambda { Flipper.new(...) }
21
+ #
22
+ def initialize(app, flipper_or_block)
23
+ @app = app
24
+
25
+ if flipper_or_block.respond_to?(:call)
26
+ @flipper_block = flipper_or_block
27
+ else
28
+ @flipper = flipper_or_block
29
+ end
30
+ end
31
+
32
+ def call(env)
33
+ env['flipper'.freeze] ||= flipper
34
+ @app.call(env)
35
+ end
36
+
37
+ private
38
+
39
+ def flipper
40
+ @flipper ||= @flipper_block.call
41
+ end
42
+ end
43
+ end
44
+ end
@@ -34,29 +34,27 @@ module Flipper
34
34
  def add(key, value)
35
35
  key = key.to_sym
36
36
 
37
- @mutex.synchronize {
37
+ @mutex.synchronize do
38
38
  if @source[key]
39
39
  raise DuplicateKey, "#{key} is already registered"
40
40
  else
41
41
  @source[key] = value
42
42
  end
43
- }
43
+ end
44
44
  end
45
45
 
46
46
  def get(key)
47
47
  key = key.to_sym
48
- @mutex.synchronize {
49
- @source.fetch(key) {
50
- raise KeyNotFound.new(key)
51
- }
52
- }
48
+ @mutex.synchronize do
49
+ @source[key]
50
+ end
53
51
  end
54
52
 
55
53
  def key?(key)
56
54
  key = key.to_sym
57
- @mutex.synchronize {
58
- @source.has_key?(key)
59
- }
55
+ @mutex.synchronize do
56
+ @source.key?(key)
57
+ end
60
58
  end
61
59
 
62
60
  def each(&block)
@@ -10,46 +10,36 @@ RSpec.shared_examples_for 'a flipper adapter' do
10
10
  let(:group_gate) { feature.gate(:group) }
11
11
  let(:actor_gate) { feature.gate(:actor) }
12
12
  let(:actors_gate) { feature.gate(:percentage_of_actors) }
13
- let(:time_gate) { feature.gate(:percentage_of_time) }
14
-
15
- let(:default_config) {
16
- {
17
- :boolean => nil,
18
- :groups => Set.new,
19
- :actors => Set.new,
20
- :percentage_of_actors => nil,
21
- :percentage_of_time => nil,
22
- }
23
- }
13
+ let(:time_gate) { feature.gate(:percentage_of_time) }
24
14
 
25
15
  before do
26
- Flipper.register(:admins) { |actor|
16
+ Flipper.register(:admins) do |actor|
27
17
  actor.respond_to?(:admin?) && actor.admin?
28
- }
18
+ end
29
19
 
30
- Flipper.register(:early_access) { |actor|
20
+ Flipper.register(:early_access) do |actor|
31
21
  actor.respond_to?(:early_access?) && actor.early_access?
32
- }
22
+ end
33
23
  end
34
24
 
35
25
  after do
36
26
  Flipper.unregister_groups
37
27
  end
38
28
 
39
- it "has name that is a symbol" do
40
- expect(subject.name).to_not be_nil
29
+ it 'has name that is a symbol' do
30
+ expect(subject.name).not_to be_nil
41
31
  expect(subject.name).to be_instance_of(Symbol)
42
32
  end
43
33
 
44
- it "has included the flipper adapter module" do
34
+ it 'has included the flipper adapter module' do
45
35
  expect(subject.class.ancestors).to include(Flipper::Adapter)
46
36
  end
47
37
 
48
- it "returns correct default values for the gates if none are enabled" do
49
- expect(subject.get(feature)).to eq(default_config)
38
+ it 'returns correct default values for the gates if none are enabled' do
39
+ expect(subject.get(feature)).to eq(subject.default_config)
50
40
  end
51
41
 
52
- it "can enable, disable and get value for boolean gate" do
42
+ it 'can enable, disable and get value for boolean gate' do
53
43
  expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
54
44
 
55
45
  result = subject.get(feature)
@@ -61,26 +51,20 @@ RSpec.shared_examples_for 'a flipper adapter' do
61
51
  expect(result[:boolean]).to eq(nil)
62
52
  end
63
53
 
64
- it "fully disables all enabled things when boolean gate disabled" do
65
- actor_22 = actor_class.new('22')
54
+ it 'fully disables all enabled things when boolean gate disabled' do
55
+ actor22 = actor_class.new('22')
66
56
  expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
67
57
  expect(subject.enable(feature, group_gate, flipper.group(:admins))).to eq(true)
68
- expect(subject.enable(feature, actor_gate, flipper.actor(actor_22))).to eq(true)
58
+ expect(subject.enable(feature, actor_gate, flipper.actor(actor22))).to eq(true)
69
59
  expect(subject.enable(feature, actors_gate, flipper.actors(25))).to eq(true)
70
60
  expect(subject.enable(feature, time_gate, flipper.time(45))).to eq(true)
71
61
 
72
62
  expect(subject.disable(feature, boolean_gate, flipper.boolean(false))).to eq(true)
73
63
 
74
- expect(subject.get(feature)).to eq({
75
- :boolean => nil,
76
- :groups => Set.new,
77
- :actors => Set.new,
78
- :percentage_of_actors => nil,
79
- :percentage_of_time => nil,
80
- })
64
+ expect(subject.get(feature)).to eq(subject.default_config)
81
65
  end
82
66
 
83
- it "can enable, disable and get value for group gate" do
67
+ it 'can enable, disable and get value for group gate' do
84
68
  expect(subject.enable(feature, group_gate, flipper.group(:admins))).to eq(true)
85
69
  expect(subject.enable(feature, group_gate, flipper.group(:early_access))).to eq(true)
86
70
 
@@ -96,17 +80,17 @@ RSpec.shared_examples_for 'a flipper adapter' do
96
80
  expect(result[:groups]).to eq(Set.new)
97
81
  end
98
82
 
99
- it "can enable, disable and get value for actor gate" do
100
- actor_22 = actor_class.new('22')
83
+ it 'can enable, disable and get value for actor gate' do
84
+ actor22 = actor_class.new('22')
101
85
  actor_asdf = actor_class.new('asdf')
102
86
 
103
- expect(subject.enable(feature, actor_gate, flipper.actor(actor_22))).to eq(true)
87
+ expect(subject.enable(feature, actor_gate, flipper.actor(actor22))).to eq(true)
104
88
  expect(subject.enable(feature, actor_gate, flipper.actor(actor_asdf))).to eq(true)
105
89
 
106
90
  result = subject.get(feature)
107
91
  expect(result[:actors]).to eq(Set['22', 'asdf'])
108
92
 
109
- expect(subject.disable(feature, actor_gate, flipper.actor(actor_22))).to eq(true)
93
+ expect(subject.disable(feature, actor_gate, flipper.actor(actor22))).to eq(true)
110
94
  result = subject.get(feature)
111
95
  expect(result[:actors]).to eq(Set['asdf'])
112
96
 
@@ -115,7 +99,7 @@ RSpec.shared_examples_for 'a flipper adapter' do
115
99
  expect(result[:actors]).to eq(Set.new)
116
100
  end
117
101
 
118
- it "can enable, disable and get value for percentage of actors gate" do
102
+ it 'can enable, disable and get value for percentage of actors gate' do
119
103
  expect(subject.enable(feature, actors_gate, flipper.actors(15))).to eq(true)
120
104
  result = subject.get(feature)
121
105
  expect(result[:percentage_of_actors]).to eq('15')
@@ -125,7 +109,7 @@ RSpec.shared_examples_for 'a flipper adapter' do
125
109
  expect(result[:percentage_of_actors]).to eq('0')
126
110
  end
127
111
 
128
- it "can enable percentage of actors gate many times and consistently return values" do
112
+ it 'can enable percentage of actors gate many times and consistently return values' do
129
113
  (1..100).each do |percentage|
130
114
  expect(subject.enable(feature, actors_gate, flipper.actors(percentage))).to eq(true)
131
115
  result = subject.get(feature)
@@ -133,7 +117,7 @@ RSpec.shared_examples_for 'a flipper adapter' do
133
117
  end
134
118
  end
135
119
 
136
- it "can disable percentage of actors gate many times and consistently return values" do
120
+ it 'can disable percentage of actors gate many times and consistently return values' do
137
121
  (1..100).each do |percentage|
138
122
  expect(subject.disable(feature, actors_gate, flipper.actors(percentage))).to eq(true)
139
123
  result = subject.get(feature)
@@ -141,7 +125,7 @@ RSpec.shared_examples_for 'a flipper adapter' do
141
125
  end
142
126
  end
143
127
 
144
- it "can enable, disable and get value for percentage of time gate" do
128
+ it 'can enable, disable and get value for percentage of time gate' do
145
129
  expect(subject.enable(feature, time_gate, flipper.time(10))).to eq(true)
146
130
  result = subject.get(feature)
147
131
  expect(result[:percentage_of_time]).to eq('10')
@@ -151,7 +135,7 @@ RSpec.shared_examples_for 'a flipper adapter' do
151
135
  expect(result[:percentage_of_time]).to eq('0')
152
136
  end
153
137
 
154
- it "can enable percentage of time gate many times and consistently return values" do
138
+ it 'can enable percentage of time gate many times and consistently return values' do
155
139
  (1..100).each do |percentage|
156
140
  expect(subject.enable(feature, time_gate, flipper.time(percentage))).to eq(true)
157
141
  result = subject.get(feature)
@@ -159,7 +143,7 @@ RSpec.shared_examples_for 'a flipper adapter' do
159
143
  end
160
144
  end
161
145
 
162
- it "can disable percentage of time gate many times and consistently return values" do
146
+ it 'can disable percentage of time gate many times and consistently return values' do
163
147
  (1..100).each do |percentage|
164
148
  expect(subject.disable(feature, time_gate, flipper.time(percentage))).to eq(true)
165
149
  result = subject.get(feature)
@@ -167,37 +151,37 @@ RSpec.shared_examples_for 'a flipper adapter' do
167
151
  end
168
152
  end
169
153
 
170
- it "converts boolean value to a string" do
154
+ it 'converts boolean value to a string' do
171
155
  expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
172
156
  result = subject.get(feature)
173
157
  expect(result[:boolean]).to eq('true')
174
158
  end
175
159
 
176
- it "converts the actor value to a string" do
160
+ it 'converts the actor value to a string' do
177
161
  expect(subject.enable(feature, actor_gate, flipper.actor(actor_class.new(22)))).to eq(true)
178
162
  result = subject.get(feature)
179
163
  expect(result[:actors]).to eq(Set['22'])
180
164
  end
181
165
 
182
- it "converts group value to a string" do
166
+ it 'converts group value to a string' do
183
167
  expect(subject.enable(feature, group_gate, flipper.group(:admins))).to eq(true)
184
168
  result = subject.get(feature)
185
169
  expect(result[:groups]).to eq(Set['admins'])
186
170
  end
187
171
 
188
- it "converts percentage of time integer value to a string" do
172
+ it 'converts percentage of time integer value to a string' do
189
173
  expect(subject.enable(feature, time_gate, flipper.time(10))).to eq(true)
190
174
  result = subject.get(feature)
191
175
  expect(result[:percentage_of_time]).to eq('10')
192
176
  end
193
177
 
194
- it "converts percentage of actors integer value to a string" do
178
+ it 'converts percentage of actors integer value to a string' do
195
179
  expect(subject.enable(feature, actors_gate, flipper.actors(10))).to eq(true)
196
180
  result = subject.get(feature)
197
181
  expect(result[:percentage_of_actors]).to eq('10')
198
182
  end
199
183
 
200
- it "can add, remove and list known features" do
184
+ it 'can add, remove and list known features' do
201
185
  expect(subject.features).to eq(Set.new)
202
186
 
203
187
  expect(subject.add(flipper[:stats])).to eq(true)
@@ -213,46 +197,40 @@ RSpec.shared_examples_for 'a flipper adapter' do
213
197
  expect(subject.features).to eq(Set.new)
214
198
  end
215
199
 
216
- it "clears all the gate values for the feature on remove" do
217
- actor_22 = actor_class.new('22')
200
+ it 'clears all the gate values for the feature on remove' do
201
+ actor22 = actor_class.new('22')
218
202
  expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
219
203
  expect(subject.enable(feature, group_gate, flipper.group(:admins))).to eq(true)
220
- expect(subject.enable(feature, actor_gate, flipper.actor(actor_22))).to eq(true)
204
+ expect(subject.enable(feature, actor_gate, flipper.actor(actor22))).to eq(true)
221
205
  expect(subject.enable(feature, actors_gate, flipper.actors(25))).to eq(true)
222
206
  expect(subject.enable(feature, time_gate, flipper.time(45))).to eq(true)
223
207
 
224
208
  expect(subject.remove(feature)).to eq(true)
225
209
 
226
- expect(subject.get(feature)).to eq({
227
- :boolean => nil,
228
- :groups => Set.new,
229
- :actors => Set.new,
230
- :percentage_of_actors => nil,
231
- :percentage_of_time => nil,
232
- })
210
+ expect(subject.get(feature)).to eq(subject.default_config)
233
211
  end
234
212
 
235
- it "can clear all the gate values for a feature" do
236
- actor_22 = actor_class.new('22')
213
+ it 'can clear all the gate values for a feature' do
214
+ actor22 = actor_class.new('22')
237
215
  subject.add(feature)
238
216
  expect(subject.features).to include(feature.key)
239
217
 
240
218
  expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
241
219
  expect(subject.enable(feature, group_gate, flipper.group(:admins))).to eq(true)
242
- expect(subject.enable(feature, actor_gate, flipper.actor(actor_22))).to eq(true)
220
+ expect(subject.enable(feature, actor_gate, flipper.actor(actor22))).to eq(true)
243
221
  expect(subject.enable(feature, actors_gate, flipper.actors(25))).to eq(true)
244
222
  expect(subject.enable(feature, time_gate, flipper.time(45))).to eq(true)
245
223
 
246
224
  expect(subject.clear(feature)).to eq(true)
247
225
  expect(subject.features).to include(feature.key)
248
- expect(subject.get(feature)).to eq(default_config)
226
+ expect(subject.get(feature)).to eq(subject.default_config)
249
227
  end
250
228
 
251
- it "does not complain clearing a feature that does not exist in adapter" do
229
+ it 'does not complain clearing a feature that does not exist in adapter' do
252
230
  expect(subject.clear(flipper[:stats])).to eq(true)
253
231
  end
254
232
 
255
- it "can get multiple features" do
233
+ it 'can get multiple features' do
256
234
  expect(subject.add(flipper[:stats])).to eq(true)
257
235
  expect(subject.enable(flipper[:stats], boolean_gate, flipper.boolean)).to eq(true)
258
236
 
@@ -262,8 +240,8 @@ RSpec.shared_examples_for 'a flipper adapter' do
262
240
  expect(result).to be_instance_of(Hash)
263
241
 
264
242
  stats, search, other = result.values
265
- expect(stats).to eq(default_config.merge(boolean: "true"))
266
- expect(search).to eq(default_config)
267
- expect(other).to eq(default_config)
243
+ expect(stats).to eq(subject.default_config.merge(boolean: 'true'))
244
+ expect(search).to eq(subject.default_config)
245
+ expect(other).to eq(subject.default_config)
268
246
  end
269
247
  end
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Metrics/ModuleLength
1
2
  module Flipper
2
3
  module Test
3
4
  module SharedAdapterTests
@@ -9,24 +10,16 @@ module Flipper
9
10
  @boolean_gate = @feature.gate(:boolean)
10
11
  @group_gate = @feature.gate(:group)
11
12
  @actor_gate = @feature.gate(:actor)
12
- @actors_gate = @feature.gate(:percentage_of_actors)
13
- @time_gate = @feature.gate(:percentage_of_time)
14
-
15
- @default_config = {
16
- :boolean => nil,
17
- :groups => Set.new,
18
- :actors => Set.new,
19
- :percentage_of_actors => nil,
20
- :percentage_of_time => nil,
21
- }
13
+ @actors_gate = @feature.gate(:percentage_of_actors)
14
+ @time_gate = @feature.gate(:percentage_of_time)
22
15
 
23
16
  Flipper.register(:admins) do |actor|
24
17
  actor.respond_to?(:admin?) && actor.admin?
25
18
  end
26
19
 
27
- Flipper.register(:early_access) { |actor|
20
+ Flipper.register(:early_access) do |actor|
28
21
  actor.respond_to?(:early_access?) && actor.early_access?
29
- }
22
+ end
30
23
  end
31
24
 
32
25
  def teardown
@@ -35,16 +28,16 @@ module Flipper
35
28
  end
36
29
 
37
30
  def test_has_name_that_is_a_symbol
38
- refute_empty @adapter.name
31
+ refute_empty @adapter.name
39
32
  assert_kind_of Symbol, @adapter.name
40
33
  end
41
34
 
42
35
  def test_has_included_the_flipper_adapter_module
43
- assert_includes @adapter.class.ancestors, Flipper::Adapter
36
+ assert_includes @adapter.class.ancestors, Flipper::Adapter
44
37
  end
45
38
 
46
39
  def test_returns_correct_default_values_for_gates_if_none_are_enabled
47
- assert_equal @default_config, @adapter.get(@feature)
40
+ assert_equal @adapter.default_config, @adapter.get(@feature)
48
41
  end
49
42
 
50
43
  def test_can_enable_disable_and_get_value_for_boolean_gate
@@ -55,14 +48,14 @@ module Flipper
55
48
  end
56
49
 
57
50
  def test_fully_disables_all_enabled_things_when_boolean_gate_disabled
58
- actor_22 = @actor_class.new('22')
51
+ actor22 = @actor_class.new('22')
59
52
  assert_equal true, @adapter.enable(@feature, @boolean_gate, @flipper.boolean)
60
53
  assert_equal true, @adapter.enable(@feature, @group_gate, @flipper.group(:admins))
61
- assert_equal true, @adapter.enable(@feature, @actor_gate, @flipper.actor(actor_22))
54
+ assert_equal true, @adapter.enable(@feature, @actor_gate, @flipper.actor(actor22))
62
55
  assert_equal true, @adapter.enable(@feature, @actors_gate, @flipper.actors(25))
63
56
  assert_equal true, @adapter.enable(@feature, @time_gate, @flipper.time(45))
64
57
  assert_equal true, @adapter.disable(@feature, @boolean_gate, @flipper.boolean(false))
65
- assert_equal @default_config, @adapter.get(@feature)
58
+ assert_equal @adapter.default_config, @adapter.get(@feature)
66
59
  end
67
60
 
68
61
  def test_can_enable_disable_get_value_for_group_gate
@@ -82,16 +75,16 @@ module Flipper
82
75
  end
83
76
 
84
77
  def test_can_enable_disable_and_get_value_for_an_actor_gate
85
- actor_22 = @actor_class.new('22')
78
+ actor22 = @actor_class.new('22')
86
79
  actor_asdf = @actor_class.new('asdf')
87
80
 
88
- assert_equal true, @adapter.enable(@feature, @actor_gate, @flipper.actor(actor_22))
81
+ assert_equal true, @adapter.enable(@feature, @actor_gate, @flipper.actor(actor22))
89
82
  assert_equal true, @adapter.enable(@feature, @actor_gate, @flipper.actor(actor_asdf))
90
83
 
91
84
  result = @adapter.get(@feature)
92
85
  assert_equal Set['22', 'asdf'], result[:actors]
93
86
 
94
- assert true, @adapter.disable(@feature, @actor_gate, @flipper.actor(actor_22))
87
+ assert true, @adapter.disable(@feature, @actor_gate, @flipper.actor(actor22))
95
88
  result = @adapter.get(@feature)
96
89
  assert_equal Set['asdf'], result[:actors]
97
90
 
@@ -159,7 +152,8 @@ module Flipper
159
152
  end
160
153
 
161
154
  def test_converts_the_actor_value_to_a_string
162
- assert_equal true, @adapter.enable(@feature, @actor_gate, @flipper.actor(@actor_class.new(22)))
155
+ assert_equal true,
156
+ @adapter.enable(@feature, @actor_gate, @flipper.actor(@actor_class.new(22)))
163
157
  result = @adapter.get(@feature)
164
158
  assert_equal Set['22'], result[:actors]
165
159
  end
@@ -199,32 +193,32 @@ module Flipper
199
193
  end
200
194
 
201
195
  def test_clears_all_the_gate_values_for_the_feature_on_remove
202
- actor_22 = @actor_class.new('22')
196
+ actor22 = @actor_class.new('22')
203
197
  assert_equal true, @adapter.enable(@feature, @boolean_gate, @flipper.boolean)
204
198
  assert_equal true, @adapter.enable(@feature, @group_gate, @flipper.group(:admins))
205
- assert_equal true, @adapter.enable(@feature, @actor_gate, @flipper.actor(actor_22))
199
+ assert_equal true, @adapter.enable(@feature, @actor_gate, @flipper.actor(actor22))
206
200
  assert_equal true, @adapter.enable(@feature, @actors_gate, @flipper.actors(25))
207
201
  assert_equal true, @adapter.enable(@feature, @time_gate, @flipper.time(45))
208
202
 
209
203
  assert_equal true, @adapter.remove(@feature)
210
204
 
211
- assert_equal @default_config, @adapter.get(@feature)
205
+ assert_equal @adapter.default_config, @adapter.get(@feature)
212
206
  end
213
207
 
214
208
  def test_can_clear_all_the_gate_values_for_a_feature
215
- actor_22 = @actor_class.new('22')
209
+ actor22 = @actor_class.new('22')
216
210
  @adapter.add(@feature)
217
211
  assert_includes @adapter.features, @feature.key
218
212
 
219
213
  assert_equal true, @adapter.enable(@feature, @boolean_gate, @flipper.boolean)
220
214
  assert_equal true, @adapter.enable(@feature, @group_gate, @flipper.group(:admins))
221
- assert_equal true, @adapter.enable(@feature, @actor_gate, @flipper.actor(actor_22))
215
+ assert_equal true, @adapter.enable(@feature, @actor_gate, @flipper.actor(actor22))
222
216
  assert_equal true, @adapter.enable(@feature, @actors_gate, @flipper.actors(25))
223
217
  assert_equal true, @adapter.enable(@feature, @time_gate, @flipper.time(45))
224
218
 
225
219
  assert_equal true, @adapter.clear(@feature)
226
220
  assert_includes @adapter.features, @feature.key
227
- assert_equal @default_config, @adapter.get(@feature)
221
+ assert_equal @adapter.default_config, @adapter.get(@feature)
228
222
  end
229
223
 
230
224
  def test_does_not_complain_clearing_a_feature_that_does_not_exist_in_adapter
@@ -240,9 +234,9 @@ module Flipper
240
234
  assert_instance_of Hash, result
241
235
 
242
236
  stats, search, other = result.values
243
- assert_equal @default_config.merge(boolean: "true"), stats
244
- assert_equal @default_config, search
245
- assert_equal @default_config, other
237
+ assert_equal @adapter.default_config.merge(boolean: 'true'), stats
238
+ assert_equal @adapter.default_config, search
239
+ assert_equal @adapter.default_config, other
246
240
  end
247
241
  end
248
242
  end