Sha256: ad5d731417d2a3d3632e47e4c8e73c340e83325f5e21901cf3178a016c551788

Contents?: true

Size: 870 Bytes

Versions: 16

Compression:

Stored size: 870 Bytes

Contents

require File.expand_path('../example_setup', __FILE__)

require 'flipper'

adapter = Flipper::Adapters::Memory.new
flipper = Flipper.new(adapter)

# 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
gate = Flipper::Gates::PercentageOfActors.new
feature_name = "data_migration"
percentage_enabled = 10
total = 20_000
enabled = []

(1..total).each do |id|
  user = User.new(id)
  if gate.open?(user, percentage_enabled, feature_name: feature_name)
    enabled << user
  end
end

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

# checking one
user = User.new(1)
p user_1_enabled: Flipper::Gates::PercentageOfActors.new.open?(user, percentage_enabled, feature_name: feature_name)

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
flipper-0.20.4 examples/percentage_of_actors_enabled_check.rb
flipper-0.20.3 examples/percentage_of_actors_enabled_check.rb
flipper-0.20.2 examples/percentage_of_actors_enabled_check.rb
flipper-0.20.1 examples/percentage_of_actors_enabled_check.rb
flipper-0.20.0 examples/percentage_of_actors_enabled_check.rb
flipper-0.20.0.beta3 examples/percentage_of_actors_enabled_check.rb
flipper-0.20.0.beta2 examples/percentage_of_actors_enabled_check.rb
flipper-0.20.0.beta1 examples/percentage_of_actors_enabled_check.rb
flipper-0.19.1 examples/percentage_of_actors_enabled_check.rb
flipper-0.19.0 examples/percentage_of_actors_enabled_check.rb
flipper-0.18.0 examples/percentage_of_actors_enabled_check.rb
flipper-0.17.2 examples/percentage_of_actors_enabled_check.rb
flipper-0.17.1 examples/percentage_of_actors_enabled_check.rb
flipper-0.16.2 examples/percentage_of_actors_enabled_check.rb
flipper-0.16.1 examples/percentage_of_actors_enabled_check.rb
flipper-0.16.0 examples/percentage_of_actors_enabled_check.rb