Sha256: bf64180d8d143fdbfe1cad8d71629fabe7e758ef4cf395098b947878d7ad5e39

Contents?: true

Size: 644 Bytes

Versions: 38

Compression:

Stored size: 644 Bytes

Contents

require 'bundler/setup'
require 'flipper'

# Some class that represents what will be trying to do something
class User
  attr_reader :id

  def initialize(id)
    @id = id
  end

  # Must respond to flipper_id
  alias_method :flipper_id, :id
end

# checking a bunch
total = 20_000
enabled = []
percentage_enabled = 10

feature = Flipper[:data_migration]
feature.enable_percentage_of_actors 10

(1..total).each do |id|
  user = User.new(id)
  if feature.enabled? user
    enabled << user
  end
end

p actual: enabled.size, expected: total * (percentage_enabled * 0.01)

# checking one
user = User.new(1)
p user_1_enabled: feature.enabled?(user)

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
flipper-1.3.2 examples/percentage_of_actors_enabled_check.rb
flipper-1.3.1 examples/percentage_of_actors_enabled_check.rb
flipper-1.3.0 examples/percentage_of_actors_enabled_check.rb
flipper-1.3.0.pre examples/percentage_of_actors_enabled_check.rb
flipper-1.2.2 examples/percentage_of_actors_enabled_check.rb
flipper-1.2.1 examples/percentage_of_actors_enabled_check.rb
flipper-1.2.0 examples/percentage_of_actors_enabled_check.rb
flipper-1.1.2 examples/percentage_of_actors_enabled_check.rb
flipper-1.1.1 examples/percentage_of_actors_enabled_check.rb
flipper-1.1.0 examples/percentage_of_actors_enabled_check.rb
flipper-1.0.0 examples/percentage_of_actors_enabled_check.rb
flipper-1.0.0.pre examples/percentage_of_actors_enabled_check.rb
flipper-0.28.3 examples/percentage_of_actors_enabled_check.rb
flipper-0.28.2 examples/percentage_of_actors_enabled_check.rb
flipper-0.28.1 examples/percentage_of_actors_enabled_check.rb
flipper-0.28.0 examples/percentage_of_actors_enabled_check.rb
flipper-0.27.1 examples/percentage_of_actors_enabled_check.rb
flipper-0.27.0 examples/percentage_of_actors_enabled_check.rb
flipper-0.26.2 examples/percentage_of_actors_enabled_check.rb
flipper-0.26.1 examples/percentage_of_actors_enabled_check.rb