Rails Rspec 测试控制器是否触发了 Websockets 事件

Rails Rspec test that a controller has triggered Websockets event

在我的控制器中,我有以下代码在更新方法中触发 websockets 事件:

WebsocketRails[recipient.id].trigger "new_activity", "Shared" if recipient.online?

如何测试我的控制器是否触发了此事件?

expect(triggerable = double).to receive(:trigger)
  .with('new_activity', 'Shared')
allow(WebsocketRails).to receive(:[]).and_return(triggerable)
get :myroute