personally I've broken with convention and put all my route specs
into a routes_spec.rb file
in part because they're in one file in rails, and when i edit that
file I want to make sure other routes didn't break.
Your question about a catchall is another reason.
I also like to spec named routes, not all the time but especially
those outside the rails resources conventions. Although not strictly
a "behavior", I'm more comfortable knowing that the named routes work
(e.g. logout_path => /logout ) before using them in my code.
Unfortunately I found (via trial and error) that you need a response
first. This is what I have working (although its hackish):
class RoutesController < ApplicationController
def foo
end
end
describe FoosController, "named routes" do
before do
get :foo
end
it "should route /logout " do
logout_path.should == "/logout"
route_for(:controller => "sessions", :action =>
"destroy").should == "/logout"
params_from(:get, "/logout").should == {:controller =>
"sessions", :action => "destroy"}
end
end
--linoj
On Dec 16, 2007, at 11:43 AM, David Chelimsky wrote:
> On Dec 16, 2007 10:32 AM, Francis Hwang <[EMAIL PROTECTED]> wrote:
>> Once again, here's something I haven't figured out. Apologies if this
>> is too newb-ish, but, how do I spec my routes using RSpec-Rails?
>>
>> In particular, I've got a catch-all route that needs to catch a wide
>> variety of URLs:
>>
>> map.document '*url', :controller => 'documents', :action => 'show'
>>
>> Is there a way to have a controller spec test site-wide routing? It
>> seems to me that the get and post methods are just controller-
>> specific routing. If I can't do it in a controller spec, where else
>> should I do it?
>
> Check out route_for and params_from at http://rspec.info/rdoc-rails/.
> There are examples of their use in the controller examples generated
> by 'script/generate rspec_scaffold ...'. Here are a couple of
> examples:
>
> http://pastie.caboo.se/129301
>
> Cheers,
> David
>
>>
>> Thanks,
>>
>> Francis Hwang
>> http://fhwang.net/
>>
>>
>>
>> _______________________________________________
>> rspec-users mailing list
>> [email protected]
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users