跳到內容 跳到搜尋
命名空間
方法
C
D
包含模組

常數

DEFAULT_PATH = "/cable"
 

屬性

[R] connection

實體公開方法

connect(path = ActionCable.server.config.mount_path, **request_params)

對待測試中連線執行連線嘗試,以執行 connect

接受請求路徑為第一個引數和以下的請求選項:

  • params – 網址參數 (雜湊)

  • headers – 請求標頭 (雜湊)

  • session – 會話資料 (雜湊)

  • env – 其他機架環境組態 (雜湊)

# File actioncable/lib/action_cable/connection/test_case.rb, line 195
def connect(path = ActionCable.server.config.mount_path, **request_params)
  path ||= DEFAULT_PATH

  connection = self.class.connection_class.allocate
  connection.singleton_class.include(TestConnection)
  connection.send(:initialize, build_test_request(path, **request_params))
  connection.connect if connection.respond_to?(:connect)

  # Only set instance variable if connected successfully
  @connection = connection
end

cookies()

# File actioncable/lib/action_cable/connection/test_case.rb, line 215
def cookies
  @cookie_jar ||= TestCookieJar.new
end

disconnect()

對待測試中的連線執行 disconnect

# File actioncable/lib/action_cable/connection/test_case.rb, line 208
def disconnect
  raise "Must be connected!" if connection.nil?

  connection.disconnect if connection.respond_to?(:disconnect)
  @connection = nil
end