module Rack
  module Test
    
    module Methods
      
      def self.delegate_to_rack_test_session(*meths)
        meths.each do |meth|
          self.class_eval <<-RUBY
            def #{meth}(*args, &blk)
              rack_test_session.#{meth}(*args, &blk)
            end
          RUBY
        end
      end
      
      def rack_test_session
        @_rack_test_session ||= Rack::Test::Session.new(app)
      end
      
      delegate_to_rack_test_session \
        :request,
        
        # HTTP verbs
        :get,
        :post,
        :put,
        :delete,
        :head,
        
        # Redirects
        :follow_redirect!,
        
        # Header-related features
        :header,
        :authorize,

        # Expose the last request and response
        :last_response,
        :last_request
        
        
    end
    
  end
end
require "forwardable"

module Rack
  module Test
    module Methods
      extend Forwardable
      
      def rack_test_session
        @_rack_test_session ||= Rack::Test::Session.new(app)
      end

      METHODS = [
        :request,
        # HTTP verbs
        :get,
        :post,
        :put,
        :delete,
        :head,
        # Redirects
        :follow_redirect!,
        # Header-related features
        :header,
        :authorize,
        # Expose the last request and response
        :last_response,
        :last_request
      ]

      def_delegators :rack_test_session, *METHODS
    end
  end
end

Use forwardable from the stdlib
Use forwardable from the stdlib
