I'm currently in a simliar situation as you.<br>I have an application that doesn't use the default routing.<br><br>When I try to write my stories.<br>ex.<br><br>And "user logged in successfully" do<br> post "/session/create", :login => "Jon", :password => "your_momma"
<br> response.should redirect_to(home_path)<br>end<br><br>The post fails unless I include this back into my routes file<br> map.connect ':controller/:action/:id.:format'<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
map.connect ':controller/:action/:id'</blockquote><div><br>and even then when I add them back in they'll conflict with my other routes and I have to comment out all my other routes.<br>But then it will pass.<br>
</div><br><div><span class="gmail_quote">On 9/22/07, <b class="gmail_sendername">Ben Mabey</b> <<a href="mailto:ben@benmabey.com">ben@benmabey.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br>The app I am making right now uses restful routing entirely. I want to<br>prevent people from accessing my actions without the proper HTTP verb so<br>I commented out the :controller/:action/:id catch all routes that were
<br>used in pre-RESTful Rails apps. Like so:<br> #map.connect ':controller/:action/:id.:format'<br> #map.connect ':controller/:action/:id'<br>When I did this however all of my routing specs broke. I have been
<br>testing my routes like the rspec-scaffold generator tests them:<br>it "{ :controller => 'users', :action => 'new' } to /users/new" do<br> route_for(:controller => "users", :action => "new").should ==
<br>"/users/new"<br>end<br><br>To get around this the easiest thing I could think of was to add this to<br>my routes.rb:<br>if RAILS_ENV=="test"<br> map.connect ':controller/:action/:id.:format'
<br> map.connect ':controller/:action/:id'<br> end<br><br>Are there better solutions?<br>This is a workaround for the problem, but I'm wondering if there is a<br>better way to test restful routes without relying on the old routing
<br>convention of controller/action/id. Ideally, the routing specs should<br>also verify the HTTP verb as well. Is there any way to do this?<br><br>Thanks,<br>Ben<br>_______________________________________________<br>rspec-users mailing list
<br><a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a><br></blockquote></div><br>