Sha256: 4ab784a1db410426e48be0a5448ffceb13b0ba49115fbacc125541403ee5883c

Contents?: true

Size: 783 Bytes

Versions: 24

Compression:

Stored size: 783 Bytes

Contents

require 'test_helper'

class RolloutPercentageSegmenterTest < Minitest::Test

  def setup
    @experiment = Verdict::Experiment.new('test') do
      rollout_percentage 50
    end
  end

  def test_assignment
    included_subject = stub(id: 1)
    excluded_subject = stub(id: 2)

    included_assignment = @experiment.assign(included_subject)
    assert included_assignment.qualified?
    assert included_assignment.permanent?

    excluded_assignment = @experiment.assign(excluded_subject)
    assert !excluded_assignment.qualified?
    assert excluded_assignment.temporary?
  end

  def test_group_json_representation
    json = JSON.parse(@experiment.segmenter.groups['enabled'].to_json)
    assert_equal 'enabled', json['handle']
    assert_equal 50, json['percentage']
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
verdict-0.3.2 test/segmenters/rollout_segmenter_test.rb
verdict-0.3.1 test/segmenters/rollout_segmenter_test.rb
verdict-0.3.0 test/segmenters/rollout_segmenter_test.rb
verdict-0.2.1 test/segmenters/rollout_segmenter_test.rb