test/websocket/api_channel_test.rb in bixby-common-0.4.7 vs test/websocket/api_channel_test.rb in bixby-common-0.4.8

- old
+ new

@@ -19,11 +19,11 @@ attr_reader :api_chan, :ws def setup @em_thread = Thread.new { EM.run{} } - @ws = mock() + @ws = mock("websocket") @api_chan = Bixby::WebSocket::APIChannel.new(ws, SampleHandler) end def test_open refute api_chan.connected? @@ -78,12 +78,16 @@ # test receiving a connect request on the channel json_req = JsonRequest.new("", {}) signed_json_req = SignedJsonRequest.new(json_req, "foo", "bar") req = Bixby::WebSocket::Request.new(signed_json_req, nil, "connect") - event = mock() + event = mock("event") event.expects(:data).once.returns(req.to_wire) SampleHandler.any_instance.expects(:connect).with(json_req, api_chan) + ws.expects(:send).once.with { |str| + res = Bixby::WebSocket::Message.from_wire(str) + !res.nil? && res.type == "rpc_result" && res.json_response.success? + } api_chan.message(event) end def test_close # close