-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repeated GET calls not being played back properly #9
Comments
So, I've traced it down to WebMock. When we set up the episodes to be stubbed by WebMock, we call The problem occurs when WebMock tries to find the matching stub for any given request. WebMock will sequentially go through all stubs attempting to find a match. Since we are performing identical requests, the first stub will match the second request. Will see if there's an easy way to have WebMock "consume" a stub after the first time it matches a request. |
Hi Alistair, if I understood this correctly you expect different results when you make the same request? However, you can control this behaviour with different ways, like switching to another cassette (and therefore another result) for example or setting an But maybe I just misunderstood your issue!? |
Hi, Alexander, When I use If I issue the same GET request a second time, that then gets recorded as another request, whether the server responds with the same response or not (in my case, since I POST in between GETs, I'm expecting a new value). I can put up a Ruby gist to demonstrate. |
https://gist.github.com/aisrael/c389569b83ac2c12e1cbc7aec1032a5a I think in this case hi8 essentially performs caching of HTTP requests and matching based on the "signature". Identical request signatures then yield the same result. But, as demonstrated, this is not necessarily the desired (nor the expected, based on |
In that case the easiest solution could be to set the |
That might work if the Web service being mocked would just ignore the request counter, right? I mean, if I just append Anyway, I remember now this is really a limitation of current Webmock so if they don't act on the ticket I opened, I'm inclined to just patch Webmock myself. |
Just waiting on manastech/webmock.cr#21 Meanwhile, we're using my fork. |
Background
Am writing a spec for an API client. To verify the client is working I'm trying to:
GET /api
to fetch the current state/valuePOST /api
to set the new state/valueGET /api
again to get the new state/valueIssue
When first running the spec and recording the cassette, the spec passes.
When running the spec again and playing back the recorded interactions, the spec fails in step 3. The result of the first
GET
is being returned as the result of the secondGET
.Sample code demonstrating the issue
Please see: https://github.com/aisrael/hi8-test
In particular, note the different results of two successive
GET
requests atrepeated_calls_failing.yml#17
andrepeated_calls_failing.yml#L33
The test in
hi8-test_spec.cr
goes like:Expected result
The spec passes
Actual result
The spec fails with:
The text was updated successfully, but these errors were encountered: