require "action_dispatch/testing/assertions/routing"

module RSpec::Rails
  module RoutingExampleGroup
    extend ActiveSupport::Concern
    include RSpec::Rails::RailsExampleGroup
    include ActionDispatch::Assertions::RoutingAssertions
    include RSpec::Rails::Matchers::RoutingMatchers
    include RSpec::Rails::Matchers::RoutingMatchers::RouteHelpers

    module InstanceMethods
      
      def routes
        @routes ||= ::Rails.application.routes
      end

      private

      def method_missing(m, *args, &block)
        routes.url_helpers.respond_to?(m) ? routes.url_helpers.send(m, *args) : super
      end
    end

    included do
      metadata[:type] = :routing
    end
  end
end

require "action_dispatch/testing/assertions/routing"

module RSpec::Rails
  module RoutingExampleGroup
    extend ActiveSupport::Concern
    include RSpec::Rails::RailsExampleGroup
    include ActionDispatch::Assertions::RoutingAssertions
    include RSpec::Rails::Matchers::RoutingMatchers
    include RSpec::Rails::Matchers::RoutingMatchers::RouteHelpers

    module InstanceMethods
      attr_reader :routes

      private

      def method_missing(m, *args, &block)
        routes.url_helpers.respond_to?(m) ? routes.url_helpers.send(m, *args) : super
      end
    end

    included do
      metadata[:type] = :routing

      before do
        @routes = ::Rails.application.routes
      end
    end
  end
end

Revert "restored the ability to use method missing matchers like be_blank or be_true in before blocks for routing example groups"
Revert "restored the ability to use method missing matchers like be_blank or be_true in before blocks for routing example groups"

This reverts commit c1c2f606eba41be720224aa1f972ea0730d3c489.

Unfortunately, there is code outside rspec's control that refers
directly to the instance variable, so this change ends up breaking more
than it fixes.

- Reopens #460.
