Sha256: 90fc650147fa4d9077ae3f07e3dc8e0cdb94697d4579e1601467a6d7bf980335

Contents?: true

Size: 932 Bytes

Versions: 3

Compression:

Stored size: 932 Bytes

Contents

require 'test_helper'

class ExperimentTest < MiniTest::Unit::TestCase

  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)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
verdict-0.2.0 test/experiments_repository_test.rb
verdict-0.1.1 test/experiments_repository_test.rb
verdict-0.1.0 test/experiments_repository_test.rb