跳到內容 跳到搜尋
方法
D
F
G
H
O
P

執行個體公開的方法

delete(path, **args)

執行指定參數的 DELETE 請求。有關更多詳情,請參閱 ActionDispatch::Integration::Session#process

# File actionpack/lib/action_dispatch/testing/integration.rb, line 42
def delete(path, **args)
  process(:delete, path, **args)
end

follow_redirect!(headers: {}, **args)

追蹤單一重新導向回應。如果上一個回應並非重新導向,系統會提出例外。否則,系統會對位置標頭執行重新導向。如果重新導向為 307 或 308 重新導向,重新導向時將使用相同的 HTTP 動詞,否則會執行 GET 請求。任何參數都會傳遞給基礎請求。

HTTP_REFERER 標頭會設定為前一個 URL。

# File actionpack/lib/action_dispatch/testing/integration.rb, line 65
def follow_redirect!(headers: {}, **args)
  raise "not a redirect! #{status} #{status_message}" unless redirect?

  method =
    if [307, 308].include?(response.status)
      request.method.downcase
    else
      :get
    end

  if [ :HTTP_REFERER, "HTTP_REFERER" ].none? { |key| headers.key? key }
    headers["HTTP_REFERER"] = request.url
  end

  public_send(method, response.location, headers: headers, **args)
  status
end

get(path, **args)

執行指定參數的 GET 請求。有關更多詳情,請參閱 ActionDispatch::Integration::Session#process

# File actionpack/lib/action_dispatch/testing/integration.rb, line 18
def get(path, **args)
  process(:get, path, **args)
end

head(path, **args)

執行指定參數的 HEAD 請求。有關更多詳情,請參閱 ActionDispatch::Integration::Session#process

# File actionpack/lib/action_dispatch/testing/integration.rb, line 48
def head(path, **args)
  process(:head, path, **args)
end

options(path, **args)

執行指定參數的 OPTIONS 請求。有關更多詳情,請參閱 ActionDispatch::Integration::Session#process

# File actionpack/lib/action_dispatch/testing/integration.rb, line 54
def options(path, **args)
  process(:options, path, **args)
end

patch(path, **args)

執行使用指定參數的 PATCH 請求。更多詳情,請參閱ActionDispatch::Integration::Session#process

# File actionpack/lib/action_dispatch/testing/integration.rb, line 30
def patch(path, **args)
  process(:patch, path, **args)
end

post(path, **args)

執行使用指定參數的 POST 請求。更多詳情,請參閱ActionDispatch::Integration::Session#process

# File actionpack/lib/action_dispatch/testing/integration.rb, line 24
def post(path, **args)
  process(:post, path, **args)
end

put(path, **args)

執行使用指定參數的 PUT 請求。更多詳情,請參閱ActionDispatch::Integration::Session#process

# File actionpack/lib/action_dispatch/testing/integration.rb, line 36
def put(path, **args)
  process(:put, path, **args)
end