Sha256: 2067b89a84fa263d72bff207444b935105ea792929e864ce8ac71b1b48467dbe

Contents?: true

Size: 765 Bytes

Versions: 3

Compression:

Stored size: 765 Bytes

Contents

# frozen_string_literal: true

# This file contains patches to Action Cable testing modules

# Trigger autoload (if constant is defined)
begin
  ActionCable::Channel::TestCase # rubocop:disable Lint/Void
  ActionCable::Connection::TestCase
rescue NameError
  return
end

ActionCable::Channel::ChannelStub.prepend(Module.new do
  def subscribe_to_channel
    handle_subscribe
  end
end)

ActionCable::Channel::ConnectionStub.prepend(Module.new do
  def socket
    @socket ||= AnyCable::Socket.new(env: AnyCable::Env.new(url: "http://test.host", headers: {}))
  end

  alias_method :anycable_socket, :socket
end)

ActionCable::Connection::TestConnection.prepend(Module.new do
  def initialize(request)
    @request = request
    @cached_ids = {}
    super
  end
end)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
anycable-rails-1.2.1 lib/anycable/rails/actioncable/testing.rb
anycable-rails-1.2.0 lib/anycable/rails/actioncable/testing.rb
anycable-rails-1.1.4 lib/anycable/rails/actioncable/testing.rb