Sha256: 0ec87190ae86d52c3d80011f27d1763b7b91f871744ce804a3463e5b537fd205

Contents?: true

Size: 1.69 KB

Versions: 47

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

require "abstract_unit"

module ActionDispatch
  module Journey
    class TestRoutes < ActiveSupport::TestCase
      attr_reader :routes, :mapper

      def setup
        @route_set = ActionDispatch::Routing::RouteSet.new
        @routes = @route_set.router.routes
        @router = @route_set.router
        @mapper = ActionDispatch::Routing::Mapper.new @route_set
        super
      end

      def test_clear
        mapper.get "/foo(/:id)", to: "foo#bar", as: "aaron"
        assert_not_empty routes
        assert_equal 1, routes.length

        routes.clear
        assert_empty routes
        assert_equal 0, routes.length
      end

      def test_ast
        mapper.get "/foo(/:id)", to: "foo#bar", as: "aaron"
        ast = routes.ast
        mapper.get "/foo(/:id)", to: "foo#bar", as: "gorby"
        assert_not_equal ast, routes.ast
      end

      def test_simulator_changes
        mapper.get "/foo(/:id)", to: "foo#bar", as: "aaron"
        sim = routes.simulator
        mapper.get "/foo(/:id)", to: "foo#bar", as: "gorby"
        assert_not_equal sim, routes.simulator
      end

      def test_partition_route
        mapper.get "/foo(/:id)", to: "foo#bar", as: "aaron"

        assert_equal 1, @routes.anchored_routes.length
        assert_empty @routes.custom_routes

        mapper.get "/hello/:who", to: "foo#bar", as: "bar", who: /\d/

        assert_equal 1, @routes.custom_routes.length
        assert_equal 1, @routes.anchored_routes.length
      end

      def test_first_name_wins
        mapper.get "/hello", to: "foo#bar", as: "aaron"
        assert_raise(ArgumentError) do
          mapper.get "/aaron", to: "foo#bar", as: "aaron"
        end
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
jets-1.9.7 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.9.6 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.9.5 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.9.4 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.9.3 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.9.2 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.9.1 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.9.0 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.14 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.13 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.12 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.11 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.10 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.9 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.8 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.7 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.6 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.5 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.4 vendor/rails/actionpack/test/journey/routes_test.rb
jets-1.8.3 vendor/rails/actionpack/test/journey/routes_test.rb