Module: ActionCable::Connection::TestCase::Behavior
- Extended by:
- ActiveSupport::Concern
- Includes:
- Assertions, ActiveSupport::Testing::ConstantLookup
- Defined in:
- lib/action_cable/connection/test_case.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#connect(path = "/cable", cookies: {}, headers: {}, session: {}) ⇒ Object
Performs connection attempt (i.e. calls #connect method).
-
#disconnect ⇒ Object
Disconnect the connection under test (i.e. calls #disconnect).
Methods included from Assertions
Instance Method Details
#connect(path = "/cable", cookies: {}, headers: {}, session: {}) ⇒ Object
Performs connection attempt (i.e. calls #connect method).
Accepts request path as the first argument and cookies and headers as options.
179 180 181 182 183 184 185 186 187 |
# File 'lib/action_cable/connection/test_case.rb', line 179 def connect(path = "/cable", cookies: {}, headers: {}, session: {}) connection = self.class.connection_class.allocate connection.singleton_class.include(TestConnection) connection.send(:initialize, path, , headers, session) connection.connect if connection.respond_to?(:connect) # Only set instance variable if connected successfully @connection = connection end |
#disconnect ⇒ Object
Disconnect the connection under test (i.e. calls #disconnect)
190 191 192 193 194 195 |
# File 'lib/action_cable/connection/test_case.rb', line 190 def disconnect raise "Must be connected!" if connection.nil? connection.disconnect if connection.respond_to?(:disconnect) @connection = nil end |