File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 1919 gem "bake-test-external"
2020end
2121
22- gem "rack " , "~> 3.0.0 "
22+ # gem "protocol-websocket ", path: "../protocol-websocket "
Original file line number Diff line number Diff line change 2020 end
2121 end
2222
23+ with '#send_close' do
24+ it "can read incoming messages and then close" do
25+ connection = Async ::WebSocket ::Client . connect ( client_endpoint )
26+ 3 . times do
27+ connection . send_text ( "Hello World!" )
28+ end
29+
30+ # This informs the server we are done echoing messages:
31+ connection . send_close
32+
33+ # Collect all the echoed messages:
34+ messages = [ ]
35+ while message = connection . read
36+ messages << message
37+ end
38+
39+ expect ( messages . size ) . to be == 3
40+ expect ( connection ) . to be ( :closed? )
41+ end
42+ end
43+
2344 with '#close' do
2445 it "can connect to a websocket server and close underlying client" do
2546 Async do |task |
4667 end
4768 end
4869
70+ with "#close(1001)" do
71+ let ( :app ) do
72+ Protocol ::HTTP ::Middleware . for do |request |
73+ Async ::WebSocket ::Adapters ::HTTP . open ( request ) do |connection |
74+ connection . send_text ( "Hello World!" )
75+ connection . close ( 1001 )
76+ end
77+ end
78+ end
79+
80+ it 'closes with custom error' do
81+ connection = Async ::WebSocket ::Client . connect ( client_endpoint )
82+ message = connection . read
83+
84+ expect do
85+ connection . read
86+ end . to raise_exception ( Protocol ::WebSocket ::Error ) . and ( have_attributes ( code : be == 1001 ) )
87+ end
88+ end
89+
4990 with 'missing support for websockets' do
5091 let ( :app ) do
5192 Protocol ::HTTP ::Middleware . for do |request |
You can’t perform that action at this time.
0 commit comments