7

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.

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

2

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

1 Comment

Could you give an example of how one would stub the requests?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.