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
I expected only stub2 to have been requested. The same goes not only for body, but also for headers and with blockmatchers. Is it just me or is this a bug? At least it makes expectations like expect(stub1).to have_been_requested sound misleading.
The text was updated successfully, but these errors were encountered:
stub1 pattern is a superset of stub2 pattern, so if you ask WebMock::RequestRegistry.instance.times_executed(stub1.request_pattern), it will match.
expect(stub1).to have_been_requested is just a convenience method to not have to write the same pattern twice in stub and in expectation. It doesn't check which stub exactly was used but matches pattern of that stub against executed request signatures.
If you want stub1 to have empty body and be different than stub2 rather than omitting body (and saying, 'I don't care about body'), declare it with empty body body => {}.
If you want stub1 to have empty body and be different than stub2 rather than omitting body (and saying, 'I don't care about body'), declare it with empty body body => {}.
Yeah, I thought as much. It's just that this exact phrasing is misleading: expect(stub1).to have_been_requested. UPD More correct way would be: expect_request_matching(stub1.request_pattern).to have_been_made, or something along those lines. Additionally, doesn't it make sense to add this ability? To make expectations specifically on stubs?
Consider the following script:
Output:
I expected only
stub2
to have been requested. The same goes not only forbody
, but also forheaders
andwith block
matchers. Is it just me or is this a bug? At least it makes expectations likeexpect(stub1).to have_been_requested
sound misleading.The text was updated successfully, but these errors were encountered: