Sha256: 024ab606807a0e8ff14703d09d248071eaf0013603f486eb6b29c1805156481b

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rtml-2.0.3 spec/lib/rtml/routes_spec.rb
rtml-2.0.2 spec/lib/rtml/routes_spec.rb
rtml-2.0.1 spec/lib/rtml/routes_spec.rb
rtml-2.0.0.alpha.1 spec/lib/rtml/routes_spec.rb