Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I test WebSockets (using Pusher) with RSpec?

I am looking for successful methods for testing WebSocket push events using RSpec. My application currently uses Pusher App, but more broad information relating to WebSockets is most welcome.

Ideally, I'd like something as simple as:

  parsed_body = JSON.parse(response.body)
  parsed_body["error"].should == "xyzError"

...which I have found to be an awesomely convenient way to test for JSON responses.

Sincere thanks in advance.

like image 906
tbaums Avatar asked Apr 25 '11 18:04

tbaums


People also ask

Does pusher use WebSockets?

Pusher Channels is a hosted WebSockets solution for building powerful realtime interactive apps. We've solved complex realtime infrastructure so you don't have to. Pusher Channels is a hosted WebSockets solution for building powerful realtime interactive apps.


2 Answers

WebSocket server is remote service. It's good way to stub any requests to remote services and mock responses from these ones.

like image 165
Alexander Sulim Avatar answered Sep 30 '22 22:09

Alexander Sulim


Tristan Dunn came out with this awesome gem: https://github.com/tristandunn/pusher-fake

like image 21
Brian Armstrong Avatar answered Sep 30 '22 23:09

Brian Armstrong