lundi 27 avril 2015

How to test redirect_to without making a request

I would like to test if a private method from application_controller redirect_to proper path. Here is what I tried to do:

  describe 'application is complete' do
    it 'redirects to the mortgage application show page' do
      controller.send(:load_mortgage_application)
      expects(controller).to receive(:redirect_to).with(mortgage_application_path(controller.locale, mortgage_application))
    end
  end

But I get error:

  RuntimeError:
ActionController::RackDelegation#status= delegated to @_response.status=, but @_response is nil: ...

How can I test it without having a response?

Aucun commentaire:

Enregistrer un commentaire