Sha256: c7d418279aa4850d03cc37096c6f2858127221b05fcb3c181b1a12a1517eae87

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 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

  # Turns out this was not possible, because Rails freezes the route objects.
#  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 => 'inherited', :action => 'index', :format => 'rtml' }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rtml-2.0.4 spec/lib/rtml/routes_spec.rb