Ruby on rails 编写自定义设计操作的规范

Ruby on rails 编写自定义设计操作的规范,ruby-on-rails,rspec,devise,Ruby On Rails,Rspec,Devise,我有一个应用程序,它有一个自定义版本的Desive::RegistrationController。当我尝试运行它时,出现以下错误: Failure/Error: post :create AbstractController::ActionNotFound: Could not find devise mapping for path "/users". Maybe you forgot to wrap your route inside the scope block? Fo

我有一个应用程序,它有一个自定义版本的Desive::RegistrationController。当我尝试运行它时,出现以下错误:

 Failure/Error: post :create
 AbstractController::ActionNotFound:
   Could not find devise mapping for path "/users".
   Maybe you forgot to wrap your route inside the scope block? For example:

       devise_scope :user do
         match "/some/route" => "some_devise_controller"
       end
我不明白为什么会出现这个错误,因为从用户的角度来看,一切都正常。下面是我在routes/config.rb中看到的内容:


有什么想法吗?在为Desive控制器编写规范时,我是否需要做一些特殊的事情?

在测试Desive控制器时,需要指定范围。简单到:

before { @request.env['devise.mapping'] = Devise.mappings[:user] }
假设用户是您尝试验证的模型

是否添加了RSpec.configure do | config | config.include designe::TestHelpers,:type=>:controller end?
before { @request.env['devise.mapping'] = Devise.mappings[:user] }