Permalink
Browse files

Removed extra call to #diff in #assert_recognizes. assert_equal calls…

… it for you and shows the diff. Also delayed message calculation so the cost of the diff on success is now gone.
  • Loading branch information...
1 parent 02e3684 commit 270d1cfe30b4c8c31cdf8512c012f544ae8c564b @zenspider zenspider committed Nov 17, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 actionpack/lib/action_dispatch/testing/assertions/routing.rb
@@ -36,16 +36,19 @@ module RoutingAssertions
#
# # Test a custom route
# assert_recognizes({controller: 'items', action: 'show', id: '1'}, 'view/item1')
- def assert_recognizes(expected_options, path, extras={}, message=nil)
+ def assert_recognizes(expected_options, path, extras={}, msg=nil)
request = recognized_request_for(path, extras)
expected_options = expected_options.clone
expected_options.stringify_keys!
- message ||= sprintf("The recognized options <%s> did not match <%s>, difference: <%s>",
- request.path_parameters, expected_options, diff(expected_options, request.path_parameters))
- assert_equal(expected_options, request.path_parameters, message)
+ msg = message(msg, "") {
+ sprintf("The recognized options <%s> did not match <%s>, difference:",
+ request.path_parameters, expected_options)
+ }
+
+ assert_equal(expected_options, request.path_parameters, msg)
end
# Asserts that the provided options can be used to generate the provided path. This is the inverse of +assert_recognizes+.

0 comments on commit 270d1cf

Please sign in to comment.