alexandernst alexandernst - 1 year ago 71
Ruby Question

Rspec not matching my route

I have

post '/foo/bar', to: 'api/v1/things#bar'
in my

rails routes

foo_bar POST /foo/bar(.:format) api/v1/things#bar

I'm trying to test it with
post '/foo/bar'
, but I get

No route matches {:action=>"/foo/bar", :controller=>"api/v1/things"}

I know the problem is something silly, but I'm unable to see it. Any ideas?

Answer Source

Routing is not a thing when you run controller specs.


post 'bar'

Very likely there is describe API::V1:Things do around this test, this tells RSpec which controller to use.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download