Today I was looking around a way to override/patch Net::HTTP requests to a Sinatra app in tests…
Today I was looking around a way to override/patch Net::HTTP requests to a Sinatra app in tests, and happily found that the sham_rack gem exactly does that.
ShamRack.at(“rackup.xyz”).rackup do
run MyApp.new
endPut this snippet in your test_helper and all the calls to Net::HTTP inside your tests go through the Sinatra app. Neat.
I then wondered if someone has ported this to Perl, and voila: I did that almost an year ago.
my $psgi_app = sub { … }; # any PSGI compat app
LWP::Protocol::PSGI->register($psgi_app);and now all the LWP supporting libraries go to your app.
I really like moments like this.