in reply to OK to Include CHI File Data in module Tests ?
my $override3 = Sub::Override->new('Mojo::Transaction::res', sub { my $res2 = Mojo::Message::Response->new ; $res2->code( 200 ); $res2->body( "TESTED FINE" ); return $res2; });
I also came across Mojo::UserAgent::Mockable but it took quite a while to install and seemed to introduce a lot of new dependencies so I put that on the backburner - may be worth a look at again in the future.
It also allows you to continue with new overrides as you progress but one little thing that caught me out was that each override needs to be assigned to a distinct variable and you cannot re-use the same one. I expect that this could be avoided by blocking each instance as described in the docs but the approach I'm using now serves my needs well.
As I continue to work at improving my test writing I'll def. use this injection approach or a refinement of it going forward.
|
|---|