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