Skip to content

ClientCloseDecorator#close does not accept arguments #50

Closed
@PeterRunich

Description

@PeterRunich

Hi again!
I opened this #46 issue some time ago.
Today i found a small bug, we forgot to forward arguments in the delegator #close method.

class ClientCloseDecorator < SimpleDelegator
def initialize(client, connection)
@client = client
super(connection)
end
def close
super
if @client
@client.close
@client = nil
end
end
end

Here are the arguments I was talking about
https://github.com/socketry/protocol-websocket/blob/58f0d15c6c5b44d224fd7a6eb237ce331bd8a587/lib/protocol/websocket/connection.rb#L62-L63

PeterRunich@3e7698d
i fixed it, but i didn't figure out how to write a test.
i think it should look similar like this test

it "can connect to a websocket server and close underlying client" do
Async do |task|
connection = Async::WebSocket::Client.connect(client_endpoint)
connection.send_text("Hello World!")
message = connection.read
expect(message.to_str).to be == "Hello World!"
connection.close
expect(task.children).to be(:empty?)
end.wait
end

but i didn't figured out how to expect "moment of closing" on the server and comparing close codes, it would be nice if you explain it (or if it takes less of your time, you can write it yourself :) )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions