diff options
author | Prathamesh Sonpatki <csonpatki@gmail.com> | 2015-12-06 21:39:59 +0530 |
---|---|---|
committer | Prathamesh Sonpatki <csonpatki@gmail.com> | 2015-12-06 21:39:59 +0530 |
commit | b24711621075350285fed67392720349722f4654 (patch) | |
tree | c75bd3c36867355d598b343b245dbc4e08967d11 /actionpack/lib | |
parent | 65443ceb0d55e1445b28e31e772629424e6755c3 (diff) | |
download | rails-b24711621075350285fed67392720349722f4654.tar.gz rails-b24711621075350285fed67392720349722f4654.tar.bz2 rails-b24711621075350285fed67392720349722f4654.zip |
Use assert over assert_predicate in assert_response
- `assert_predicate` appends its own error message at the end of message
generated by `assert_response` and because of that the error message
displays the whole `response` object.
- For eg.
Expected response to be a <success>, but was a redirect to <http://test.host/posts>.
Expected #<ActionDispatch::TestResponse:0x007fb1cc1cf6f8....(lambda)>}>> to be successful?.
- Complete message can be found here -
https://gist.github.com/prathamesh-sonpatki/055afb74b66108e71ded#file-gistfile1-txt-L19.
- After this change the message from `assert_predicate` won't be
displayed and only message generated by `assert_response` will be shown
as follows:
Expected response to be a <success>, but was a redirect to <http://test.host/posts>
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/assertions/response.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb index 5af052afb4..cc2a2fb119 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/response.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb @@ -31,7 +31,7 @@ module ActionDispatch if Symbol === type if [:success, :missing, :redirect, :error].include?(type) - assert_predicate @response, RESPONSE_PREDICATES[type], message + assert @response.send(RESPONSE_PREDICATES[type]), message else code = Rack::Utils::SYMBOL_TO_STATUS_CODE[type] if code.nil? |