Deviseを継承したControllerのSpec

Deviseのカスタマイズがしたくて継承してController作ってSpecからリクエストしたら怒られたのです

Failure/Error: get 'new'
AbstractController::ActionNotFound:
  Could not find devise mapping for path "/users/sign_in".
  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にはちゃんと書いてあんだろうが!と思ったんですがdeviseのREADMEにちゃんと書いてあります。

If you are testing Devise internal controllers or a controller that inherits from Devise's, you need to tell Devise which mapping should be used before a request. This is necessary because Devise gets this information from router, but since functional tests do not pass through the router, it needs to be told explicitly. For example, if you are testing the user scope, simply do:

@request.env["devise.mapping"] = Devise.mappings[:user]
get :new

英語読む努力をする前にGoogle翻訳をかけたところ読めてしまったので怠けます。わぁい
おお、怠けてしまうとは情けない

あなたがテストしている場合、内部のコントローラやのを考案から継承コントローラを考案するには、要求の前に使用されるべきであるかを考案するマッピングを指示する必要があります。考案するルータからこの情報を取得しますが、機能テストがルータを通過しないので、それが明示的に指示する必要がありますので、これが必要です。あなたがユーザースコープをテストしている場合は、単に操作を行います。

ということでリクエストする前に@request.env["devise.mapping"]にDevise.mappings[:resource]を入れましょう。