spec/article_spec.rb in mongoid_rating-0.1.0 vs spec/article_spec.rb in mongoid_rating-0.1.1

- old
+ new

@@ -37,11 +37,11 @@ @article.overall! 1, @bob end describe "#overall" do it "should track #overall properly" do - @article.overall! 1, @sally + @article.overall!(1, @sally) @article.overall_count.should eql 2 @article.overall.should eql 1.0 end it "should not mark fields as dirty" do @@ -49,21 +49,21 @@ @article.overall_sum_changed?.should be_false @article.overall_average_changed?.should be_false end it "should limit #overalls by user properly" do - @article.overall! 5, @bob + @article.overall!(5, @bob) @article.overall.should eql 5.0 end context "when overall_value in rating range" do - it { expect { @article.overall 1, @sally }.not_to raise_error } + it { expect { @article.overall(1, @sally) }.not_to raise_error } end context "when overall_value not in rating range" do - it { expect { @article.overall 17, @sally }.to raise_error() } - it { expect { @article.overall -17, @sally }.to raise_error() } + it { expect { @article.overall(17, @sally) }.to raise_error() } + it { expect { @article.overall(-17, @sally) }.to raise_error() } end describe "when using positive values" do let(:num) { rand(1..5) } let(:exp) { ((num + 1) / 2.0) - 1 } @@ -131,11 +131,11 @@ @article.overall 4, @sally @article.overall.should eq 2.5 end it "should calculate the average overall if the result is zero" do - @article.overall -1, @sally + @article.overall(-1, @sally) @article.overall.should eq 0.0 end end end @@ -163,44 +163,44 @@ end end context "when saving the collection" do before (:each) do - @article.overall 3, @bob - @article.overall -5, @sally + @article.overall(3, @bob) + @article.overall(-5, @sally) @article.save @f_article = Article.where(:name => "Article").first end it "disallows incorrect rates" do - expect { @article.overall 8, @bob }.to raise_error - expect { @article.overall -10, @sally }.to raise_error + expect { @article.overall(8, @bob) }.to raise_error + expect { @article.overall(-10, @sally) }.to raise_error end describe "#overall_by?" do describe "for Bob" do specify { @f_article.overall_by?(@bob).should be_true } - specify { @f_article.overall_by(@bob).should eq 3 } + specify { @f_article.overall_by(@bob).should eq(3) } end describe "for Sally" do specify { @f_article.overall_by?(@sally).should be_true } - specify { @f_article.overall_by(@sally).should eq -5 } + specify { @f_article.overall_by(@sally).should eq(-5) } end describe "for Alice" do specify { @f_article.overall_by?(@alice).should be_false} specify { @f_article.overall_by(@alice).should be_nil } end end describe "#overall" do - specify { @f_article.overall.should eql -1.0 } + specify { @f_article.overall.should eq(-1.0) } end describe "#overall_count" do - specify { @f_article.overall_count.should eql 2 } + specify { @f_article.overall_count.should eq(2) } end end end describe "#scopes" do @@ -266,16 +266,14 @@ end describe '#by_overall' do it "should return proper count of articles" do Article.by_overall.limit(10).count(true).should eq 5 - Article.by_overall.to_a.should eq [@article3, @article1, @article2, @article4, @article5] end it 'returns articles in proper order' do - + Article.by_overall.to_a.should eq [@article3, @article1, @article2, @article4, @article5] end end end - end end