Sha256: c61a7cc8cfa351bffce12472961a0c91dfd1c296e8cd323527d206ff90004d86
Contents?: true
Size: 812 Bytes
Versions: 19
Compression:
Stored size: 812 Bytes
Contents
require 'helper' module Bixby module Test module WebSocket class TestAsyncResponse < TestCase def test_block sync_response = nil cb_response = nil res = Bixby::WebSocket::AsyncResponse.new("1234") do |r| cb_response = r end assert res assert_equal "1234", res.id refute res.completed? # start a thread waiting on the response to be writ ten t = Thread.new { sync_response = res.response } assert t.alive? # small sleep here, otherwise execution will continue too quickly, before the thread starts assert_nil t.join(0.001) # now write it, thread should complete & callback will fire res.response = "hi" t.join refute t.alive? assert_equal "hi", cb_response assert_equal "hi", sync_response end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems