ruby on rails - error during signin in authentication_pages_spec -


fllowing michael hartl tutorial i'm getting following error "undefined method pages" in authentication_pages_spec during sign in chapter 8.

first image

enter image description here

authentication_pages_spec.rb

require 'rails_helper'  rspec.describe "authenticationpages", type: :request    subject { pages }      describe "signin pages"         before { visit signin_path }          { should have_selector('h1', text: 'sign in')}         { should have_selector('title', text: 'sign in')}     end      describe "signin"         before { visit signin_path }          describe "with invalid information"             before { click_button "sign in" }              { should have_selector('title', text: 'sign in')}             { should have_selector('div.alert.alert-error', text: 'invalid')}        describe "after visiting page"           before { click_link "home" }           { should_not have_selector('div.alert.alert-error') }       end         end          describe "with valid information"             let(:user) {factorygirl.create(:user)}             before                 fill_in "email", with: user.email                 fill_in "password", with: user.password                 click_button "sign in"             end              { should have_selector('title', text: user.name) }             { should have_link('profile', href: user_path(user))}             { should have_link('sign out', href: signout_path)}             { should_not have_link('sign in', href: signin_path)}         end     end end 

new.html.erb

<% provide(:title, "sign in") %> <h1>sign in</h1>  <div class = "row">     <div class = "col-md-6 col-md-offset-3">         <%= form_for(:session, url: sessions_path) |f| %>              <%= f.label :email %>             <%= f.text_field :email %>              <%= f.label :password %>             <%= f.password_field :password %>              <%= f.submit "sign in", class: "btn btn-large btn-primary" %>              <p> new user? <%= link_to "sign now", signup_path %></p>          <% end %>     </div> </div> 

routes.rb

rails.application.routes.draw   resources :users   resources :sessions, only: [:new, :create, :destroy]    root to: 'static_pages#home'   '/signup', to: 'users#new'   '/signin', to: 'sessions#new'   '/signout', to: 'sessions#destroy', via: :delete   '/help', to: 'static_pages#help'   '/about', to: 'static_pages#about'   resources :users end 

session_controller.rb

class sessionscontroller < applicationcontroller      def new     end      def create         user = user.find_by_email(params[:session][:email])         if user && user.authennticate(params[:session][:password])             #sign user in redirect user's show page.         else             #create error message , re-render signin form             flash.now[:error] = 'invalid email/password combination'             render 'new'         end     end      def destroy     end  end 

it looks you're using old version of tutorial (the current version uses minitest instead of rspec), should consider switching over.

as errors, seem have 2 spelling mistakes:

  • change pages page (singular), object capybara makes assertions against
  • change user.authennticate user.authenticate

for future questions, please copy , paste error output in text format , refrain posting screenshots.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -