1

我收到以下 rSpec 测试失败错误。

我做错了什么?

非常感谢..

1)身份验证登录页面失败/错误:在{访问signin_path}之前NameError:未定义的局部变量或方法signin_path' for ## ./spec/requests/authentication_pages_spec.rb:8:inblock (3 levels) in '

2)身份验证登录页面失败/错误:在{访问signin_path}之前NameError:未定义的局部变量或方法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

路线.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 

结尾

4

3 回答 3

6

我有同样的问题,在我创建路线后重新启动警卫/spork解决了这个问题

于 2012-07-10T17:47:23.173 回答
1

在运行测试之前,您是否添加了signin路由routes.rb而不是重新启动 spork(假设您正在使用它)?

于 2012-06-08T22:06:21.210 回答
0

您可以rake routes从控制台运行并显示输出吗

于 2012-05-12T17:22:31.653 回答