开发者

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

开发者 https://www.devze.com 2023-02-28 09:35 出处:网络
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.

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.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消