test/experiment_test.rb in verdict-0.2.1 vs test/experiment_test.rb in verdict-0.3.0

- old
+ new

@@ -136,10 +136,42 @@ mock_store.expects(:retrieve_assignment).returns(unqualified_assignment).once mock_store.expects(:store_assignment).never e.assign(mock('subject')) end + def test_assign_manually_stores_assignment + mock_store = Verdict::Storage::MockStorage.new + e = Verdict::Experiment.new('test') do + storage mock_store, store_unqualified: true + groups { group :all, 100 } + end + + group = e.group('all') + mock_store.expects(:store_assignment).once + e.assign_manually(mock('subject'), group) + end + + def test_disqualify_manually + e = Verdict::Experiment.new('test', store_unqualified: true) do + groups { group :all, 100 } + end + + subject = stub(id: 'walrus') + original_assignment = e.assign(subject) + assert original_assignment.qualified? + new_assignment = e.disqualify_manually(subject) + assert !new_assignment.qualified? + end + + def test_disqualify_manually_fails_with_store_unqualified_disabled + e = Verdict::Experiment.new('test', store_unqualified: false) do + groups { group :all, 100 } + end + + assert_raises(Verdict::Error) { e.disqualify_manually('subject') } + end + def test_returning_qualified_assignment_with_store_unqualified mock_store, mock_qualifier = Verdict::Storage::MockStorage.new, mock('qualifier') e = Verdict::Experiment.new('test') do qualify { mock_qualifier.qualifies? } storage mock_store, store_unqualified: true @@ -163,21 +195,9 @@ 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 - - subject = stub(id: 'walrus') - original_assignment = e.assign(subject) - assert original_assignment.qualified? - new_assignment = e.disqualify(subject) - assert !new_assignment.qualified? end def test_assignment_event_logging e = Verdict::Experiment.new('test') do groups { group :all, 100 }