Forcing the Loading of Named Routes

Hi all,

I have a spec for my controller (and its routing) that looks like this:

  describe "named routes" do

    before do
      # mini-hack: need a GET before the named routes are loaded
      get :index
    end

    it "admin_venue_merges_path.should == '/admin/venue_merges'" do
      admin_venue_merges_path.should == "/admin/venue_merges"
    end

  end

Trouble is, I don’t actually need an index action on this particular
controller - it’s just there so that I can spin up whatever the code is
within ActionPack that loads those named route methods.

What I’d prefer to do is directly call ActionController or whatever and
tell it to load the named routes.

I’m fairly new to ruby and find the source code to ActionPack pretty
overwhelming.

Can anyone more au fait with the rails source tell me how I might
achieve this?

I recommend generating an rspec_scaffold. It gives some nice examples
for
model, controller and view specs.

$ script/generate rspec_scaffold Person name:string age:integer

gives this for verifying routing:

describe PeopleController do
describe “route generation” do
it “should map #index” do
route_for(:controller => “people”, :action => “index”).should ==
“/people”
end

end

end

Regards,
Craig

Craig D. wrote:

I recommend generating an rspec_scaffold.
gives this for verifying routing:

describe PeopleController do
describe “route generation” do
it “should map #index” do
route_for(:controller => “people”, :action => “index”).should ==
“/people”
end

end

end
Okay sure, but if I want to test the named route, for example if I
want to put a route into a namespace, how do I write a test for that?