test_response.rb 882 字节
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 10 11 12 13 14 15 16 17
  class TestResponse < Response
    def self.from_response(response)
      new.tap do |resp|
        resp.status  = response.status
        resp.headers = response.headers
        resp.body    = response.body
      end
    end

    # Was the response successful?
18
    alias_method :success?, :successful?
19 20

    # Was the URL not found?
21
    alias_method :missing?, :not_found?
22 23

    # Were we redirected?
24
    alias_method :redirect?, :redirection?
25 26

    # Was there a server-side error?
27
    alias_method :error?, :server_error?
28 29
  end
end