Sha256: 83556616ac6b0e7ee8037087c97999a1252634eb5f362a199227dc318e0b91fe

Contents?: true

Size: 904 Bytes

Versions: 31

Compression:

Stored size: 904 Bytes

Contents

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

require 'flipper'
require 'flipper/adapters/memory'

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

31 entries across 31 versions & 1 rubygems

Version Path
flipper-0.15.0 examples/percentage_of_actors_enabled_check.rb
flipper-0.14.0 examples/percentage_of_actors_enabled_check.rb
flipper-0.13.0 examples/percentage_of_actors_enabled_check.rb
flipper-0.13.0.beta1 examples/percentage_of_actors_enabled_check.rb
flipper-0.12.2 examples/percentage_of_actors_enabled_check.rb
flipper-0.12.1 examples/percentage_of_actors_enabled_check.rb
flipper-0.12.0 examples/percentage_of_actors_enabled_check.rb
flipper-0.11.0 examples/percentage_of_actors_enabled_check.rb
flipper-0.11.0.rc1 examples/percentage_of_actors_enabled_check.rb
flipper-0.11.0.beta9 examples/percentage_of_actors_enabled_check.rb
flipper-0.11.0.beta8 examples/percentage_of_actors_enabled_check.rb
flipper-0.11.0.beta7 examples/percentage_of_actors_enabled_check.rb
flipper-0.11.0.beta6 examples/percentage_of_actors_enabled_check.rb
flipper-0.11.0.beta5 examples/percentage_of_actors_enabled_check.rb
flipper-0.11.0.beta4 examples/percentage_of_actors_enabled_check.rb
flipper-0.11.0.beta3 examples/percentage_of_actors_enabled_check.rb
flipper-0.11.0.beta1 examples/percentage_of_actors_enabled_check.rb
flipper-0.10.2 examples/percentage_of_actors_enabled_check.rb
flipper-0.10.1 examples/percentage_of_actors_enabled_check.rb
flipper-0.10.0 examples/percentage_of_actors_enabled_check.rb