8000 Allow passing through arguments to #close. · zarqman/async-websocket@7eb22b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7eb22b6

Browse files
committed
Allow passing through arguments to #close.
1 parent cff18c0 commit 7eb22b6

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
8000
-12
lines changed

lib/async/websocket/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def initialize(client, connection)
4141
super(connection)
4242
end
4343

44-
def close
45-
super
44+
def close(...)
45+
super(...)
4646

4747
if @client
4848
@client.close

test/async/websocket/client.rb

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,30 @@
2020
end
2121
end
2222

23-
it "can connect to a websocket server and close underlying client" do
24-
Async do |task|
25-
connection = Async::WebSocket::Client.connect(client_endpoint)
26-
connection.send_text("Hello World!")
27-
message = connection.read
28-
expect(message.to_str).to be == "Hello World!"
29-
30-
connection.close
31-
expect(task.children).to be(:empty?)
32-
end.wait
23+
with '#close' do
24+
it "can connect to a websocket server and close underlying client" do
25+
Async do |task|
26+
connection = Async::WebSocket::Client.connect(client_endpoint)
27+
connection.send_text("Hello World!")
28+
message = connection.read
29+
expect(message.to_str).to be == "Hello World!"
30+
31+
connection.close
32+
expect(task.children).to be(:empty?)
33+
end.wait
34+
end
35+
36+
it "can connect to a websocket server and close underlying client with an error code" do
37+
Async do |task|
38+
connection = Async::WebSocket::Client.connect(client_endpoint)
39+
connection.send_text("Hello World!")
40+
message = connection.read
41+
expect(message.to_str).to be == "Hello World!"
42+
43+
connection.close(Protocol::WebSocket::Error::GOING_AWAY, "Bye!")
44+
expect(task.children).to be(:empty?)
45+
end.wait
46+
end
3347
end
3448

3549
with 'missing support for websockets' do

0 commit comments

Comments
 (0)
0