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 Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
-
#testserver ⇒ Object
readonly
Returns the value of attribute testserver.
Instance Method Summary collapse
-
#connect(path = ActionCable.server.config.mount_path, server: ActionCable.server, **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.
- #transmissions ⇒ Object
Methods included from Assertions
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
252 253 254 |
# File 'lib/action_cable/connection/test_case.rb', line 252 def connection @connection end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
252 253 254 |
# File 'lib/action_cable/connection/test_case.rb', line 252 def socket @socket end |
#testserver ⇒ Object (readonly)
Returns the value of attribute testserver.
252 253 254 |
# File 'lib/action_cable/connection/test_case.rb', line 252 def testserver @testserver end |
Instance Method Details
#connect(path = ActionCable.server.config.mount_path, server: ActionCable.server, **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)
262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/action_cable/connection/test_case.rb', line 262 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: )) @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 ⇒ Object
282 283 284 |
# File 'lib/action_cable/connection/test_case.rb', line 282 def @cookie_jar ||= TestCookieJar.new end |
#disconnect ⇒ Object
Exert #disconnect on the connection under test.
275 276 277 278 279 280 |
# File 'lib/action_cable/connection/test_case.rb', line 275 def disconnect raise "Must be connected!" if connection.nil? connection.disconnect if connection.respond_to?(:disconnect) @connection = nil end |
#transmissions ⇒ Object
286 287 288 |
# File 'lib/action_cable/connection/test_case.rb', line 286 def transmissions socket&.transmissions || [] end |