Sha256: 1ebc005dbdf481017299a8dc612dfde4ea6a5ae88395adbbaf53f9019e67b10c

Contents?: true

Size: 922 Bytes

Versions: 16

Compression:

Stored size: 922 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)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
verdict-0.11.0 test/experiments_repository_test.rb
verdict-0.10.0 test/experiments_repository_test.rb
verdict-0.9.0 test/experiments_repository_test.rb
verdict-0.8.0 test/experiments_repository_test.rb
verdict-0.7.0 test/experiments_repository_test.rb
verdict-0.6.3 test/experiments_repository_test.rb
verdict-0.6.2 test/experiments_repository_test.rb
verdict-0.6.1 test/experiments_repository_test.rb
verdict-0.6.0 test/experiments_repository_test.rb
verdict-0.5.0 test/experiments_repository_test.rb
verdict-0.4.1 test/experiments_repository_test.rb
verdict-0.4.0 test/experiments_repository_test.rb
verdict-0.3.2 test/experiments_repository_test.rb
verdict-0.3.1 test/experiments_repository_test.rb
verdict-0.3.0 test/experiments_repository_test.rb
verdict-0.2.1 test/experiments_repository_test.rb