module Merb module Test module RouteHelper include RequestHelper # Mimics the url method available to controllers. # # ==== Parameters # name<~to_sym>:: The name of the URL to generate. # params:: Parameters for the route generation. # # ==== Returns # String:: The generated URL. def url(*args) args << (@request_params || {}) Merb::Router.url(*args) end # Mimics the resource method available to controllers # # ==== Paramaters # resources:: The resources to generate URLs from # params:: Any extra parameters that are required. # # ==== Returns # String:: The generated URL. def resource(*args) args << @request_params || {} Merb::Router.resource(*args) end # ==== Parameters # path<~to_string>:: The URL of the request. # method<~to_sym>:: HTTP request method. # env:: Additional parameters for the request. # # ==== Returns # Hash:: A hash containing the controller and action along with any parameters def request_to(path, method = :get, env = {}) env[:request_method] ||= method.to_s.upcase env[:request_uri] = path check_request_for_route(build_request({}, env)) end end end end