mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Improve error messages in cookies_test
Using `assert_predicate` and `assert_match` instead of just `assert` is preferrable because better error messages are output. In the case of `assert response.cookies.empty?` the error message was `Failed assertion, no message given.` but now with `assert_predicate` it will be `Expected {"user_name"=>"david"} to be empty?.` For `assert_match(/user_name=david/, response.headers["Set-Cookie"])` as well, the message returned was unhelpful - `Failed assertion, no message given.` but now will tell what was expected and what was returned with `Expected /user_name=david/ to match "user_name=nope; path=/".`
This commit is contained in:
parent
991e98f564
commit
4d7b507073
1 changed files with 3 additions and 3 deletions
|
@ -280,7 +280,7 @@ class CookiesTest < ActionController::TestCase
|
|||
def test_setting_the_same_value_to_cookie
|
||||
request.cookies[:user_name] = 'david'
|
||||
get :authenticate
|
||||
assert response.cookies.empty?
|
||||
assert_predicate response.cookies, :empty?
|
||||
end
|
||||
|
||||
def test_setting_the_same_value_to_permanent_cookie
|
||||
|
@ -360,7 +360,7 @@ class CookiesTest < ActionController::TestCase
|
|||
def test_delete_unexisting_cookie
|
||||
request.cookies.clear
|
||||
get :delete_cookie
|
||||
assert @response.cookies.empty?
|
||||
assert_predicate @response.cookies, :empty?
|
||||
end
|
||||
|
||||
def test_deleted_cookie_predicate
|
||||
|
@ -378,7 +378,7 @@ class CookiesTest < ActionController::TestCase
|
|||
|
||||
def test_cookies_persist_throughout_request
|
||||
response = get :authenticate
|
||||
assert response.headers["Set-Cookie"] =~ /user_name=david/
|
||||
assert_match(/user_name=david/, response.headers["Set-Cookie"])
|
||||
end
|
||||
|
||||
def test_set_permanent_cookie
|
||||
|
|
Loading…
Reference in a new issue