You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the stubbed request have been removed, both stub and number of times it have been requested, should not be carried over and should not affect any other stubs.
When I stub the request, make the request, assert the stub, and then remove the stub, I expect the next stub with same url to be a properly isolated object that does not know, and does not care, about anything that happened before, after, or during it's existence.
Instead, we observe a breach of isolation:
Actual behaviour
FAIL FooTest#test_foo (0.20s)
The request GET https://www.google.com/ was expected to execute 1 time but it executed 2 times
The following requests were made:
GET https://www.google.com/ with headers {'Expect'=>'', 'User-Agent'=>'Typhoeus - https://github.com/typhoeus/typhoeus'} was made 2 times
============================================================
test/foo_test.rb:14:in `block in <class:FooTest>'
I guess the problem is assert_requested is checking not the stub object, as one would expect from the syntax, but the global registry of requests instead.
The text was updated successfully, but these errors were encountered:
support for passing a stub to assert_requested has been added after assert_requested was originally created to make it easier and avoid duplication, but the assertion is made on request registry and not on the stub itself.
Well yes, that's what this whole issue is about. They are expected to.
According to the semantics and signature of stub_request, assert_requested <stub>, and remove_request_stub methods, one would expect them to be idempotent.
remove_request_stub is expected to actually remove the stub and all the information related to it.
Which is not happening.
It would be really great if those methods could work as described (either by simply removing entries from registry, altering the request count, setting some flags, counters, or redesigning the whole registry approach in a different manner).
Or at least, please, have it well documented, both in the methods descriptions and the readme. That alone could save quite a number of wasted brain cells of fellow developers out there. ;)
"If it's not documented, it's not a feature, it's a bug."
Test case
Expected behaviour
Test should pass.
Since the stubbed request have been removed, both stub and number of times it have been requested, should not be carried over and should not affect any other stubs.
When I stub the request, make the request, assert the stub, and then remove the stub, I expect the next stub with same url to be a properly isolated object that does not know, and does not care, about anything that happened before, after, or during it's existence.
Instead, we observe a breach of isolation:
Actual behaviour
UPD.
#548 seems to be related.
I guess the problem is
assert_requested
is checking not the stub object, as one would expect from the syntax, but the global registry of requests instead.The text was updated successfully, but these errors were encountered: