1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actioncable/test/subscription_adapter/test_adapter_test.rb
2018-08-19 19:06:30 -04:00

47 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require "test_helper"
require_relative "common"
class ActionCable::SubscriptionAdapter::TestTest < ActionCable::TestCase
include CommonSubscriptionAdapterTest
def setup
super
@tx_adapter.shutdown
@tx_adapter = @rx_adapter
end
def cable_config
{ adapter: "test" }
end
test "#broadcast stores messages for streams" do
@tx_adapter.broadcast("channel", "payload")
@tx_adapter.broadcast("channel2", "payload2")
assert_equal ["payload"], @tx_adapter.broadcasts("channel")
assert_equal ["payload2"], @tx_adapter.broadcasts("channel2")
end
test "#clear_messages deletes recorded broadcasts for the channel" do
@tx_adapter.broadcast("channel", "payload")
@tx_adapter.broadcast("channel2", "payload2")
@tx_adapter.clear_messages("channel")
assert_equal [], @tx_adapter.broadcasts("channel")
assert_equal ["payload2"], @tx_adapter.broadcasts("channel2")
end
test "#clear deletes all recorded broadcasts" do
@tx_adapter.broadcast("channel", "payload")
@tx_adapter.broadcast("channel2", "payload2")
@tx_adapter.clear
assert_equal [], @tx_adapter.broadcasts("channel")
assert_equal [], @tx_adapter.broadcasts("channel2")
end
end