diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-02-20 09:44:09 -0700 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-02-20 09:44:09 -0700 |
commit | f3186093d816675344c4f93c82c96fe8e94caafa (patch) | |
tree | 9fa9f4340da59c03349eceace8e117b7d6f7cbaf /actionpack/lib/action_dispatch/testing/assertions | |
parent | e0f29c51b9bbb41f4235d0948103194096d92cd9 (diff) | |
parent | 6cf671b61e35a94ec8e6acad0aaef85822c93eb0 (diff) | |
download | rails-f3186093d816675344c4f93c82c96fe8e94caafa.tar.gz rails-f3186093d816675344c4f93c82c96fe8e94caafa.tar.bz2 rails-f3186093d816675344c4f93c82c96fe8e94caafa.zip |
Merge pull request #18665 from sgrif/sg-test-route-all
Allow `method: "all"` as a valid routing test option
Diffstat (limited to 'actionpack/lib/action_dispatch/testing/assertions')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/assertions/routing.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb index a927738b42..c94eea9134 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb @@ -38,18 +38,24 @@ module ActionDispatch # # Test a custom route # assert_recognizes({controller: 'items', action: 'show', id: '1'}, 'view/item1') def assert_recognizes(expected_options, path, extras={}, msg=nil) - request = recognized_request_for(path, extras, msg) + if path.is_a?(Hash) && path[:method].to_s == "all" + [:get, :post, :put, :delete].each do |method| + assert_recognizes(expected_options, path.merge(method: method), extras, msg) + end + else + request = recognized_request_for(path, extras, msg) - expected_options = expected_options.clone + expected_options = expected_options.clone - expected_options.stringify_keys! + expected_options.stringify_keys! - msg = message(msg, "") { - sprintf("The recognized options <%s> did not match <%s>, difference:", - request.path_parameters, expected_options) - } + 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) + assert_equal(expected_options, request.path_parameters, msg) + end end # Asserts that the provided options can be used to generate the provided path. This is the inverse of +assert_recognizes+. |