How can I test ActionCable channels using RSpec?

后端 未结 4 1532
刺人心
刺人心 2021-01-01 19:25

I am wondering how to test ActionCable channels.

Let\'s say I have the following chat channel:

class ChatChannel < ApplicationCable::Channel
  def s         


        
4条回答
  •  长情又很酷
    2021-01-01 19:47

    Now Rails 6 includes the action-cable-test gem

    So there is no need to add a gem. You can do either

    assert_has_stream "chat_1"
    

    or, with rspec:

    expect(subscription).to have_stream_from("chat_1") 
    

提交回复
热议问题