Module: Test::Spec::Rails::ShouldRoute

Defined in:
lib/test/spec/rails/should_route.rb

Instance Method Summary collapse

Instance Method Details

#route(options) ⇒ Object

Specify that a path should be routable from a set of url options and vice versa. This translates directly to assert_routing Examples:

"/items/1".should.route :controller => "items", :action => "show", :id =>"1"

See also api.rubyonrails.org/classes/ActionController/Assertions/RoutingAssertions.html#M000368



29
30
31
# File 'lib/test/spec/rails/should_route.rb', line 29

def route(options)
  assert_routing(@object, options)
end

#route_from(options, extras = {}) ⇒ Object

Specify that a path should be routable from a set of url options. This translates directly to assert_recognizes Examples:

{:path => "/items/1", :method => :get}.should.route_from :controller => "items", :action => "show", :id =>"1"
{:path => "/items/1?print=true", :method => :get}.should.route_from({:controller => "items", :action => "show", :id =>"1"}, {:print => true})

See also api.rubyonrails.org/classes/ActionController/Assertions/RoutingAssertions.html#M000366



19
20
21
# File 'lib/test/spec/rails/should_route.rb', line 19

def route_from(options, extras={})
  assert_recognizes(options, @object, extras)
end

#route_to(options) ⇒ Object

Specify that a set of url options route to a path. This translates directly to assert_generates Example:

{:controller => "items", :action => "show", :id =>"1"}.should.route_to "/items/1"

See also api.rubyonrails.org/classes/ActionController/Assertions/RoutingAssertions.html#M000367



8
9
10
# File 'lib/test/spec/rails/should_route.rb', line 8

def route_to(options)
  assert_generates(options, @object)
end