diff options
author | Arthur Nogueira Neves <github@arthurnn.com> | 2015-12-05 16:52:04 -0500 |
---|---|---|
committer | Arthur Nogueira Neves <github@arthurnn.com> | 2015-12-05 16:52:04 -0500 |
commit | 65443ceb0d55e1445b28e31e772629424e6755c3 (patch) | |
tree | c074e7fad8c09d424221aebb66f77df899b87f71 /actionpack/test/assertions | |
parent | cb148c5ca1c80d51a8b43967692f18264c9a7029 (diff) | |
parent | 1ee87e42caa832510dfb4a1cb6c7643620447166 (diff) | |
download | rails-65443ceb0d55e1445b28e31e772629424e6755c3.tar.gz rails-65443ceb0d55e1445b28e31e772629424e6755c3.tar.bz2 rails-65443ceb0d55e1445b28e31e772629424e6755c3.zip |
Merge pull request #19977 from prathamesh-sonpatki/mention-redirect-path-in-assert-response
Add redirection path in the error message of assert_response if response is :redirect
Diffstat (limited to 'actionpack/test/assertions')
-rw-r--r-- | actionpack/test/assertions/response_assertions_test.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/actionpack/test/assertions/response_assertions_test.rb b/actionpack/test/assertions/response_assertions_test.rb index 82c747680d..6c7036aa1a 100644 --- a/actionpack/test/assertions/response_assertions_test.rb +++ b/actionpack/test/assertions/response_assertions_test.rb @@ -6,7 +6,12 @@ module ActionDispatch class ResponseAssertionsTest < ActiveSupport::TestCase include ResponseAssertions - FakeResponse = Struct.new(:response_code) do + FakeResponse = Struct.new(:response_code, :location) do + def initialize(*) + super + self.location ||= "http://test.example.com/posts" + end + [:successful, :not_found, :redirection, :server_error].each do |sym| define_method("#{sym}?") do sym == response_code @@ -58,6 +63,16 @@ module ActionDispatch assert_response :succezz } end + + def test_message_when_response_is_redirect_but_asserted_for_status_other_than_redirect + @response = FakeResponse.new :redirection, "http://test.host/posts/redirect/1" + error = assert_raises(Minitest::Assertion) do + assert_response :success + end + + expected = "Expected response to be a <success>, but was a redirect to <http://test.host/posts/redirect/1>." + assert_match expected, error.message + end end end end |