lostisland / faraday

Simple, but flexible HTTP client library, with support for multiple backends.
https://lostisland.github.io/faraday
MIT License
5.7k stars 971 forks source link

Is it possible when stubbing to execute the original request? #1562

Closed apotonick closed 1 month ago

apotonick commented 1 month ago

Hi, first of all thanks for Faraday, I love the gem!

As the title says, is it possible to configure Faraday's test adapter in a way that only configured requests return their stub response, and unmatched proceed as real requests?

iMacTia commented 1 month ago

Hi @apotonick that's not currently possible because the test adapter doesn't ship with an underlying http library like the other adapters (e.g. :net_http -> Net::HTTP).

I'm not sure about what exactly you're trying to achieve here, but if you're writing tests for your application and you want to test some Faraday client you've built, you're almost always better using some other solution than the :test adapter, like Webmock or VCR, which both allow what you're trying to achieve.

The :test adapter is mostly there for assisting in the development of Faraday middleware.

Hopefully this helps, but happy to continue the discussion if you have any other inputs 🙂

apotonick commented 1 month ago

Hi @iMacTia, wow, that was a fast response, thanks! :green_heart:

Okay, that makes sense, I didn't know that the :test adapter is more of an internal concept. I will check out webmock and post my findings here! Thanks again :beers: