From aa1e75f071e0c729b217e42a93b742ace0ba6b39 Mon Sep 17 00:00:00 2001 From: jrconlin Date: Tue, 31 Jul 2018 16:21:18 -0700 Subject: [PATCH] feature: allow TestServer to open a websocket on any URL * added `TestServer::ws_at(uri_str)` * modified `TestServer::ws()` to call `self.ws_at("/")` to preserve behavior Closes #432 --- src/test.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/test.rs b/src/test.rs index f94732dd7..2ec7a98d8 100644 --- a/src/test.rs +++ b/src/test.rs @@ -207,15 +207,23 @@ impl TestServer { self.rt.block_on(fut) } - /// Connect to websocket server - pub fn ws( + /// Connect to websocket server at a given path + pub fn ws_at( &mut self, + path: &str, ) -> Result<(ws::ClientReader, ws::ClientWriter), ws::ClientError> { - let url = self.url("/"); + let url = self.url(path); self.rt .block_on(ws::Client::with_connector(url, self.conn.clone()).connect()) } + /// Connect to a websocket server + pub fn ws( + &mut self, + ) -> Result<(ws::ClientReader, ws::ClientWriter), ws::ClientError> { + self.ws_at("/") + } + /// Create `GET` request pub fn get(&self) -> ClientRequestBuilder { ClientRequest::get(self.url("/").as_str())