Permalink
Browse files

Updated assert_generates/routing to the new Routes code #1498 [Rick O…

…lson]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1505 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent deda0ee commit 6f6c6b8bcb78169bcd6dd3aaa1c0410e7b36b567 @dhh dhh committed Jun 25, 2005
Showing with 6 additions and 1 deletion.
  1. +2 −1 actionpack/lib/action_controller/assertions.rb
  2. +4 −0 actionpack/test/controller/test_test.rb
@@ -94,6 +94,7 @@ def assert_template(expected = nil, message=nil)
# Asserts that the routing of the given path is handled correctly and that the parsed options match.
def assert_recognizes(expected_options, path, extras={}, message=nil)
+ path = "/#{path}" unless path[0..0] == '/'
# Load routes.rb if it hasn't been loaded.
ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
@@ -105,6 +106,7 @@ def assert_recognizes(expected_options, path, extras={}, message=nil)
expected_options = expected_options.clone
extras.each_key { |key| expected_options.delete key } unless extras.nil?
+ expected_options.stringify_keys!
msg = build_message(message, "The recognized options <?> did not match <?>",
request.path_parameters, expected_options)
assert_block(msg) { request.path_parameters == expected_options }
@@ -121,7 +123,6 @@ def assert_generates(expected_path, options, defaults={}, extras = {}, message=n
request.path_parameters[:controller] ||= options[:controller]
generated_path, found_extras = ActionController::Routing::Routes.generate(options, request)
- generated_path = generated_path.join('/')
msg = build_message(message, "found extras <?>, not <?>", found_extras, extras)
assert_block(msg) { found_extras == extras }
@@ -84,4 +84,8 @@ def test_assert_tag
:children => { :greater_than => 2,
:only => { :tag => "li" } } }
end
+
+ def test_assert_routing
+ assert_generates 'controller/action/5', :controller => 'controller', :action => 'action', :id => '5'
+ end
end

0 comments on commit 6f6c6b8

Please sign in to comment.