Module: Merb::Test::RouteHelper

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

Instance Method Summary collapse

Methods included from RequestHelper

#describe_input, #describe_request, #request, #status_code

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



39
40
41
42
43
44
# File 'lib/merb-core/test/helpers/route_helper.rb', line 39

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

#resource(*args) ⇒ Object

Mimics the resource method available to controllers

Paramaters

resources<Object>

The resources to generate URLs from

params<Hash>

Any extra parameters that are required.

Returns

String

The generated URL.



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

def resource(*args)
  args << @request_params || {}
  Merb::Router.resource(*args)
end

#url(*args) ⇒ 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
17
# File 'lib/merb-core/test/helpers/route_helper.rb', line 14

def url(*args)
  args << (@request_params || {})
  Merb::Router.url(*args)
end