Closed nirvdrum closed 3 years ago
wiremock-rs
currently supports request recording (see https://docs.rs/wiremock/0.5.2/wiremock/struct.MockServerBuilder.html#method.disable_request_recording and https://docs.rs/wiremock/0.5.2/wiremock/struct.MockServer.html#method.received_requests) but it does not support what is commonly referred to as "Record & Playback" because it would require persisting state outside of a test run (using the simplest implementation strategy, you'd also need DNS tricks for a more advanced one).
It is definitely possible to build the functionality using wiremock-rs
, but I don't see that landing in the crate itself right now.
A project you might be interested into is stubr
, which might fulfill your needs (cc @beltram).
Thanks. I'll close this out then. I hadn't come across stubr (or wiremock for that matter) before. I'll have to spend some time with each and decide where to go from there.
In case anyone comes across this issue, there's now a tracking issue for this functionality in stubr.
Is record and playback in scope for this project? I'm after something like VCR for Ruby, where real external requests can be made and recorded. Subsequent tests will load up the previously recorded requests and if a request matches exactly, its response will be returned to the client. If no such request can be found (e.g., the client changed something since the last recording), then a 404 will result.
In Ruby, it's achieved by mocking out the client. I realize this project is a bit different. What I'm proposing is the WireMock server would function as a proxy when recording and disallow external connections when in playback mode.
I'm currently looking at ways to achieve this with WireMock. But, if the tool just fundamentally isn't designed for that, it'd be helpful to know. If I can get it working, I'm happy to contribute it back.