File tree 2 files changed +42
-1
lines changed 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 19
19
gem "bake-test-external"
20
20
end
21
21
22
- gem "rack " , "~> 3.0.0 "
22
+ # gem "protocol-websocket ", path: "../protocol-websocket "
Original file line number Diff line number Diff line change 20
20
end
21
21
end
22
22
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
+
23
44
with '#close' do
24
45
it "can connect to a websocket server and close underlying client" do
25
46
Async do |task |
46
67
end
47
68
end
48
69
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
+
49
90
with 'missing support for websockets' do
50
91
let ( :app ) do
51
92
Protocol ::HTTP ::Middleware . for do |request |
You can’t perform that action at this time.
0 commit comments