title: Rspec: Test redirects in Devise::OmniauthCallbacksController subclass
body: <p>Following the <a href="http://railscasts.com/episodes/235-devise-and-omniauth-revised?view=asciicast" rel="nofollow noreferrer">Railscast on Devise and OmniAuth</a> I have implemented an <code>OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController</code> which contains a single method to handle an OmniAuth callback:</p>
  
  <pre><code>def all
    user = User.from_omniauth(request.env["omniauth.auth"])
    if user.persisted?
      sign_in_and_redirect user
    else
      session["devise.user_attributes"] = user.attributes
      redirect_to new_user_registration_url
    end
  end
  alias_method :facebook, :all
  </code></pre>
  
  <p>routes.rb:</p>
  
  <pre><code>devise_for :users, controllers: {omniauth_callbacks: "omniauth_callbacks", :sessions =&gt; "sessions" }
  </code></pre>
  
  <p>I would like to customise this, so I'm trying to test it using RSpec. The question is how do I test this method and the redirects?</p>
  
  <p>If in the spec I put <code>user_omniauth_callback_path(:facebook)</code> it doesn't complain about the route not existing, but doesn't seem to actually call the method.</p>
  
  <p>According to <a href="https://stackoverflow.com/a/4228714/1450420">this answer</a> "controller tests use the four HTTP verbs (GET, POST, PUT, DELETE), regardless of whether your controller is RESTful."  I tried <code>get user_...</code> etc. but here it does complain that the route doesn't exist.  And indeed if I do <code>rake routes</code> it shows there is no HTTP verb for this route:</p>
  
  <pre><code>user_omniauth_callback [BLANK] /users/auth/:action/callback(.:format) omniauth_callbacks#(?-mix:facebook)
  </code></pre>
  
  <p>Can you see what I'm missing?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>So following <a href="https://stackoverflow.com/questions/10989461/runtimeerror-actioncontrollerrackdelegation-in-rspec-2-10-1-for-rails-3-1-4-a">this question</a> one way of calling the method is:</p>
  
  <pre><code>controller.send(:all)
  </code></pre>
  
  <p>However I then run into the same error that the questioner ran into:</p>
  
  <pre><code>ActionController::RackDelegation#content_type delegated to @_response.content_type, but @_response is nil
  </code></pre>