I have been recently developing Message Queue using Rabbitmq and Sneakers Workers. I had a look on this guide https://github.com/jondot/sneakers/wiki/Testing-Your-Worker
But I still have no idea about how to develop the tests for them. I'm very grateful if there are any advices.
 
                        
Suggested guide contains
Sneakers::Testingmodule to store all published messages. In order to do that you need to patch/stub methodSneakers::Publisher#publishto save published messages intoSneakers::Testing.messages_by_queue. And then use that data for expectations or somehow supply the data to worker classes.Probably in most cases you just need inline execution for delayed jobs in specs. So can just patch
Sneakers::Publisher#publishto get worker class by queue name and call itsworkmethod with received payload message. Initial setup:Or stub method for one worker in a spec:
Or add a shared context for convenient way to enable inline jobs execution:
Then just add
include_context 'sneakers_publish_inline'in spec where you need inline jobs execution.