flipper 0.28.3 → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +23 -0
  3. data/Gemfile +5 -3
  4. data/docs/images/flipper_cloud.png +0 -0
  5. data/examples/cloud/app.ru +12 -0
  6. data/examples/cloud/basic.rb +22 -0
  7. data/examples/cloud/cloud_setup.rb +4 -0
  8. data/examples/cloud/forked.rb +31 -0
  9. data/examples/cloud/import.rb +17 -0
  10. data/examples/cloud/threaded.rb +36 -0
  11. data/examples/dsl.rb +0 -14
  12. data/flipper-cloud.gemspec +19 -0
  13. data/flipper.gemspec +3 -2
  14. data/lib/flipper/cloud/configuration.rb +189 -0
  15. data/lib/flipper/cloud/dsl.rb +27 -0
  16. data/lib/flipper/cloud/instrumenter.rb +48 -0
  17. data/lib/flipper/cloud/message_verifier.rb +95 -0
  18. data/lib/flipper/cloud/middleware.rb +63 -0
  19. data/lib/flipper/cloud/routes.rb +14 -0
  20. data/lib/flipper/cloud.rb +53 -0
  21. data/lib/flipper/dsl.rb +0 -46
  22. data/lib/flipper/{railtie.rb → engine.rb} +19 -3
  23. data/lib/flipper/metadata.rb +5 -1
  24. data/lib/flipper/spec/shared_adapter_specs.rb +43 -43
  25. data/lib/flipper/test/shared_adapter_test.rb +43 -43
  26. data/lib/flipper/version.rb +1 -1
  27. data/lib/flipper.rb +3 -5
  28. data/spec/flipper/adapters/dual_write_spec.rb +2 -2
  29. data/spec/flipper/adapters/instrumented_spec.rb +1 -1
  30. data/spec/flipper/adapters/memoizable_spec.rb +6 -6
  31. data/spec/flipper/adapters/operation_logger_spec.rb +2 -2
  32. data/spec/flipper/adapters/read_only_spec.rb +6 -6
  33. data/spec/flipper/cloud/configuration_spec.rb +269 -0
  34. data/spec/flipper/cloud/dsl_spec.rb +82 -0
  35. data/spec/flipper/cloud/message_verifier_spec.rb +104 -0
  36. data/spec/flipper/cloud/middleware_spec.rb +289 -0
  37. data/spec/flipper/cloud_spec.rb +180 -0
  38. data/spec/flipper/dsl_spec.rb +0 -75
  39. data/spec/flipper/engine_spec.rb +190 -0
  40. data/spec/flipper_integration_spec.rb +12 -12
  41. data/spec/flipper_spec.rb +0 -30
  42. data/spec/spec_helper.rb +0 -12
  43. data/spec/support/climate_control.rb +7 -0
  44. metadata +54 -10
  45. data/spec/flipper/railtie_spec.rb +0 -109
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "flipper/cloud/message_verifier"
4
+
5
+ module Flipper
6
+ module Cloud
7
+ class Middleware
8
+ # Internal: The path to match for webhook requests.
9
+ WEBHOOK_PATH = %r{\A/webhooks\/?\Z}
10
+ # Internal: The root path to match for requests.
11
+ ROOT_PATH = %r{\A/\Z}
12
+
13
+ def initialize(app, options = {})
14
+ @app = app
15
+ @env_key = options.fetch(:env_key, 'flipper')
16
+ end
17
+
18
+ def call(env)
19
+ dup.call!(env)
20
+ end
21
+
22
+ def call!(env)
23
+ request = Rack::Request.new(env)
24
+ if request.post? && (request.path_info.match(ROOT_PATH) || request.path_info.match(WEBHOOK_PATH))
25
+ status = 200
26
+ headers = {
27
+ "content-type" => "application/json",
28
+ }
29
+ body = "{}"
30
+ payload = request.body.read
31
+ signature = request.env["HTTP_FLIPPER_CLOUD_SIGNATURE"]
32
+ flipper = env.fetch(@env_key)
33
+
34
+ begin
35
+ message_verifier = MessageVerifier.new(secret: flipper.sync_secret)
36
+ if message_verifier.verify(payload, signature)
37
+ begin
38
+ flipper.sync
39
+ body = JSON.generate({
40
+ groups: Flipper.group_names.map { |name| {name: name}}
41
+ })
42
+ rescue Flipper::Adapters::Http::Error => error
43
+ status = error.response.code.to_i == 402 ? 402 : 500
44
+ headers["Flipper-Cloud-Response-Error-Class"] = error.class.name
45
+ headers["Flipper-Cloud-Response-Error-Message"] = error.message
46
+ rescue => error
47
+ status = 500
48
+ headers["Flipper-Cloud-Response-Error-Class"] = error.class.name
49
+ headers["Flipper-Cloud-Response-Error-Message"] = error.message
50
+ end
51
+ end
52
+ rescue MessageVerifier::InvalidSignature
53
+ status = 400
54
+ end
55
+
56
+ [status, headers, [body]]
57
+ else
58
+ @app.call(env)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,14 @@
1
+ # Default routes loaded by Flipper::Cloud::Engine
2
+ Rails.application.routes.draw do
3
+ if ENV["FLIPPER_CLOUD_TOKEN"] && ENV["FLIPPER_CLOUD_SYNC_SECRET"]
4
+ require 'flipper/cloud'
5
+ config = Rails.application.config.flipper
6
+
7
+ cloud_app = Flipper::Cloud.app(nil,
8
+ env_key: config.env_key,
9
+ memoizer_options: { preload: config.preload }
10
+ )
11
+
12
+ mount cloud_app, at: config.cloud_path
13
+ end
14
+ end
@@ -0,0 +1,53 @@
1
+ require "flipper"
2
+ require "flipper/middleware/setup_env"
3
+ require "flipper/middleware/memoizer"
4
+ require "flipper/cloud/configuration"
5
+ require "flipper/cloud/dsl"
6
+ require "flipper/cloud/middleware"
7
+
8
+ module Flipper
9
+ module Cloud
10
+ # Public: Returns a new Flipper instance with an http adapter correctly
11
+ # configured for flipper cloud.
12
+ #
13
+ # token - The String token for the environment from the website.
14
+ # options - The Hash of options. See Flipper::Cloud::Configuration.
15
+ # block - The block that configuration will be yielded to allowing you to
16
+ # customize this cloud instance and its adapter.
17
+ def self.new(options = {})
18
+ configuration = Configuration.new(options)
19
+ yield configuration if block_given?
20
+ DSL.new(configuration)
21
+ end
22
+
23
+ def self.app(flipper = nil, options = {})
24
+ env_key = options.fetch(:env_key, 'flipper')
25
+ memoizer_options = options.fetch(:memoizer_options, {})
26
+
27
+ app = ->(_) { [404, { 'content-type'.freeze => 'application/json'.freeze }, ['{}'.freeze]] }
28
+ builder = Rack::Builder.new
29
+ yield builder if block_given?
30
+ builder.use Flipper::Middleware::SetupEnv, flipper, env_key: env_key
31
+ builder.use Flipper::Middleware::Memoizer, memoizer_options.merge(env_key: env_key)
32
+ builder.use Flipper::Cloud::Middleware, env_key: env_key
33
+ builder.run app
34
+ klass = self
35
+ app = builder.to_app
36
+ app.define_singleton_method(:inspect) { klass.inspect } # pretty rake routes output
37
+ app
38
+ end
39
+
40
+ # Private: Configure Flipper to use Cloud by default
41
+ def self.set_default
42
+ if ENV["FLIPPER_CLOUD_TOKEN"]
43
+ Flipper.configure do |config|
44
+ config.default do
45
+ self.new(local_adapter: config.adapter)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ Flipper::Cloud.set_default
data/lib/flipper/dsl.rb CHANGED
@@ -210,22 +210,6 @@ module Flipper
210
210
  # Returns an instance of Flipper::Feature.
211
211
  alias_method :[], :feature
212
212
 
213
- # Public: Shortcut for getting a boolean type instance.
214
- #
215
- # value - The true or false value for the boolean.
216
- #
217
- # Returns a Flipper::Types::Boolean instance.
218
- def boolean(value = true)
219
- Types::Boolean.new(value)
220
- end
221
-
222
- # Public: Even shorter shortcut for getting a boolean type instance.
223
- #
224
- # value - The true or false value for the boolean.
225
- #
226
- # Returns a Flipper::Types::Boolean instance.
227
- alias_method :bool, :boolean
228
-
229
213
  # Public: Access a flipper group by name.
230
214
  #
231
215
  # name - The String or Symbol name of the feature.
@@ -235,36 +219,6 @@ module Flipper
235
219
  Flipper.group(name)
236
220
  end
237
221
 
238
- # Public: Wraps an object as a flipper actor.
239
- #
240
- # actor - The object that you would like to wrap.
241
- #
242
- # Returns an instance of Flipper::Types::Actor.
243
- # Raises ArgumentError if actor does not respond to `flipper_id`.
244
- def actor(actor)
245
- Types::Actor.new(actor)
246
- end
247
-
248
- # Public: Shortcut for getting a percentage of time instance.
249
- #
250
- # number - The percentage of time that should be enabled.
251
- #
252
- # Returns Flipper::Types::PercentageOfTime.
253
- def time(number)
254
- Types::PercentageOfTime.new(number)
255
- end
256
- alias_method :percentage_of_time, :time
257
-
258
- # Public: Shortcut for getting a percentage of actors instance.
259
- #
260
- # number - The percentage of actors that should be enabled.
261
- #
262
- # Returns Flipper::Types::PercentageOfActors.
263
- def actors(number)
264
- Types::PercentageOfActors.new(number)
265
- end
266
- alias_method :percentage_of_actors, :actors
267
-
268
222
  # Public: Returns a Set of the known features for this adapter.
269
223
  #
270
224
  # Returns Set of Flipper::Feature instances.
@@ -1,12 +1,15 @@
1
1
  module Flipper
2
- class Railtie < Rails::Railtie
2
+ class Engine < Rails::Engine
3
+ paths["config/routes.rb"] = ["lib/flipper/cloud/routes.rb"]
4
+
3
5
  config.before_configuration do
4
6
  config.flipper = ActiveSupport::OrderedOptions.new.update(
5
7
  env_key: ENV.fetch('FLIPPER_ENV_KEY', 'flipper'),
6
8
  memoize: ENV.fetch('FLIPPER_MEMOIZE', 'true').casecmp('true').zero?,
7
9
  preload: ENV.fetch('FLIPPER_PRELOAD', 'true').casecmp('true').zero?,
8
10
  instrumenter: ENV.fetch('FLIPPER_INSTRUMENTER', 'ActiveSupport::Notifications').constantize,
9
- log: ENV.fetch('FLIPPER_LOG', 'true').casecmp('true').zero?
11
+ log: ENV.fetch('FLIPPER_LOG', 'true').casecmp('true').zero?,
12
+ cloud_path: "_flipper"
10
13
  )
11
14
  end
12
15
 
@@ -17,9 +20,18 @@ module Flipper
17
20
  end
18
21
 
19
22
  initializer "flipper.default", before: :load_config_initializers do |app|
23
+ require 'flipper/cloud' if cloud?
24
+
20
25
  Flipper.configure do |config|
21
26
  config.default do
22
- Flipper.new(config.adapter, instrumenter: app.config.flipper.instrumenter)
27
+ if cloud?
28
+ Flipper::Cloud.new(
29
+ local_adapter: config.adapter,
30
+ instrumenter: app.config.flipper.instrumenter
31
+ )
32
+ else
33
+ Flipper.new(config.adapter, instrumenter: app.config.flipper.instrumenter)
34
+ end
23
35
  end
24
36
  end
25
37
  end
@@ -43,5 +55,9 @@ module Flipper
43
55
  }
44
56
  end
45
57
  end
58
+
59
+ def cloud?
60
+ !!ENV["FLIPPER_CLOUD_TOKEN"]
61
+ end
46
62
  end
47
63
  end
@@ -1,5 +1,9 @@
1
1
  module Flipper
2
2
  METADATA = {
3
- 'changelog_uri' => 'https://github.com/jnunemaker/flipper/blob/main/Changelog.md',
3
+ "documentation_uri" => "https://www.flippercloud.io/docs",
4
+ "homepage_uri" => "https://www.flippercloud.io",
5
+ "source_code_uri" => "https://github.com/jnunemaker/flipper",
6
+ "bug_tracker_uri" => "https://github.com/jnunemaker/flipper/issues",
7
+ "changelog_uri" => "https://github.com/jnunemaker/flipper/blob/main/Changelog.md",
4
8
  }.freeze
5
9
  end
@@ -46,12 +46,12 @@ RSpec.shared_examples_for 'a flipper adapter' do
46
46
  end
47
47
 
48
48
  it 'can enable, disable and get value for boolean gate' do
49
- expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
49
+ expect(subject.enable(feature, boolean_gate, Flipper::Types::Boolean.new)).to eq(true)
50
50
 
51
51
  result = subject.get(feature)
52
52
  expect(result[:boolean]).to eq('true')
53
53
 
54
- expect(subject.disable(feature, boolean_gate, flipper.boolean(false))).to eq(true)
54
+ expect(subject.disable(feature, boolean_gate, Flipper::Types::Boolean.new(false))).to eq(true)
55
55
 
56
56
  result = subject.get(feature)
57
57
  expect(result[:boolean]).to eq(nil)
@@ -59,13 +59,13 @@ RSpec.shared_examples_for 'a flipper adapter' do
59
59
 
60
60
  it 'fully disables all enabled things when boolean gate disabled' do
61
61
  actor22 = Flipper::Actor.new('22')
62
- expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
62
+ expect(subject.enable(feature, boolean_gate, Flipper::Types::Boolean.new)).to eq(true)
63
63
  expect(subject.enable(feature, group_gate, flipper.group(:admins))).to eq(true)
64
- expect(subject.enable(feature, actor_gate, flipper.actor(actor22))).to eq(true)
65
- expect(subject.enable(feature, actors_gate, flipper.actors(25))).to eq(true)
66
- expect(subject.enable(feature, time_gate, flipper.time(45))).to eq(true)
64
+ expect(subject.enable(feature, actor_gate, Flipper::Types::Actor.new(actor22))).to eq(true)
65
+ expect(subject.enable(feature, actors_gate, Flipper::Types::PercentageOfActors.new(25))).to eq(true)
66
+ expect(subject.enable(feature, time_gate, Flipper::Types::PercentageOfTime.new(45))).to eq(true)
67
67
 
68
- expect(subject.disable(feature, boolean_gate, flipper.boolean(false))).to eq(true)
68
+ expect(subject.disable(feature, boolean_gate, Flipper::Types::Boolean.new(false))).to eq(true)
69
69
 
70
70
  expect(subject.get(feature)).to eq(subject.default_config)
71
71
  end
@@ -90,34 +90,34 @@ RSpec.shared_examples_for 'a flipper adapter' do
90
90
  actor22 = Flipper::Actor.new('22')
91
91
  actor_asdf = Flipper::Actor.new('asdf')
92
92
 
93
- expect(subject.enable(feature, actor_gate, flipper.actor(actor22))).to eq(true)
94
- expect(subject.enable(feature, actor_gate, flipper.actor(actor_asdf))).to eq(true)
93
+ expect(subject.enable(feature, actor_gate, Flipper::Types::Actor.new(actor22))).to eq(true)
94
+ expect(subject.enable(feature, actor_gate, Flipper::Types::Actor.new(actor_asdf))).to eq(true)
95
95
 
96
96
  result = subject.get(feature)
97
97
  expect(result[:actors]).to eq(Set['22', 'asdf'])
98
98
 
99
- expect(subject.disable(feature, actor_gate, flipper.actor(actor22))).to eq(true)
99
+ expect(subject.disable(feature, actor_gate, Flipper::Types::Actor.new(actor22))).to eq(true)
100
100
  result = subject.get(feature)
101
101
  expect(result[:actors]).to eq(Set['asdf'])
102
102
 
103
- expect(subject.disable(feature, actor_gate, flipper.actor(actor_asdf))).to eq(true)
103
+ expect(subject.disable(feature, actor_gate, Flipper::Types::Actor.new(actor_asdf))).to eq(true)
104
104
  result = subject.get(feature)
105
105
  expect(result[:actors]).to eq(Set.new)
106
106
  end
107
107
 
108
108
  it 'can enable, disable and get value for percentage of actors gate' do
109
- expect(subject.enable(feature, actors_gate, flipper.actors(15))).to eq(true)
109
+ expect(subject.enable(feature, actors_gate, Flipper::Types::PercentageOfActors.new(15))).to eq(true)
110
110
  result = subject.get(feature)
111
111
  expect(result[:percentage_of_actors]).to eq('15')
112
112
 
113
- expect(subject.disable(feature, actors_gate, flipper.actors(0))).to eq(true)
113
+ expect(subject.disable(feature, actors_gate, Flipper::Types::PercentageOfActors.new(0))).to eq(true)
114
114
  result = subject.get(feature)
115
115
  expect(result[:percentage_of_actors]).to eq('0')
116
116
  end
117
117
 
118
118
  it 'can enable percentage of actors gate many times and consistently return values' do
119
119
  (1..100).each do |percentage|
120
- expect(subject.enable(feature, actors_gate, flipper.actors(percentage))).to eq(true)
120
+ expect(subject.enable(feature, actors_gate, Flipper::Types::PercentageOfActors.new(percentage))).to eq(true)
121
121
  result = subject.get(feature)
122
122
  expect(result[:percentage_of_actors]).to eq(percentage.to_s)
123
123
  end
@@ -125,25 +125,25 @@ RSpec.shared_examples_for 'a flipper adapter' do
125
125
 
126
126
  it 'can disable percentage of actors gate many times and consistently return values' do
127
127
  (1..100).each do |percentage|
128
- expect(subject.disable(feature, actors_gate, flipper.actors(percentage))).to eq(true)
128
+ expect(subject.disable(feature, actors_gate, Flipper::Types::PercentageOfActors.new(percentage))).to eq(true)
129
129
  result = subject.get(feature)
130
130
  expect(result[:percentage_of_actors]).to eq(percentage.to_s)
131
131
  end
132
132
  end
133
133
 
134
134
  it 'can enable, disable and get value for percentage of time gate' do
135
- expect(subject.enable(feature, time_gate, flipper.time(10))).to eq(true)
135
+ expect(subject.enable(feature, time_gate, Flipper::Types::PercentageOfTime.new(10))).to eq(true)
136
136
  result = subject.get(feature)
137
137
  expect(result[:percentage_of_time]).to eq('10')
138
138
 
139
- expect(subject.disable(feature, time_gate, flipper.time(0))).to eq(true)
139
+ expect(subject.disable(feature, time_gate, Flipper::Types::PercentageOfTime.new(0))).to eq(true)
140
140
  result = subject.get(feature)
141
141
  expect(result[:percentage_of_time]).to eq('0')
142
142
  end
143
143
 
144
144
  it 'can enable percentage of time gate many times and consistently return values' do
145
145
  (1..100).each do |percentage|
146
- expect(subject.enable(feature, time_gate, flipper.time(percentage))).to eq(true)
146
+ expect(subject.enable(feature, time_gate, Flipper::Types::PercentageOfTime.new(percentage))).to eq(true)
147
147
  result = subject.get(feature)
148
148
  expect(result[:percentage_of_time]).to eq(percentage.to_s)
149
149
  end
@@ -151,20 +151,20 @@ RSpec.shared_examples_for 'a flipper adapter' do
151
151
 
152
152
  it 'can disable percentage of time gate many times and consistently return values' do
153
153
  (1..100).each do |percentage|
154
- expect(subject.disable(feature, time_gate, flipper.time(percentage))).to eq(true)
154
+ expect(subject.disable(feature, time_gate, Flipper::Types::PercentageOfTime.new(percentage))).to eq(true)
155
155
  result = subject.get(feature)
156
156
  expect(result[:percentage_of_time]).to eq(percentage.to_s)
157
157
  end
158
158
  end
159
159
 
160
160
  it 'converts boolean value to a string' do
161
- expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
161
+ expect(subject.enable(feature, boolean_gate, Flipper::Types::Boolean.new)).to eq(true)
162
162
  result = subject.get(feature)
163
163
  expect(result[:boolean]).to eq('true')
164
164
  end
165
165
 
166
166
  it 'converts the actor value to a string' do
167
- expect(subject.enable(feature, actor_gate, flipper.actor(Flipper::Actor.new(22)))).to eq(true)
167
+ expect(subject.enable(feature, actor_gate, Flipper::Types::Actor.new(Flipper::Actor.new(22)))).to eq(true)
168
168
  result = subject.get(feature)
169
169
  expect(result[:actors]).to eq(Set['22'])
170
170
  end
@@ -176,13 +176,13 @@ RSpec.shared_examples_for 'a flipper adapter' do
176
176
  end
177
177
 
178
178
  it 'converts percentage of time integer value to a string' do
179
- expect(subject.enable(feature, time_gate, flipper.time(10))).to eq(true)
179
+ expect(subject.enable(feature, time_gate, Flipper::Types::PercentageOfTime.new(10))).to eq(true)
180
180
  result = subject.get(feature)
181
181
  expect(result[:percentage_of_time]).to eq('10')
182
182
  end
183
183
 
184
184
  it 'converts percentage of actors integer value to a string' do
185
- expect(subject.enable(feature, actors_gate, flipper.actors(10))).to eq(true)
185
+ expect(subject.enable(feature, actors_gate, Flipper::Types::PercentageOfActors.new(10))).to eq(true)
186
186
  result = subject.get(feature)
187
187
  expect(result[:percentage_of_actors]).to eq('10')
188
188
  end
@@ -205,11 +205,11 @@ RSpec.shared_examples_for 'a flipper adapter' do
205
205
 
206
206
  it 'clears all the gate values for the feature on remove' do
207
207
  actor22 = Flipper::Actor.new('22')
208
- expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
208
+ expect(subject.enable(feature, boolean_gate, Flipper::Types::Boolean.new)).to eq(true)
209
209
  expect(subject.enable(feature, group_gate, flipper.group(:admins))).to eq(true)
210
- expect(subject.enable(feature, actor_gate, flipper.actor(actor22))).to eq(true)
211
- expect(subject.enable(feature, actors_gate, flipper.actors(25))).to eq(true)
212
- expect(subject.enable(feature, time_gate, flipper.time(45))).to eq(true)
210
+ expect(subject.enable(feature, actor_gate, Flipper::Types::Actor.new(actor22))).to eq(true)
211
+ expect(subject.enable(feature, actors_gate, Flipper::Types::PercentageOfActors.new(25))).to eq(true)
212
+ expect(subject.enable(feature, time_gate, Flipper::Types::PercentageOfTime.new(45))).to eq(true)
213
213
 
214
214
  expect(subject.remove(feature)).to eq(true)
215
215
 
@@ -221,11 +221,11 @@ RSpec.shared_examples_for 'a flipper adapter' do
221
221
  subject.add(feature)
222
222
  expect(subject.features).to include(feature.key)
223
223
 
224
- expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
224
+ expect(subject.enable(feature, boolean_gate, Flipper::Types::Boolean.new)).to eq(true)
225
225
  expect(subject.enable(feature, group_gate, flipper.group(:admins))).to eq(true)
226
- expect(subject.enable(feature, actor_gate, flipper.actor(actor22))).to eq(true)
227
- expect(subject.enable(feature, actors_gate, flipper.actors(25))).to eq(true)
228
- expect(subject.enable(feature, time_gate, flipper.time(45))).to eq(true)
226
+ expect(subject.enable(feature, actor_gate, Flipper::Types::Actor.new(actor22))).to eq(true)
227
+ expect(subject.enable(feature, actors_gate, Flipper::Types::PercentageOfActors.new(25))).to eq(true)
228
+ expect(subject.enable(feature, time_gate, Flipper::Types::PercentageOfTime.new(45))).to eq(true)
229
229
 
230
230
  expect(subject.clear(feature)).to eq(true)
231
231
  expect(subject.features).to include(feature.key)
@@ -238,7 +238,7 @@ RSpec.shared_examples_for 'a flipper adapter' do
238
238
 
239
239
  it 'can get multiple features' do
240
240
  expect(subject.add(flipper[:stats])).to eq(true)
241
- expect(subject.enable(flipper[:stats], boolean_gate, flipper.boolean)).to eq(true)
241
+ expect(subject.enable(flipper[:stats], boolean_gate, Flipper::Types::Boolean.new)).to eq(true)
242
242
  expect(subject.add(flipper[:search])).to eq(true)
243
243
 
244
244
  result = subject.get_multi([flipper[:stats], flipper[:search], flipper[:other]])
@@ -254,7 +254,7 @@ RSpec.shared_examples_for 'a flipper adapter' do
254
254
 
255
255
  it 'can get all features' do
256
256
  expect(subject.add(flipper[:stats])).to eq(true)
257
- expect(subject.enable(flipper[:stats], boolean_gate, flipper.boolean)).to eq(true)
257
+ expect(subject.enable(flipper[:stats], boolean_gate, Flipper::Types::Boolean.new)).to eq(true)
258
258
  expect(subject.add(flipper[:search])).to eq(true)
259
259
 
260
260
  result = subject.get_all
@@ -277,8 +277,8 @@ RSpec.shared_examples_for 'a flipper adapter' do
277
277
 
278
278
  it 'can double enable an actor without error' do
279
279
  actor = Flipper::Actor.new('Flipper::Actor;22')
280
- expect(subject.enable(feature, actor_gate, flipper.actor(actor))).to eq(true)
281
- expect(subject.enable(feature, actor_gate, flipper.actor(actor))).to eq(true)
280
+ expect(subject.enable(feature, actor_gate, Flipper::Types::Actor.new(actor))).to eq(true)
281
+ expect(subject.enable(feature, actor_gate, Flipper::Types::Actor.new(actor))).to eq(true)
282
282
  expect(subject.get(feature).fetch(:actors)).to eq(Set['Flipper::Actor;22'])
283
283
  end
284
284
 
@@ -289,13 +289,13 @@ RSpec.shared_examples_for 'a flipper adapter' do
289
289
  end
290
290
 
291
291
  it 'can double enable percentage without error' do
292
- expect(subject.enable(feature, actors_gate, flipper.actors(25))).to eq(true)
293
- expect(subject.enable(feature, actors_gate, flipper.actors(25))).to eq(true)
292
+ expect(subject.enable(feature, actors_gate, Flipper::Types::PercentageOfActors.new(25))).to eq(true)
293
+ expect(subject.enable(feature, actors_gate, Flipper::Types::PercentageOfActors.new(25))).to eq(true)
294
294
  end
295
295
 
296
296
  it 'can double enable without error' do
297
- expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
298
- expect(subject.enable(feature, boolean_gate, flipper.boolean)).to eq(true)
297
+ expect(subject.enable(feature, boolean_gate, Flipper::Types::Boolean.new)).to eq(true)
298
+ expect(subject.enable(feature, boolean_gate, Flipper::Types::Boolean.new)).to eq(true)
299
299
  end
300
300
 
301
301
  it 'can get_all features when there are none' do
@@ -305,11 +305,11 @@ RSpec.shared_examples_for 'a flipper adapter' do
305
305
 
306
306
  it 'clears other gate values on enable' do
307
307
  actor = Flipper::Actor.new('Flipper::Actor;22')
308
- subject.enable(feature, actors_gate, flipper.actors(25))
309
- subject.enable(feature, time_gate, flipper.time(25))
308
+ subject.enable(feature, actors_gate, Flipper::Types::PercentageOfActors.new(25))
309
+ subject.enable(feature, time_gate, Flipper::Types::PercentageOfTime.new(25))
310
310
  subject.enable(feature, group_gate, flipper.group(:admins))
311
- subject.enable(feature, actor_gate, flipper.actor(actor))
312
- subject.enable(feature, boolean_gate, flipper.boolean(true))
311
+ subject.enable(feature, actor_gate, Flipper::Types::Actor.new(actor))
312
+ subject.enable(feature, boolean_gate, Flipper::Types::Boolean.new(true))
313
313
  expect(subject.get(feature)).to eq(subject.default_config.merge(boolean: "true"))
314
314
  end
315
315