问题
I'm getting the following rSpec failed tests error.
What did I do wrong?
Many thanks..
1) Authentication signin page Failure/Error: before { visit signin_path } NameError: undefined local variable or method signin_path' for # # ./spec/requests/authentication_pages_spec.rb:8:inblock (3 levels) in '
2) Authentication signin page Failure/Error: before { visit signin_path } NameError: undefined local variable or method signin_path' for # # ./spec/requests/authentication_pages_spec.rb:8:inblock (3 levels) in '
session_controller.rb:
class SessionsController < ApplicationController
def
new
end
def
create
end
def
destroy
end
end
routes.rb:
SampleApp::Application.routes.draw do
resources :users
resources :sessions, only: [:new, :create, :destroy]
root to: 'static_pages#home'
match '/signup', to: 'users#new'
match '/signin', to: 'sessions#new'
match '/signout', to: 'sessions#destroy', via: :delete
authentication_pages_spec.rb:
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
end
回答1:
I had this same issue and restarting guard/spork after I created my routes solved the problem
回答2:
Did you add the signin route to routes.rb and not restart spork (assuming you're using it) before running your tests?
回答3:
Can you run rake routes from your console and show the output
来源:https://stackoverflow.com/questions/10443105/rails-tutorial-chapter-8-undefined-local-variable-or-method-signin-path