Permalink
Browse files

better total_word_count specs

  • Loading branch information...
1 parent 4a8dce5 commit e288a4dad2a932673690b25610c57668af4148f3 @steveklabnik steveklabnik committed Jan 9, 2012
Showing with 4 additions and 8 deletions.
  1. +2 −4 spec/models/articles_spec.rb
  2. +2 −4 spec/models/comment_spec.rb
@@ -50,11 +50,9 @@
context ".total_word_count" do
it "gives the word count for all articles" do
- 2.times { Fabricate(:article) }
+ 2.times { Fabricate(:article, :body => "I think that...") }
- count = Article.all.inject(0) {|total, a| total += a.word_count }
-
- Article.total_word_count.should eq(count)
+ Article.total_word_count.should eq(6)
end
end
@@ -37,11 +37,9 @@
context ".total_word_count" do
it "gives the word count for all comments" do
- 2.times { Fabricate(:comment) }
+ 2.times { Fabricate(:comment, :body => "I think that...") }
- count = Comment.all.inject(0) {|total, a| total += a.word_count }
-
- Comment.total_word_count.should eq(count)
+ Comment.total_word_count.should eq(10) # includes @comment from above
end
end

0 comments on commit e288a4d

Please sign in to comment.