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 8233889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:17:05+00:00 2026-06-07T18:17:05+00:00

I am taking the RoR Tutorial. In the last part of chapter 8.1.5, when

  • 0

I am taking the RoR Tutorial. In the last part of chapter 8.1.5, when all the rspec tests should turn green, I just can’t get mine to work. I run bundle exec rspec spec/requests/authentication_pages_spec.rb -e “signin with invalid information” and of the four tests, one fails, with this error:

1) Authentication signin with invalid information after visiting another page 
 Failure/Error: it { should_not have_selector('div.alert.alert-error') }
   expected css "div.alert.alert-error" not to return anything
 # ./spec/requests/authentication_pages_spec.rb:25:in `block (5 levels) in <top (required)>'

The text for app/controllers/sessions_controller.rb is below:

class SessionsController < ApplicationController

  def new
  end

  def create
    user = User.find_by_email(params[:session][:email])
    if user && user.authenticate(params[:session][:password])
      # Sign the user in and redirect to the user's show page.
    else
      flash.now[:error] = 'Invalid email/password combination'
      render 'new'
    end
  end

  def destroy
  end
end

The text for spec/requests/authetication_pages_spec.rb is below:

require 'spec_helper'

describe "Authentication" do

  subject { page }

  describe "signin page" do
    before { visit signin_path }

    it { should have_selector('h1',    text: 'Sign in') }
    it { should have_selector('title', text: 'Sign in') }
  end

  describe "signin" do
    before { visit signin_path }

    describe "with invalid information" do
      before { click_button "Sign in" }

      it { should have_selector('title', text: 'Sign in') }
      it { should have_selector('div.alert.alert-error', text: 'Invalid') }

      describe "after visiting another page" do
        before { click_link "Home" }
        it { should_not have_selector('div.alert.alert-error') }
      end
    end 

    describe "with valid information" do
      let(:user) { FactoryGirl.create(:user) }
      before do
        fill_in "Email",    with: user.email
        fill_in "Password", with: user.password
        click_button "Sign in"
      end 

      it { should have_selector('title', text: user.name) }
      it { should have_link('Profile', href: user_path(user)) }
      it { should have_link('Sign out', href: signout_path) }
      it { should_not have_link('Sign in', href: signin_path) }
    end
  end
end

If you have any thoughts or ideas, please let me know, I’m totally stumped!

  • 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-07T18:17:07+00:00Added an answer on June 7, 2026 at 6:17 pm

    I cloned your repo and found your problem.

    The links in your header file (app/views/layouts/_header.html.erb) don’t go anywhere:

    <li><%= link_to "Home",    '#' %></li>
    <li><%= link_to "Help",    '#' %></li>
    

    So, when your tests are run, the following tests pass because an error is displayed…

    describe "with invalid information" do
      before { click_button "Sign in" }
    
      it { should have_selector('title', text: 'Sign in') }
      it { should have_selector('div.alert.alert-error', text: 'Invalid') }
    

    …but when you then click on a link that doesn’t go anywhere…

      describe "after visiting another page" do
        before { click_link "Home" } # goes nowhere
        it { should_not have_selector('div.alert.alert-error') }
      end
    end
    

    …that error is still on the page, so the test correctly fails.

    Once you change your "Home" link destination from '#' to root_path, your test should pass.

    Looking at the text, if you’re on Chapter 8, it seems you missed a step a few chapters back on Listing 5.2.4 in Chapter 5.3.3, so you should be in a better state once you’ve gone back and fixed it.

    I’d also recommend installing the launchy gem so that you can call helpful Capybara methods like save_and_open_page in your tests and it will open a browser for you with the state of your page at the time you called the method; helps a lot with debugging.

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

Sidebar

Related Questions

Taking a rails tutorial, and I've run into the following problem that I'm having
Taking out all of the obvious caveats related to benchmarks and benchmark comparison, is
Taking in consideration a table tbl_users , I want to get a list of
I am a newbie for RoR, and I am taking a look into BDD
Taking the simple example from Union, I am wondering where I can put configuration
Taking this question about beautiful XSL but getting more specific, how should I refactor
Taking into consideration performance and readability, how should dates be encoded in JSON for
Taking this basic example of jQuery Validate (see link below), how can you instruct
Taking into account a 5x5 grid, it requires all possible combinations of knights moves
Taking the following string example, what is the pattern I should use to extract

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.