Wednesday, 15 September 2010

ruby on rails - Routing Test Fails with Matched Route -



ruby on rails - Routing Test Fails with Matched Route -

i have line of code in routes

namespace :api, defaults: {format: 'json'} namespace :v1 match '/auth/:provider/callback', to: 'sign_in#authenticate' end end

and test as

require 'spec_helper' describe "routing" "should route sign_in#authenticate" expect(post: 'api/v1/auth/:provider/callback').to route_to({ controller: 'api/v1/sign_in', action: 'authenticate', format: 'json' }) end end

however, no matter maintain getting error

no route matches "/api/v1/auth/:provider/callback"

what missing here in order create test pass?

i believe error you're getting because match defaults request, testing post request in spec. should able prepare issue changing route to:

match '/auth/:provider/callback', to: 'sign_in#authenticate', via: :post

my personal preference utilize post method instead of match, reads improve me:

post '/auth/:provider/callback' => 'sign_in#authenticate'

ruby-on-rails ruby-on-rails-3 rspec routes omniauth

No comments:

Post a Comment