Sha256: c1109aee2917f158ab210c6893418fda20ea5ece2f6edcc3fc3c55fbd6717e33

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

# frozen_string_literal: true

module ActionCable
  module Testing
    # Enables Rails 6 compatible API via Refinements.
    #
    # Use this to write Rails 6 compatible tests (not every Rails 6 API
    # could be backported).
    #
    # Usage:
    #   # my_test.rb
    #   require "test_helper"
    #
    #   using ActionCable::Testing::Syntax
    module Rails6
      begin
        # Has been added only after 6.0.0.beta1
        unless ActionCable::Channel.respond_to?(:serialize_broadcasting)
          refine ActionCable::Channel::Broadcasting::ClassMethods do
            def broadcasting_for(model)
              super([channel_name, model])
            end
          end
        end

        SUPPORTED = true
      rescue TypeError
        warn "Your Ruby version doesn't suppport Module refinements. " \
             "Rails 6 compatibility refinement could not be applied"

        SUPPORTED = false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
action-cable-testing-0.5.0 lib/action_cable/testing/rails_six.rb