Skip to Content Skip to Search
Namespace
Methods
C
D
T
Included Modules

Constants

DEFAULT_PATH = "/cable"
 

Attributes

[R] connection
[R] socket
[R] testserver

Instance Public methods

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

Performs connection attempt to exert connect on the connection under test.

Accepts request path as the first argument and the following request options:

  • params – URL parameters (Hash)

  • headers – request headers (Hash)

  • session – session data (Hash)

  • env – additional Rack env configuration (Hash)

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

  @socket = TestSocket.new(TestSocket.build_request(path, **request_params, cookies: cookies))
  @testserver = Connection::TestServer.new(server)
  connection = self.class.connection_class.new(@testserver, socket)
  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 314
def cookies
  @cookie_jar ||= TestCookieJar.new
end

disconnect()

Exert disconnect on the connection under test.

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

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

transmissions()

# File actioncable/lib/action_cable/connection/test_case.rb, line 318
def transmissions
  socket&.transmissions || []
end