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

  • Home
  • SEARCH
  • 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 3323138
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:15:59+00:00 2026-05-17T23:15:59+00:00

Working through Michael Hartl’s RailsTutorial and came across the following error – even though

  • 0

Working through Michael Hartl’s RailsTutorial and came across the following error – even though I have followed everything to the ‘T’.

1) UsersController GET 'index' for signed-in users should have an element for each user
Failure/Error: response.should have_selector("li", :content => user.name)
undefined method `name' for #<Array:0x000001032c07c8>

Did anyone else get a similar error and know how to fix it?

I am in Chapter 10.

Btw, when I try the page it does what it is supposed to do. It’s just that the test fails in RSpec.

FYI, here is the related test code from the users_controller_spec.rb

require 'spec_helper'

describe UsersController do
    render_views

    describe "GET 'index'" do

        describe "for non-signed-in users" do
            it "should deny access" do 
                get :index
                response.should redirect_to(signin_path)
                flash[:notice].should =~ /sign in/i
            end
        end

        describe "for signed-in users" do 

            before(:each) do 
                @user = test_sign_in(Factory(:user))
                second = Factory(:user, :email => "another@example.com")
                third = Factory(:user, :email => "another@example.net")

                @users = [@user, second, third]
            end

            it "should be successful" do 
                get :index
                response.should be_success
            end

            it "should have the right title" do 
                get :index
                response.should have_selector("title", :content => "All users")
            end

            it "should have an element for each user" do
                get :index
                @users.each do |user|
                    response.should have_selector("li", :content => user.name)
                end
            end
        end
    end

My spec/spec_helper.rb file looks like the following:

require 'rubygems'
require 'spork'

Spork.prefork do
  # Loading more in this block will cause your tests to run faster. However, 
  # if you change any configuration or code from libraries loaded here, you'll
  # need to restart spork for it take effect.
  ENV["RAILS_ENV"] ||= 'test'
  unless defined?(Rails)
    require File.dirname(__FILE__) + "/../config/environment"
  end
  require 'rspec/rails'

  # Requires supporting files with custom matchers and macros, etc,
  # in ./support/ and its subdirectories.
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

  Rspec.configure do |config|
    # == Mock Framework
    #
    # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
    #
    # config.mock_with :mocha
    # config.mock_with :flexmock
    # config.mock_with :rr
    config.mock_with :rspec

    config.fixture_path = "#{::Rails.root}/spec/fixtures"

    # If you're not using ActiveRecord, or you'd prefer not to run each of your
    # examples within a transaction, comment the following line or assign false
    # instead of true.
    config.use_transactional_fixtures = true

    ### Part of a Spork hack. See http://bit.ly/arY19y
    # Emulate initializer set_clear_dependencies_hook in 
    # railties/lib/rails/application/bootstrap.rb
    ActiveSupport::Dependencies.clear

    def test_sign_in(user)
        controller.sign_in(user)
    end

    def integration_sign_in(user)
        visit signin_path
        fill_in :email,             :with => user.email
        fill_in :password,          :with => user.password 
        click_button
    end    
  end
end

Spork.each_run do
end
  • 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-05-17T23:15:59+00:00Added an answer on May 17, 2026 at 11:15 pm

    I solved this issue, and the answer can be found on the railstutorial official forums.

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

Sidebar

Related Questions

I'm working through Practical Web 2.0 Appications currently and have hit a bit of
I've been working through Practical Common Lisp and as an exercise decided to write
I'm working through previous years ACM Programming Competition problems trying to get better at
I'm currently working through an assignment that deals with Big-O and running times. I
I've been working through a recent Computer Science homework involving recursion and big-O notation.
I'm working through some homework and a question on a previous exam paper asks
I just got done working through the Django tutorials for the second time, and
I am working through some of the exercises in The C++ Programming Language by
I'm working through Cocoa Programming for Mac OS X (3rd ed) and in chapter
I'm working through the Data Binding chapter in Pro WPF in C# 2008. They

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.