Module: ActionCable::Connection::TestCase::Behavior
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::ActiveSupport::Concern
|
|
Instance Chain:
|
|
Defined in: | actioncable/lib/action_cable/connection/test_case.rb |
Constant Summary
-
DEFAULT_PATH =
# File 'actioncable/lib/action_cable/connection/test_case.rb', line 145"/cable"
Class Method Summary
::ActiveSupport::Concern
- Extended
class_methods | Define class methods from given block. |
included | Evaluate given block in context of base class, so that you can write class macros here. |
prepended | Evaluate given block in context of base class, so that you can write class macros here. |
append_features, prepend_features |
Instance Method Summary
-
#connect(path = ActionCable.server.config.mount_path, **request_params)
Performs connection attempt to exert #connect on the connection under test.
- #cookies
-
#disconnect
Exert #disconnect on the connection under test.
- #build_test_request(path, params: nil, headers: {}, session: {}, env: {}) private
::ActionCable::Connection::Assertions
- Included
#assert_reject_connection | Asserts that the connection is rejected (via |
DSL Calls
included
[ GitHub ]150 151 152 153 154 155 156
# File 'actioncable/lib/action_cable/connection/test_case.rb', line 150
included do class_attribute :_connection_class attr_reader :connection ActiveSupport.run_load_hooks(:action_cable_connection_test_case, self) end
Instance Method Details
#build_test_request(path, params: nil, headers: {}, session: {}, env: {}) (private)
[ GitHub ]# File 'actioncable/lib/action_cable/connection/test_case.rb', line 220
def build_test_request(path, params: nil, headers: {}, session: {}, env: {}) wrapped_headers = ActionDispatch::Http::Headers.from_hash(headers) uri = URI.parse(path) query_string = params.nil? ? uri.query : params.to_query request_env = { "QUERY_STRING" => query_string, "PATH_INFO" => uri.path }.merge(env) if wrapped_headers.present? ActionDispatch::Http::Headers.from_hash(request_env).merge!(wrapped_headers) end TestRequest.create(request_env).tap do |request| request.session = session.with_indifferent_access request. = end end
#connect(path = ActionCable.server.config.mount_path, **request_params)
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)
# File 'actioncable/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
[ GitHub ]# File 'actioncable/lib/action_cable/connection/test_case.rb', line 215
def @cookie_jar ||= TestCookieJar.new end
#disconnect
Exert #disconnect
on the connection under test.
# File 'actioncable/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