失败/错误:访问

时间:2012-07-26 19:24:08

标签: ruby-on-rails testing rspec lambda

有谁能告诉我这个错误是什么意思:

  
    

失败/错误:访问new_user_registration_path          NameError:            未定义的局部变量或方法`new_user_registration_path'for#          #。/ spec / control / user_controller_spec.rb:10          #。/ spec / control / user_controller_spec.rb:9

  

错误仅出现在我的spec规范的函数“lambda”中:

require 'spec_helper'

describe "User" do

describe "signup" do

describe "failure" do
  it "should not make a new user" do
    lambda do
      visit new_user_registration_path
      fill_in "email",        :with => ""
      fill_in "password",     :with => ""
      fill_in "password_confirmation", :with => ""
      click_button
      response.should render_template('users/new')
      response.should have_selector('div#error_explanation')
    end.should_not change(User, :count)
  end
end
....

我的路由rake说new_user_registration存在外观

   cancel_user_registration GET    /users/cancel(.:format)                  devise/registrations#cancel
   user_registration POST   /users(.:format)                        devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)                devise/registrations#new
   edit_user_registration GET    /users/edit(.:format)                   devise/registrations#edit
...

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

只需替换:

new_user_registration

使用:

new_user_registration_path