Sha256: 8879744db83266c0d2eec3cd3ed3bce3b901bbc21ebcd246793cf819ffb1bbdb

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'test_helper'

class GroupTest < MiniTest::Unit::TestCase

  def setup
    @experiment = Verdict::Experiment.new('a')
  end

  def test_basic_properties
    group = Verdict::Group.new(@experiment, :test)

    assert_equal @experiment, group.experiment
    assert_kind_of Verdict::Group, group
    assert_equal 'test', group.handle
    assert_equal 'test', group.to_s
    assert_equal :test, group.to_sym
  end

  def test_triple_equals
    group = Verdict::Group.new(@experiment, 'control')
    assert group === Verdict::Group.new(@experiment, :control)
    assert group === 'control'
    assert group === :control
    assert !(group === nil)

    assert !(group === Verdict::Group.new(@experiment, :test))
    assert !(group === Verdict::Group.new(Verdict::Experiment.new('b'), :test))
    assert !(group === 'test')
    assert !(group === nil)
  end

  def test_json
    group = Verdict::Group.new(@experiment, 'control')
    group.name 'testing'
    group.description 'description'

    json = JSON.parse(group.to_json)
    assert_equal 'control', json['handle']
    assert_equal 'testing', json['metadata']['name']
    assert_equal 'description', json['metadata']['description']
  end  
end

Version data entries

3 entries across 3 versions & 1 rubygems

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