Rails RSpec Routing: Testing actions in :except do NOT route

后端 未结 2 348
不知归路
不知归路 2021-01-12 05:14

Fairly simple problem (I\'d have thought), but I\'m having some issues:

In Rails 3.1.0.rc6/RSpec 2.6.0, I\'m trying to test the routing of my \'products\' resource,

相关标签:
2条回答
  • 2021-01-12 05:45

    Do you have a fallback route? Because that would explain why no error is thrown, but indeed trying to evaluate route_to("products#edit", :id => 1) would raise, because the route does not exist.

    0 讨论(0)
  • 2021-01-12 05:55

    I don't know why the lambda would fail, but I don't think the rspec-rails dsl is intended to be used like that. Have you tried something like this?

    { :get => "/products/1/edit" }.should_not be_routable
    

    http://relishapp.com/rspec/rspec-rails/docs/routing-specs/be-routable-matcher

    So you can't specify what it doesn't route to, but you can specify that it doesn't get routed.

    0 讨论(0)
提交回复
热议问题