Websocket Rails Rspec tests

I have a problem to test message triggering from Controller after dispatching an event. Here is my Rspec test:

  describe "product.delete" do
    it "should trigger any message" do
      event = create_event("product.delete", :data => "some")
      expect(event.dispatch).to trigger_message :any

Here is my Event.rb file where event routing is specified:

namespace :product do
    subscribe :delete, :to => ProductController, :with_method => :delete_product

Then my Controller code:

class ProductController < WebsocketRails::BaseController

  def delete_product
    WebsocketRails[:product].trigger :data => "something"


And finally here is what I am getting after tests run:

    should trigger any message (FAILED - 1)


  1) product.delete should trigger any message
     Failure/Error: expect(event.dispatch).to trigger_message :any
       expected product.delete to trigger message with some data, instead it did not trigger any message
     # ./spec/requests/product.rb:11:in `block (3 levels) in <top (required)>'

I am trying to strictly follow guide on websocket-rails github wiki pages. But definetely there is something I am doing wrong. Can anybody look at my code and advice , please.

Source: New Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.