Module: ActionCable::Connection::TestCase::Behavior
- Extended by:
- ActiveSupport::Concern
- Includes:
- Assertions, ActiveSupport::Testing::ConstantLookup
- Included in:
- ActionCable::Connection::TestCase
- Defined in:
- lib/action_cable/connection/test_case.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- DEFAULT_PATH =
"/cable"
Instance Method Summary collapse
-
#connect(path = ActionCable.server.config.mount_path, **request_params) ⇒ Object
Performs connection attempt to exert #connect on the connection under test.
- #cookies ⇒ Object
-
#disconnect ⇒ Object
Exert #disconnect on the connection under test.
Methods included from Assertions
Instance Method Details
#connect(path = ActionCable.server.config.mount_path, **request_params) ⇒ Object
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)
195 196 197 198 199 200 201 202 203 204 205 |
# File '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 ⇒ Object
215 216 217 |
# File 'lib/action_cable/connection/test_case.rb', line 215 def @cookie_jar ||= TestCookieJar.new end |
#disconnect ⇒ Object
Exert #disconnect on the connection under test.
208 209 210 211 212 213 |
# File '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 |