It seems there currently is no easy (or hard even) way to unit test ActionCable channels, which makes me very sad. There is a bit of logic in my Channels which would be very nice to cover with tests. Ideally, I’d like to have something like this:
it "rejects connection if current_user isn't the owner of the contract" do
channel = create_channel(:contract)
sign_in @unauthorized_user
expect(channel.subscribe(params: {contract_id: 1}).to reject_connection
end
Is this something even remotely likely to happen? I googled very hard and I also checked every ActionCable issue (opened & closed) and couldn’t find anyone asking this question.