require File.join(__FILE__.gsub(/(.*)?\/spec\/.*$/, '\1'), 'spec/spec_helper') describe "routes" do def route(uri = @uri) ActionController::Routing::Routes.recognize_path(uri) end before(:each) { @uri = "/rtml/action" } context "with id" do before(:each) { @uri.concat ".1.rtml" } it("should find a route") { route.should == { :controller => 'rtml', :action => 'action', :format => 'rtml', :id => '1' } } end context "without id" do before(:each) { @uri.concat ".rtml" } it "should find a route" do route.should == { :controller => 'rtml', :action => 'action', :format => 'rtml' } end end context "with double connection" do before(:each) do ActionController::Routing::Routes.reload! ActionController::Routing::Routes.draw { |map| map.connect_rtml :controller => 'another' } end after(:each) do ActionController::Routing::Routes.reload! end # removed since it doesn't really matter in the long run -- this stuff all gets optimized by rails. # it "should not double connect generic routes" do # matches = [] # ActionController::Routing::Routes.routes.each do |route| # matches.should_not include(route.segments.to_s) # matches << route.segments.to_s # end # end it "should update nongeneric routes" do # route("/index.tml")[:controller].should == 'another' end end it "should match /index.tml" do route("/index.tml").should == { :controller => 'rtml', :action => 'index', :format => 'rtml' } end end