Module: Merb::Test::RouteHelper

Includes:
RequestHelper
Defined in:
lib/merb-core/test/helpers/route_helper.rb

Instance Method Summary collapse

Methods included from RequestHelper

#build_request, #check_request_for_route, #delete, #dispatch_request, #dispatch_to, #dispatch_with_basic_authentication_to, #fake_request, #get, #post, #put, #request

Instance Method Details

#request_to(path, method = :get, env = {}) ⇒ Object

Parameters

path<~to_string>

The URL of the request.

method<~to_sym>

HTTP request method.

env<Hash>

Additional parameters for the request.

Returns

Hash

A hash containing the controller and action along with any parameters



25
26
27
28
29
30
# File 'lib/merb-core/test/helpers/route_helper.rb', line 25

def request_to(path, method = :get, env = {})
  env[:request_method] ||= method.to_s.upcase
  env[:request_uri] = path
  
  check_request_for_route(fake_request(env))
end

#url(name, params = {}) ⇒ Object

Mimics the url method available to controllers.

Parameters

name<~to_sym>

The name of the URL to generate.

params<Hash>

Parameters for the route generation.

Returns

String

The generated URL.



14
15
16
# File 'lib/merb-core/test/helpers/route_helper.rb', line 14

def url(name, params={})
  Merb::Router.generate(name, params)
end