spec/alternative_spec.rb in split-0.2.4 vs spec/alternative_spec.rb in split-0.3.0

- old
+ new

@@ -7,10 +7,16 @@ it "should have a name" do experiment = Split::Experiment.new('basket_text', 'Basket', "Cart") alternative = Split::Alternative.new('Basket', 'basket_text') alternative.name.should eql('Basket') end + + it "return only the name" do + experiment = Split::Experiment.new('basket_text', {'Basket' => 0.6}, {"Cart" => 0.4}) + alternative = Split::Alternative.new('Basket', 'basket_text') + alternative.name.should eql('Basket') + end it "should have a default participation count of 0" do alternative = Split::Alternative.new('Basket', 'basket_text') alternative.participant_count.should eql(0) end @@ -38,18 +44,22 @@ experiment.save alternative = Split::Alternative.find('Basket', 'basket_text') old_participant_count = alternative.participant_count alternative.increment_participation alternative.participant_count.should eql(old_participant_count+1) + + Split::Alternative.find('Basket', 'basket_text').participant_count.should eql(old_participant_count+1) end it "should increment completed count" do experiment = Split::Experiment.new('basket_text', 'Basket', "Cart") experiment.save alternative = Split::Alternative.find('Basket', 'basket_text') old_completed_count = alternative.participant_count alternative.increment_completion alternative.completed_count.should eql(old_completed_count+1) + + Split::Alternative.find('Basket', 'basket_text').completed_count.should eql(old_completed_count+1) end it "can be reset" do alternative = Split::Alternative.new('Basket', 'basket_text', {'participant_count' => 10, 'completed_count' =>4}) alternative.save \ No newline at end of file