Sha256: 1a6b31d651663f9abb2a976e09790a9b03cecf15304ea7068f56f738eb3e51d1

Contents?: true

Size: 797 Bytes

Versions: 5

Compression:

Stored size: 797 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
          ActionController::Routing::Routes.routes.collect do |route|
            name = ActionController::Routing::Routes.named_routes.routes.index(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

5 entries across 5 versions & 2 rubygems

Version Path
rich_support-0.1.1 lib/rich/support/actionpack/action_controller/test_case.rb
rich_support-0.1.0 lib/rich/support/actionpack/action_controller/test_case.rb
rich_cms-3.0.2 test/shared/support/action_controller/test_case.rb
rich_cms-3.0.1 test/shared/support/action_controller/test_case.rb
rich_cms-3.0.0 test/shared/support/action_controller/test_case.rb