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
The change in this PR #1012 has changed the timing when a request stub's response proc is called.
Given:
specifydoreq_stub=stub_request(:post,url).to_return_json(body: proc{puts"REQUEST";{}})puts"SUBJECT"subject# stand-in for expectations on the subject that would trigger the mocked requestend
In webmock 3.18.1, the output is "SUBJECT" then "REQUEST".
In webmock 3.19.0, the output is "REQUEST" then "SUBJECT".
It is expected that the proc for the request not actually fire until the mock is actually requested. This way the mock can perform side effects at the correct moment in the subject's lifecycle. In actuality, this bug was caught by an rspec change matcher that started failing after the webmock upgrade. The request stub's proc triggered side effects that replicated the real service, and so the change matcher was used to assert the subject under test was causing the changes. With the upgraded webmock, the expected side effect was occurring prior to the subject being called.
The text was updated successfully, but these errors were encountered:
This is not really a regression, since before PR #1012 , the support for declaring Proc as body in to_return_json was only accidental and not supported, but you have raised a valid point, that the body should be evaluated at the time of request and not at the time of to_return_json declaration, same as in case of to_return
The change in this PR #1012 has changed the timing when a request stub's response proc is called.
Given:
In webmock 3.18.1, the output is "SUBJECT" then "REQUEST".
In webmock 3.19.0, the output is "REQUEST" then "SUBJECT".
It is expected that the proc for the request not actually fire until the mock is actually requested. This way the mock can perform side effects at the correct moment in the subject's lifecycle. In actuality, this bug was caught by an rspec
change
matcher that started failing after the webmock upgrade. The request stub's proc triggered side effects that replicated the real service, and so thechange
matcher was used to assert the subject under test was causing the changes. With the upgraded webmock, the expected side effect was occurring prior to the subject being called.The text was updated successfully, but these errors were encountered: