test_response.rb 813 字节
Newer Older
1
module ActionDispatch
J
Joshua Peek 已提交
2 3
  # Integration test methods such as ActionDispatch::Integration::Session#get
  # and ActionDispatch::Integration::Session#post return objects of class
4 5 6 7
  # TestResponse, which represent the HTTP response results of the requested
  # controller actions.
  #
  # See Response for more information on controller response objects.
8 9
  class TestResponse < Response
    def self.from_response(response)
10
      new response.status, response.headers, response.body, default_headers: nil
11 12 13
    end

    # Was the response successful?
14
    alias_method :success?, :successful?
15 16

    # Was the URL not found?
17
    alias_method :missing?, :not_found?
18 19

    # Were we redirected?
20
    alias_method :redirect?, :redirection?
21 22

    # Was there a server-side error?
23
    alias_method :error?, :server_error?
24 25
  end
end