ruby on rails - How can I test ActionCable channels using RSpec? -


i wondering testing actioncable channels.

let's have 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 db , defines 2 streams broadcasted across channel, details not important since question more general one:

  • how can set test test logic involved subscribing channel?

rspec provides lot of helper methods , various utilities when testing similar interactions controller action, find regarding rspec , actioncable.

you want wait* https://github.com/rails/rails/pull/23211 merged. adds actioncable::testcase. once that's merged, expect rspec-rails team part: https://github.com/rspec/rspec-rails/issues/1606

* waiting optional; can not wait , based own work on "work in progress" , find solution works right now.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -