Sha256: e0bddf8a858fea92bcc1221cccc8d125b9d893339d81e946c47b3ae9a745a92f

Contents?: true

Size: 1.14 KB

Versions: 17

Compression:

Stored size: 1.14 KB

Contents

require 'test_helper'
require 'json'

class ConversionTest < Minitest::Test

  def setup
    @experiment = Verdict::Experiment.new('conversion test') do
      groups { group :all, 100 }
    end
  end

  def test_subject_identifier_lookup
    klass = Struct.new(:id)
    subject = klass.new(123)

    conversion = Verdict::Conversion.new(@experiment, subject, :test_goal)
    assert_equal '123', conversion.subject_identifier
  end

  def test_assignment_lookup
    @experiment.storage.expects(:retrieve_assignment).with(@experiment, 'test_subject_id')
    conversion = Verdict::Conversion.new(@experiment, 'test_subject_id', :test_goal)
    conversion.assignment
  end

  def test_json_representation
    conversion = Verdict::Conversion.new(@experiment, 'test_subject_id', :test_goal, Time.new(2013, 1, 1, 4, 5, 6, '+00:00'))
    json = JSON.parse(conversion.to_json)

    assert_equal 'conversion test',      json['experiment']
    assert_equal 'test_subject_id',      json['subject']
    assert_equal 'test_goal',            json['goal']
    assert_equal 'test_goal',            json['goal']
    assert_equal '2013-01-01T04:05:06Z', json['created_at']
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
verdict-0.16.1 test/conversion_test.rb
verdict-0.16.0 test/conversion_test.rb
verdict-0.15.2 test/conversion_test.rb
verdict-0.15.1 test/conversion_test.rb
verdict-0.15.0 test/conversion_test.rb
verdict-0.14.0 test/conversion_test.rb
verdict-0.13.0 test/conversion_test.rb
verdict-0.12.0 test/conversion_test.rb
verdict-0.11.0 test/conversion_test.rb
verdict-0.10.0 test/conversion_test.rb
verdict-0.9.0 test/conversion_test.rb
verdict-0.8.0 test/conversion_test.rb
verdict-0.7.0 test/conversion_test.rb
verdict-0.6.3 test/conversion_test.rb
verdict-0.6.2 test/conversion_test.rb
verdict-0.6.1 test/conversion_test.rb
verdict-0.6.0 test/conversion_test.rb