Class: ActionCable::Connection::TestSocket
- Inherits:
-
Object
- Object
- ActionCable::Connection::TestSocket
- Defined in:
- lib/action_cable/connection/test_case.rb
Defined Under Namespace
Classes: Request
Instance Attribute Summary collapse
-
#closed ⇒ Object
readonly
Returns the value of attribute closed.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#transmissions ⇒ Object
readonly
Returns the value of attribute transmissions.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(request) ⇒ TestSocket
constructor
A new instance of TestSocket.
- #transmit(data) ⇒ Object
Constructor Details
#initialize(request) ⇒ TestSocket
Returns a new instance of TestSocket.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/action_cable/connection/test_case.rb', line 85 def initialize(request) inner_logger = ActiveSupport::Logger.new(StringIO.new) tagged_logging = ActiveSupport::TaggedLogging.new(inner_logger) @logger = ActionCable::Server::TaggedLoggerProxy.new(tagged_logging, tags: []) @request = request @env = request.env @connection = nil @closed = false @transmissions = [] end |
Instance Attribute Details
#closed ⇒ Object (readonly)
Returns the value of attribute closed.
59 60 61 |
# File 'lib/action_cable/connection/test_case.rb', line 59 def closed @closed end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
59 60 61 |
# File 'lib/action_cable/connection/test_case.rb', line 59 def env @env end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
59 60 61 |
# File 'lib/action_cable/connection/test_case.rb', line 59 def logger @logger end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
59 60 61 |
# File 'lib/action_cable/connection/test_case.rb', line 59 def request @request end |
#transmissions ⇒ Object (readonly)
Returns the value of attribute transmissions.
59 60 61 |
# File 'lib/action_cable/connection/test_case.rb', line 59 def transmissions @transmissions end |
Class Method Details
.build_request(path, params: nil, headers: {}, session: {}, env: {}, cookies: nil) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/action_cable/connection/test_case.rb', line 62 def build_request(path, params: nil, headers: {}, session: {}, env: {}, cookies: nil) 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 Request.create(request_env).tap do |request| request.session = session.with_indifferent_access request. = end end |
Instance Method Details
#close ⇒ Object
100 101 102 |
# File 'lib/action_cable/connection/test_case.rb', line 100 def close @closed = true end |
#transmit(data) ⇒ Object
96 97 98 |
# File 'lib/action_cable/connection/test_case.rb', line 96 def transmit(data) @transmissions << data.with_indifferent_access end |