class Amber::Testing::TestWebSocket

Overview

Wraps a WebSocket connection for use in tests. Tracks sent and received messages and provides a simple interface for interacting with WebSocket channels.

Defined in:

amber/testing/websocket_helpers.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(path : String) #

[View source]

Instance Method Detail

def close #

Close the WebSocket connection and shut down the test server.


[View source]
def is_closed? : Bool #

[View source]
def list_of_received_messages : Array(String) #

Messages received from the server.


[View source]
def list_of_sent_messages : Array(String) #

Messages sent by the test.


[View source]
def receive : String | Nil #

Return the most recently received message, or nil if none.


[View source]
def send(message : String) #

Send a message string through the WebSocket.


[View source]
def send_json(event : String, topic : String, payload = {} of String => String) #

Send a JSON-structured message through the WebSocket.


[View source]