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: {}) ⇒ 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: {}) ⇒ Object
Performs connection attempt (i.e. calls #connect method).
Accepts request path as the first argument and cookies and headers as options.
170 171 172 173 174 175 176 177 178 |
# File 'lib/action_cable/connection/test_case.rb', line 170 def connect(path = "/cable", cookies: {}, headers: {}) connection = self.class.connection_class.allocate connection.singleton_class.include(TestConnection) connection.send(:initialize, path, , headers) 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)
181 182 183 184 185 186 |
# File 'lib/action_cable/connection/test_case.rb', line 181 def disconnect raise "Must be connected!" if connection.nil? connection.disconnect if connection.respond_to?(:disconnect) @connection = nil end |