Wie Sie schreiben-controller-tests, wenn Sie Sie überschreiben Sie entwickeln Anmeldung controller?

Ich überschreiben will, die Devise::RegistrationsController zu implementieren, einige benutzerdefinierte functionalality. Um dies zu tun, habe ich einen neuen RegistrationsController etwa so:

# /app/controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
  def new
    super
  end
end

und meine Routen so:

devise_for :users, :controllers => { :registrations => "registrations" }

und versucht es zu testen, wie diese:

describe RegistrationsController do
  describe "GET 'new'" do
    it "should be successful" do
      get :new
      response.should be_success
    end
  end
end

aber das gibt mir eine Fehlermeldung:

 1) RegistrationsController GET 'new' should be successful
 Failure/Error: get :new
 AbstractController::ActionNotFound:
   Could not find devise mapping for path "/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)>'

Also was mache ich falsch?

InformationsquelleAutor David Tuite | 2011-07-12
Schreibe einen Kommentar