diff options
author | Ryan Davis <ryand-ruby@zenspider.com> | 2012-11-17 01:36:30 -0800 |
---|---|---|
committer | Ryan Davis <ryand-ruby@zenspider.com> | 2012-11-17 01:36:30 -0800 |
commit | 270d1cfe30b4c8c31cdf8512c012f544ae8c564b (patch) | |
tree | b3e248d5cb807e38752b92b969086e2334c6ed7a /actionpack | |
parent | 02e368413301b9b60a29b9c8d901185e29e479ba (diff) | |
download | rails-270d1cfe30b4c8c31cdf8512c012f544ae8c564b.tar.gz rails-270d1cfe30b4c8c31cdf8512c012f544ae8c564b.tar.bz2 rails-270d1cfe30b4c8c31cdf8512c012f544ae8c564b.zip |
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.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/assertions/routing.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb index 8f17ee05be..79dff7d121 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb @@ -36,16 +36,19 @@ module ActionDispatch # # # 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+. |