File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 44
44
Async ::WebSocket ::Client . connect ( client_endpoint ) { }
45
45
end . to raise_exception ( Async ::WebSocket ::ProtocolError , message : be =~ /Failed to negotiate connection/ )
46
46
end
47
- end
47
+ end
48
+
49
+ with "server close condition" do
50
+ let ( :close_condition ) { Async ::Condition . new }
51
+
52
+ let ( :app ) do
53
+ Protocol ::HTTP ::Middleware . for do |request |
54
+ Async ::WebSocket ::Adapters ::HTTP . open ( request ) do |connection |
55
+ while connection . read ; end
56
+ rescue Errno ::EPIPE => e
57
+ connection . close
58
+
59
+ close_condition . signal e . cause . code
60
+ end
61
+ end
62
+ end
63
+
64
+ let ( :timeout ) { nil }
65
+
66
+ it 'closes with custom error' do
67
+ expectation = Async { expect ( close_condition . wait ) . to be == 1001 }
68
+
69
+ connection = Async ::WebSocket ::Client . connect ( client_endpoint )
70
+ connection . close 1001
71
+
72
+ expectation . wait
73
+ end
74
+ end
48
75
end
49
76
50
77
describe Async ::WebSocket ::Client do
You can’t perform that action at this time.
0 commit comments