跳至内容 跳至搜索
方法
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