跳至内容 跳至搜索

Action Cable 的测试适配器

测试适配器仅应在测试中使用。与 ActionCable::TestHelper 一起,它是一个测试 Rails 应用程序的出色工具。

要使用测试适配器,请在 config/cable.yml 文件中将 adapter 值设置为 test

注意:Test 适配器扩展了 ActionCable::SubscriptionAdapter::Async 适配器,因此它也可以在系统测试中使用。

方法
B
C

实例公共方法

broadcast(channel, payload)

# File actioncable/lib/action_cable/subscription_adapter/test.rb, line 15
def broadcast(channel, payload)
  broadcasts(channel) << payload
  super
end

broadcasts(channel)

# File actioncable/lib/action_cable/subscription_adapter/test.rb, line 20
def broadcasts(channel)
  channels_data[channel] ||= []
end

clear()

# File actioncable/lib/action_cable/subscription_adapter/test.rb, line 28
def clear
  @channels_data = nil
end

clear_messages(channel)

# File actioncable/lib/action_cable/subscription_adapter/test.rb, line 24
def clear_messages(channel)
  channels_data[channel] = []
end