class ActionDispatch::TestResponse

Integration test methods such as ActionDispatch::Integration::RequestHelpers#get and ActionDispatch::Integration::RequestHelpers#post return objects of class TestResponse, which represent the HTTP response results of the requested controller actions.

See Response for more information on controller response objects.

Public Class Methods

from_response(response) click to toggle source
# File lib/action_dispatch/testing/test_response.rb, line 9
def self.from_response(response)
  new.tap do |resp|
    resp.status  = response.status
    resp.headers = response.headers
    resp.body    = response.body
  end
end

Public Instance Methods

client_error?() click to toggle source

Was there a client client?

# File lib/action_dispatch/testing/test_response.rb, line 132
def client_error?
  (400..499).include?(response_code)
end
error?() click to toggle source

Was there a server-side error?

# File lib/action_dispatch/testing/test_response.rb, line 126
def error?
  (500..599).include?(response_code)
end
Also aliased as: server_error?
missing?() click to toggle source

Was the URL not found?

# File lib/action_dispatch/testing/test_response.rb, line 116
def missing?
  response_code == 404
end
redirect?() click to toggle source

Were we redirected?

# File lib/action_dispatch/testing/test_response.rb, line 121
def redirect?
  (300..399).include?(response_code)
end
server_error?() click to toggle source
Alias for: error?
success?() click to toggle source

Was the response successful?

# File lib/action_dispatch/testing/test_response.rb, line 111
def success?
  (200..299).include?(response_code)
end