Sha256: 3f2ff31d5e5330149f7414fd2449a865f806792bcd97aa5b1244ff38063bf52a

Contents?: true

Size: 978 Bytes

Versions: 8

Compression:

Stored size: 978 Bytes

Contents

require 'test_helper'

class ExperimentTest < Minitest::Test

  def setup
    Verdict.repository.clear
  end

  def test_should_keep_list_of_all_experiments
    size_at_start = Verdict.repository.size
    e = Verdict::Experiment.define('test')

    assert_equal size_at_start + 1, Verdict.repository.size
    assert_equal e, Verdict['test']
  end

  def test_should_not_allow_experiments_with_the_same_name
    Verdict::Experiment.define('test_duplicate')
    assert_raises(Verdict::ExperimentHandleNotUnique) do
      Verdict::Experiment.define('test_duplicate')
    end
  end

  def test_json_export
    e1 = Verdict::Experiment.define('test_1') { groups { group :all, 100 } }
    e2 = Verdict::Experiment.define('test_2') { groups { group :all, 100 } }

    json = JSON.parse(Verdict.repository.to_json)
    assert_equal ['test_1', 'test_2'], json.keys
    assert_equal json['test_1'], JSON.parse(e1.to_json)
    assert_equal json['test_2'], JSON.parse(e2.to_json)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
verdict-0.16.1 test/experiments_repository_test.rb
verdict-0.16.0 test/experiments_repository_test.rb
verdict-0.15.2 test/experiments_repository_test.rb
verdict-0.15.1 test/experiments_repository_test.rb
verdict-0.15.0 test/experiments_repository_test.rb
verdict-0.14.0 test/experiments_repository_test.rb
verdict-0.13.0 test/experiments_repository_test.rb
verdict-0.12.0 test/experiments_repository_test.rb