title: How can I test ActionCable channels using RSpec?
body: <p>I am wondering how to test ActionCable channels.</p>
  <p>Let's say I have the following chat channel:</p>
  <pre><code>class ChatChannel &lt; ApplicationCable::Channel
    def subscribed
      current_user.increment!(:num_of_chats)
  
      stream_from &quot;chat_#{params[:chat_id]}&quot;
      stream_from &quot;chat_stats_#{params[:chat_id]}&quot;
    end
  end
  </code></pre>
  <p>The <code>subscribed</code> 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:</p>
  <ul>
  <li>How can I set up a test to test the logic involved by subscribing to
  this channel?</li>
  </ul>
  <p>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.</p>