Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8827423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:22:04+00:00 2026-06-14T07:22:04+00:00

I used the following to write tests for chapter 10 exercises 1 and 2

  • 0

I used the following to write tests for chapter 10 exercises 1 and 2 in the static_pages_spec.rb and when I got those other tests to pass, I got the following error:

  1) Static pages Home page for signed-in users should render the user's feed
     Failure/Error: page.should have_selector("li##{item.id}", text: item.content)
       expected css "li#1138" with text "Lorem ipsum" to return something
     # ./spec/requests/static_pages_spec.rb:25:in `block (5 levels) in <top (required)>'
     # ./spec/requests/static_pages_spec.rb:24:in `block (4 levels) in <top (required)>'

Apparently the line item.id test broke somehow as soon as FactoryGirl creates more than 30 microposts.

Here is the static_pages_spec.rb:

  describe "Home page" do
    before { visit root_path }

    it { should have_selector('h1', text: 'Sample App') }
    it { should have_selector('title', text: full_title('')) }

    describe "for signed-in users" do
      let(:user) { FactoryGirl.create(:user) }
      before do
        31.times { FactoryGirl.create(:micropost, user: user) }
        sign_in user
        visit root_path
      end

      after { user.microposts.delete_all }

      it "should render the user's feed" do
        user.feed.each do |item|
          page.should have_selector("li##{item.id}", text: item.content)
        end
      end

      it "should have micropost count and pluralize" do
        page.should have_content('31 microposts')
      end

      it "should paginate after 31" do
        page.should have_selector('div.pagination')
      end
    end

  end

Here is my _feed_item.html.erb partial:

<li id="<%= feed_item.id %>">
  <%= link_to gravatar_for(feed_item.user), feed_item.user %>
  <span class="user">
    <%= link_to feed_item.user.name, feed_item.user %>
  </span>
  <span class="content"><%= feed_item.content %></span>
  <span class="timestamp">
    Posted <%= time_ago_in_words(feed_item.created_at) %> ago.
  </span>
  <% if current_user?(feed_item.user) %>
    <%= link_to "delete", feed_item, method: :delete,
                                     data: { confirm: "You sure?" },
                                     title: feed_item.content %>
  <% end %>
</li>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:22:06+00:00Added an answer on June 14, 2026 at 7:22 am

    I fixed this by limiting the feed line item test to only check the first 28 posts.

      it "should render the user's feed" do
        user.feed[1..28].each do |item|
          page.should have_selector("li##{item.id}", text: item.content)
        end
      end
    

    However, I don’t know that this is the best way to fix it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find a way to write some unit-tests that can be used
I have got to know that src/test/java is used for writing unit tests. I
i am trying to write excel file through erlang. I used the following code
I used following code, but it displays only 2 digit of ISO country name.
I used following JS code to create equal height columns: var colHeight = Math.max($('.3columngallery
I have used following code to convert string to json and parse it. String
i have used following code to repeat a process creation/close iteratively dim vProcessInfo as
I have used following code to create a simple PDF file. It executes fine
I am trying to used following code but I am not getting good performance
I've used following code snippet for my activity in order to deal with orientation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.