I am working on Michael Hartl's Rails Tutorial, Chapter 8.2.4: http://www.railstutorial.org/book/sign_in_out#sec-changing_the_layout_links
So far, everything seems to have worked great.
However, when I run the tests at the end of the section, the tutorial says they should pass, but I get the following errors:
FFFF.....*....................................
Pending:
SessionsHelper add some examples to (or delete) /Users/Thibaud/work/rails_projects/sample_app/spec/helpers/sessions_helper_spec.rb
# No reason given
# ./spec/helpers/sessions_helper_spec.rb:14
Failures:
1) Authentication signin with valid information
Failure/Error: click_button "Sign in"
ActionView::MissingTemplate:
Missing template sessions/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/Users/Thibaud/work/rails_projects/sample_app/app/views"
# ./spec/requests/authentication_pages_spec.rb:34:in `block (4 levels) in <top (required)>'
2) Authentication signin with valid information
Failure/Error: click_button "Sign in"
ActionView::MissingTemplate:
Missing template sessions/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/Users/Thibaud/work/rails_projects/sample_app/app/views"
# ./spec/requests/authentication_pages_spec.rb:34:in `block (4 levels) in <top (required)>'
3) Authentication signin with valid information
Failure/Error: click_button "Sign in"
ActionView::MissingTemplate:
Missing template sessions/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/Users/Thibaud/work/rails_projects/sample_app/app/views"
# ./spec/requests/authentication_pages_spec.rb:34:in `block (4 levels) in <top (required)>'
4) Authentication signin with valid information
Failure/Error: click_button "Sign in"
ActionView::MissingTemplate:
Missing template sessions/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/Users/Thibaud/work/rails_projects/sample_app/app/views"
# ./spec/requests/authentication_pages_spec.rb:34:in `block (4 levels) in <top (required)>'
Finished in 2.04 seconds
46 examples, 4 failures, 1 pending
Failed examples:
rspec ./spec/requests/authentication_pages_spec.rb:40 # Authentication signin with valid information
rspec ./spec/requests/authentication_pages_spec.rb:38 # Authentication signin with valid information
rspec ./spec/requests/authentication_pages_spec.rb:39 # Authentication signin with valid information
rspec ./spec/requests/authentication_pages_spec.rb:37 # Authentication signin with valid information
Randomized with seed 59639
Here is what's in my authentication_pages_spec.rb file:
require 'spec_helper'
describe "Authentication" do
subject { page }
describe "signin page" do
before { visit signin_path }
it { should have_content('Sign in') }
it { should have_title('Sign in') }
end
describe "signin" do
before { visit signin_path }
describe "with invalid information" do
before { click_button "Sign in" }
it { should have_title('Sign in') }
it { should have_selector('div.alert.alert-error') }
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.upcase
fill_in "Password", with: user.password
click_button "Sign in"
end
it { should have_title(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
[EDIT:] Here is the SessionController file:
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by(email: params[:session][:email].downcase)
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
sign_out
redirect_to root_url
end
end
How can I make the tests to pass?
Thanks.