カスタム機能を実装するためにDevise::RegistrationsController
を上書きしたいと思います。登録コントローラーを無効にするときのコントローラーテストの書き方は?
# /app/controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
def new
super
end
end
と、このような私のルートを設定します:これを行うには、私はそうのような新しいRegistrationsController
作成した
devise_for :users, :controllers => { :registrations => "registrations" }
をし、このようにそれをテストしてみました:
describe RegistrationsController do
describe "GET 'new'" do
it "should be successful" do
get :new
response.should be_success
end
end
end
しかしそれは私にエラーを与える:
1) RegistrationsController GET 'new' should be successful
Failure/Error: get :new
AbstractController::ActionNotFound:
Could not find devise mapping for path "https://stackoverflow.com/users/sign_up".
Maybe you forgot to wrap your route inside the scope block? For example:
devise_scope :user do
match "/some/route" => "some_devise_controller"
end
# ./spec/controllers/registrations_controller_spec.rb:13:in `block (3 levels) in <top (required)>'
どうしたの?
これをどのファイルに追加しますか - 私はそれを把握できません、ありがとう。 – eWizardII
最初の 'describe'ブロックのちょうど内側のコントローラテストに入れます。 - スペックで –
私はコントローラを無駄に次のように私はそれを置く場所registration_controllerがされてい: は「spec_helper」を必要と は前 を行う「『編集』をGET」について説明しますRegistrationsControllerについて説明します。それぞれが[ request.envを行います'devise.mapping'] = Devise.mappings [:ユーザー] エンド それは "成功する必要がある" やる GET '編集' response.shouldのbe_success 終了 エンド エンド – eWizardII