Question

I'm currently in RailsTutorial 3.2, Section 9.3.1 User Index.

Listing 9.27 directs an edit to the spec/requests/authentication_pages_spec.rb code as follows:

require 'spec_helper'

describe "Authentication" do
    .
    .
    .
    describe "with valid information" do
      let(:user) { FactoryGirl.create(:user) }
      before { valid_signin(user) }

      it { should have_selector('title', text: user.name) }

      it { should have_link('Users',    href: users_path) }
      it { should have_link('Profile',  href: user_path(user)) }
      it { should have_link('Settings', href: edit_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

After doing this, the corresponding section of tests fails. I have been following the tutorial very faithfully, so my code and setup are otherwise pretty much identical.

After testing a few things out, I've found that changing the

before { valid_signin(user) } 

line to read

before { sign_in user }

instead will make all the tests pass again. Is there something about the valid_signin(user) line that is off syntactically, or does this point to an error elsewhere in my code?

(The app works exactly like it's supposed to, it's just the test that says it doesn't.)

Was it helpful?

Solution

If you look at listing 8.34 you will see the def of valid_signin in the spec/support/utilities.rb file.

OTHER TIPS

I am finding that much of the "optional" work is necessary for the ensuing code to work. FYI

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top