Included Modules

Class Index [+]

Quicksearch

Merb::Test::RouteHelper

Public Instance Methods

request_to(path, method = :get, env = {}) click to toggle source

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

    # File lib/merb-core/test/helpers/route_helper.rb, line 85
85:       def request_to(path, method = :get, env = {})
86:         env[:request_method] ||= method.to_s.upcase
87:         env[:request_uri] = path
88:         
89:         check_request_for_route(build_request({}, env))
90:       end
resource(*args) click to toggle source

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.

    # File lib/merb-core/test/helpers/route_helper.rb, line 73
73:       def resource(*args)
74:         args << @request_params || {}
75:         Merb::Router.resource(*args)
76:       end
url(*args) click to toggle source

There are three possible ways to use this method. First, if you have a named route, you can specify the route as the first parameter as a symbol and any paramters in a hash. Second, you can generate the default route by just passing the params hash, just passing the params hash. Finally, you can use the anonymous parameters. This allows you to specify the parameters to a named route in the order they appear in the router.

Parameters(Named Route)

name

The name of the route.

args

Parameters for the route generation.

Parameters(Default Route)

args

Parameters for the route generation. This route will use the default route.

Parameters(Anonymous Parameters)

name

The name of the route.

args

An array of anonymous parameters to generate the route with. These parameters are assigned to the route parameters in the order that they are passed.

Returns

String

The generated URL.

Examples

Named Route

Merb::Router.prepare do

  match("/articles/:title").to(:controller => :articles, :action => :show).name("articles")

end

url(:articles, :title => “new_article“)

Default Route

Merb::Router.prepare do

  default_routes

end

url(:controller => “articles”, :action => “new”)

Anonymous Paramters

Merb::Router.prepare do

  match("/articles/:year/:month/:title").to(:controller => :articles, :action => :show).name("articles")

end

url(:articles, 2008, 10, “test_article“)

:api: public

    # File lib/merb-core/test/helpers/route_helper.rb, line 60
60:       def url(*args)
61:         args << (@request_params || {})
62:         Merb::Router.url(*args)
63:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.