httpmock icon indicating copy to clipboard operation
httpmock copied to clipboard

Overwrite mocks

Open RichoDemus opened this issue 1 year ago • 1 comments

I'd like the ability to overwrite a previously defined mock if I define a new one with the same "when" like this:

self.mock_server.mock(|when, then| { when.method(GET) .path("/api/")); then.status(200).json_body(json!({ "msg": "A" })); });

now a call to /api returns msg: A

then I do self.mock_server.mock(|when, then| { when.method(GET) .path("/api/")); then.status(200).json_body(json!({ "msg": "B" })); });

now a call to /api returns msg:B

currently it seems like the only way is to delete the old mock first which is a bit cumbersome imo

RichoDemus avatar Oct 20 '23 12:10 RichoDemus

I see, thanks for your suggestion!

alexliesenfeld avatar Jan 06 '24 12:01 alexliesenfeld