Sha256: 831ac439d7061325d5aa707b4f291364eba3757fbb2c82b4843f2860cff55931

Contents?: true

Size: 656 Bytes

Versions: 3

Compression:

Stored size: 656 Bytes

Contents

require 'test_helper'
require 'resolvers/percentage'

module CanaryLabs
  module Resolvers
    class PercentageTest < ActiveSupport::TestCase
      def test_participating
        total_participating = 0
        resolver = Percentage.new 0.1, :test

        (0..9999).to_a.each_index do |idx|
          total_participating += 1 if resolver.participating? idx
        end

        # ensure we are within 10% of the expected percentage (i.e. with an eligibility percentage of 10%
        # between 9% and 11% of tested range were eligible)
        error_rate = (total_participating / 1000.0) - 1
        assert error_rate.abs < 0.1
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
canary_labs-0.4.0 test/resolvers/percentage_test.rb
canary_labs-0.3.0 test/resolvers/percentage_test.rb
canary_labs-0.2.0 test/resolvers/percentage_test.rb