Skip to content

Commit

Permalink
small refactoring of count specs.
Browse files Browse the repository at this point in the history
Now we're not relying on the model methods.
  • Loading branch information
steveklabnik committed Jan 9, 2012
1 parent b2c4f96 commit fccf20d
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions spec/requests/dashboard_spec.rb
Expand Up @@ -9,8 +9,8 @@

context "recent articles" do
before :each do
6.times do
Fabricate(:article)
6.times do |i|
Fabricate(:article, :title => "Title #{i}")
end

visit "/"
Expand All @@ -22,16 +22,15 @@
end

it "lists them in reverse chronological order" do
titles = Article.for_dashboard.map(&:title)
titles_on_page = page.all('li.article').map(&:text)
titles_on_page.should eq(titles)
titles = page.all('li.article').map(&:text)
titles.should eq(["Title 5", "Title 4", "Title 3", "Title 2", "Title 1"])
end
end

context "recent comments" do
before :each do
6.times do
Fabricate(:comment)
6.times do |i|
Fabricate(:comment, :body => "Body #{i}")
end

visit "/"
Expand All @@ -43,9 +42,8 @@
end

it "lists them in reverse order" do
bodies = Comment.for_dashboard.map(&:body)
bodies_on_page = page.all('li.comment').map(&:text)
bodies_on_page.should eq(bodies)
bodies = page.all('li.comment').map(&:text)
bodies.should eq(["Body 5", "Body 4", "Body 3", "Body 2", "Body 1"])
end
end

Expand All @@ -68,21 +66,19 @@


it "displays the total words of all articles" do
Fabricate(:article)
total_words = Article.total_word_count
Fabricate(:article, :body => "Four score and seven years...")

visit "/"

page.should have_content("Total words: #{total_words}")
page.should have_content("Total words: 5")
end

it "displays the total words of all comments" do
Fabricate(:comment)
total_words = Comment.total_word_count
Fabricate(:comment, :body => "I think that...")

visit "/"

page.should have_content("Total words: #{total_words}")
page.should have_content("Total words: 3")
end
it "displays the time since the most recent article"
it "displays the time since the most recent comment"
Expand Down

0 comments on commit fccf20d

Please sign in to comment.