instance method stub_connection

Ruby on Rails edge

Since edge

Signature

stub_connection(server: ActionCable.server, **identifiers)

Set up test connection with the specified identifiers:

class ApplicationCable < ActionCable::Connection::Base
  identified_by :user, :token
end

stub_connection(user: users[:john], token: 'my-secret-token')

Parameters

server key = ActionCable.server
identifiers keyrest
Source
# File actioncable/lib/action_cable/channel/test_case.rb, line 208
        def stub_connection(server: ActionCable.server, **identifiers)
          @socket = Connection::TestSocket.new(Connection::TestSocket.build_request(ActionCable.server.config.mount_path || "/cable"))
          @testserver = Connection::TestServer.new(server)
          @connection = self.class.connection_class.new(testserver, socket).tap do |conn|
            identifiers.each do |identifier, val|
              conn.public_send("#{identifier}=", val)
            end
          end
        end

Defined in actioncable/lib/action_cable/channel/test_case.rb line 208 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionCable::Channel::ChannelExt::TestCase::Behavior

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close