1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

8 commits

Author SHA1 Message Date
Derek Prior
31ef17a5eb
Fix "instance variable not initialized" in tests
The ActionPack test suite had a handful of these warnings when run. This
was due to `assert_response` being tested outside the context of a
controller instance where those instance variables would already have
been initialized.
2015-12-17 21:20:25 -05:00
Jon Atack
c6fe614e45 Show redirect response code in assert_response messages
Follow-up to PR #19977, which helpfully added the redirection path to the error message of assert_response if response is a redirection, but which removed the response code, obscuring the type of redirect.

This PR:

- brings back the response code in the error message,

- updates the tests so the new messages can be tested,

- and adds test cases for the change.
2015-12-11 18:18:08 +01:00
Prathamesh Sonpatki
b247116210 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>
2015-12-06 21:39:59 +05:30
Prathamesh Sonpatki
1ee87e42ca Add redirection path in the error message of assert_response if response is :redirect
- If the assert_response is checking for any non-redirect response like
  :success and actual response is :redirect then, the error message displayed
  was -

     Expected response to be a <success>, but was <302>

- This commit adds the redirect path to the error message of
  assert_response if the response is :redirect.
  So above message is changed to -

     Expected response to be a <success>, but was a redirect to <http://test.host/posts/lol>
2015-12-04 13:13:25 +05:30
Aaron Patterson
908bc79729 use a lookup table for assert_response
We shouldn't depend on specific methods imlemented in the TestResponse
subclass because the response could actually be a real response object.

In the future, we should either push the aliased predicate methods in
TestResponse up to the real response object, or remove them
2015-07-13 18:10:36 -07:00
Vipul A M
7bae2921ec Change all MiniTest to Minitest since, MiniTest namespace has been renamed to Minitest
Ref: https://github.com/seattlerb/minitest/blob/master/History.txt
2013-12-18 14:39:50 +05:30
Victor Costan
c759a93454 Better error message for typos in assert_response argument.
This commit makes it really easy to debug errors due to typos like
"assert_response :succezz".
2013-11-25 03:09:02 -05:00
Aaron Patterson
01d17943ec test response assertions 2012-01-06 11:20:26 -08:00