I am wondering how to test ActionCable channels.
Let's say I have the following chat channel:
class ChatChannel < ApplicationCable::Channel
def subscribed
current_user.increment!(:num_of_chats)
stream_from "chat_#{params[:chat_id]}"
stream_from "chat_stats_#{params[:chat_id]}"
end
end
The subscribed
method updates the db and defines two streams to be broadcasted across the channel, but the details are not very important since my question is a more general one:
- How can I set up a test to test the logic involved by subscribing to this channel?
RSpec provides a lot of helper methods and various utilities when testing similar interactions like controller actions, but I couldn't find anything regarding RSpec and ActionCable.