Sha256: 8173acad91bd255000d5131188b002cc13b6f539707907e114871ce48e4903e9

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 Bytes

Contents

module ActionController
  class TestCase

  protected

    def assert_named_route(result, name)
      assert_equal result, named_routes[name.to_s]
    end

    def named_routes
      @named_routes ||= Hash[*begin
        if Rails::VERSION::MAJOR >= 3
          Rails.application.routes.routes.collect do |route|
            [route.name, route.path.gsub("(.:format)", "")] unless route.name.blank?
          end
        else
          method = ActionController::Routing::Routes.named_routes.routes.respond_to?(:key) ? :key : :index
          ActionController::Routing::Routes.routes.collect do |route|
            name = ActionController::Routing::Routes.named_routes.routes.send(method, route).to_s
            path = route.segments.collect(&:to_s).join
            path.chop! if path.length > 1
            [name, path] unless name.blank?
          end
        end
      end.compact.flatten]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rich_support-0.1.2 lib/rich/support/actionpack/action_controller/test_case.rb