test/experiment_test.rb in verdict-0.1.1 vs test/experiment_test.rb in verdict-0.2.0
- old
+ new
@@ -151,10 +151,24 @@
mock_store.expects(:retrieve_assignment).returns(qualified_assignment).once
mock_store.expects(:store_assignment).never
e.assign(mock('subject'))
end
+ def test_dont_store_when_segmenter_returns_nil
+ mock_store = Verdict::Storage::MockStorage.new
+ e = Verdict::Experiment.new('test') do
+ groups { group :all, 100 }
+ storage mock_store, store_unqualified: true
+ end
+
+ e.segmenter.stubs(:assign).returns(nil)
+ mock_store.expects(:store_assignment).never
+
+ assignment = e.assign(mock('subject'))
+ assert !assignment.qualified?
+ end
+
def test_disqualify
e = Verdict::Experiment.new('test') do
groups { group :all, 100 }
end
@@ -175,16 +189,20 @@
e.assign(stub(id: 'subject_identifier'))
end
def test_conversion_event_logging
- e = Verdict::Experiment.new('test')
+ e = Verdict::Experiment.new('test')do
+ groups { group :all, 100 }
+ end
+ subject = stub(id: 'test_subject')
e.stubs(:event_logger).returns(logger = mock('logger'))
logger.expects(:log_conversion).with(kind_of(Verdict::Conversion))
+ e.segmenter.expects(:conversion_feedback).with('test_subject', subject, kind_of(Verdict::Conversion))
- conversion = e.convert(subject = stub(id: 'test_subject'), :my_goal)
+ conversion = e.convert(subject, :my_goal)
assert_equal 'test_subject', conversion.subject_identifier
assert_equal :my_goal, conversion.goal
end
def test_json
@@ -227,10 +245,10 @@
e = Verdict::Experiment.new(:json) do
groups { group :all, 100 }
storage storage_mock
end
- storage_mock.expects(:retrieve_assignment).returns(e.subject_assignment(mock('subject_identifier'), e.group(:all)))
+ storage_mock.expects(:retrieve_assignment).returns(e.subject_assignment(mock('subject_identifier'), e.group(:all), nil))
storage_mock.expects(:store_assignment).raises(Verdict::StorageError, 'storage write issues')
rescued_assignment = e.assign(stub(id: 456))
assert !rescued_assignment.qualified?
end