Sha256: 9e4d944d4746d938adb626a9ec4265d8161390f02359211097f4632dd747ffff

Contents?: true

Size: 797 Bytes

Versions: 1

Compression:

Stored size: 797 Bytes

Contents

require 'test_helper'

class RolloutPercentageSegmenterTest < MiniTest::Unit::TestCase

  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

1 entries across 1 versions & 1 rubygems

Version Path
verdict-0.2.0 test/rollout_segmenter_test.rb