> On Jan 22, 2020, at 12:25 PM, Felipe Gasper <
fel...@felipegasper.com> wrote:
>
> Hi Dan,
>
> Thank you for your response!
>
> So, maybe what I need isn’t Test::Mojo. I have:
>
> -----
> package t::MockApp;
>
> use Mojo::Base -strict;
>
> use Mojolicious::Lite;
>
> websocket '/my-websocket-endpoint' => sub { ... }
> -----
>
> … and I’d like my tested $ua (Mojo::UserAgent->new()) to call logic defined in t::MockApp, rather than going out to the real world. I’d also like to define other mock server classes and have other parts of the test use those classes instead.
>
> I’ve tried “$ua->server->app($TEST_MOJO_APP) if $TEST_MOJO_APP” in my tested code, but that doesn’t seem to work. (The client times out rather than connecting to my WS server logic.)
Follow-up: I have this working but only if I alter the tested logic to give a relative URL rather than an absolute URL to $tx->websocket().
Is there any tooling in place for handling absolute URLs in such setups? I can override $tx->websocket() but wonder if there’s any ready-made sugar for this.