Module: ActionCable::Connection::TestCase::Behavior

Extended by:
ActiveSupport::Concern
Includes:
Assertions, ActiveSupport::Testing::ConstantLookup
Included in:
ActionCable::Channel::TestCase::Behavior, ActionCable::Connection::TestCase
Defined in:
lib/action_cable/connection/test_case.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from Assertions

#assert_reject_connection

Instance Method Details

#connect(path = "/cable", cookies: {}, headers: {}) ⇒ Object

Performs connection attempt (i.e. calls #connect method).

Accepts request path as the first argument and cookies and headers as options.



177
178
179
180
181
182
183
184
185
# File 'lib/action_cable/connection/test_case.rb', line 177

def connect(path = "/cable", cookies: {}, headers: {})
  connection = self.class.connection_class.allocate
  connection.singleton_class.include(TestConnection)
  connection.send(:initialize, path, cookies, headers)
  connection.connect if connection.respond_to?(:connect)

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

#disconnectObject

Disconnect the connection under test (i.e. calls #disconnect)



188
189
190
191
192
193
# File 'lib/action_cable/connection/test_case.rb', line 188

def disconnect
  raise "Must be connected!" if connection.nil?

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