Class: ActionCable::Channel::ConnectionStub

Inherits:
Object
  • Object
show all
Defined in:
actioncable/lib/action_cable/channel/test_case.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifiers = {}) ⇒ ConnectionStub

Returns a new instance of ConnectionStub.



54
55
56
57
58
59
60
61
62
63
64
65
# File 'actioncable/lib/action_cable/channel/test_case.rb', line 54

def initialize(identifiers = {})
  @server = ActionCable.server
  @transmissions = []

  identifiers.each do |identifier, val|
    define_singleton_method(identifier) { val }
  end

  @subscriptions = ActionCable::Connection::Subscriptions.new(self)
  @identifiers = identifiers.keys
  @logger = ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new)
end

Instance Attribute Details

#identifiersObject (readonly)

Returns the value of attribute identifiers.



50
51
52
# File 'actioncable/lib/action_cable/channel/test_case.rb', line 50

def identifiers
  @identifiers
end

#loggerObject (readonly)

Returns the value of attribute logger.



50
51
52
# File 'actioncable/lib/action_cable/channel/test_case.rb', line 50

def logger
  @logger
end

#serverObject (readonly)

Returns the value of attribute server.



50
51
52
# File 'actioncable/lib/action_cable/channel/test_case.rb', line 50

def server
  @server
end

#subscriptionsObject (readonly)

Returns the value of attribute subscriptions.



50
51
52
# File 'actioncable/lib/action_cable/channel/test_case.rb', line 50

def subscriptions
  @subscriptions
end

#transmissionsObject (readonly)

Returns the value of attribute transmissions.



50
51
52
# File 'actioncable/lib/action_cable/channel/test_case.rb', line 50

def transmissions
  @transmissions
end

Instance Method Details

#connection_identifierObject



71
72
73
# File 'actioncable/lib/action_cable/channel/test_case.rb', line 71

def connection_identifier
  @connection_identifier ||= connection_gid(identifiers.filter_map { |id| send(id.to_sym) if id })
end

#transmit(cable_message) ⇒ Object



67
68
69
# File 'actioncable/lib/action_cable/channel/test_case.rb', line 67

def transmit(cable_message)
  transmissions << cable_message.with_indifferent_access
end