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
someMock.given(.aFunction(willProduce:{ stubber in
stubber.return(resultFactory())}))
It does work, but not as I expect. I was expecting the stubber block to be called every time the method on the mock is invoked, and return a fresh result from the factory.
What actually happens: stubber block is ran only once, correctly (once) runs the factory block, captures its result, and keeps wrapping over it and returning the same result to all method invocations.
I realize why working with static results is OK most of the time. I’m not proposing to change anything about current behavior, but rather, to add a capability to stubber where it would let me return fresh results from a factory. I suppose it would be a new stubbing policy in addition to wrap and drop.
The text was updated successfully, but these errors were encountered:
I was expecting this to work:
It does work, but not as I expect. I was expecting the stubber block to be called every time the method on the mock is invoked, and return a fresh result from the factory.
What actually happens: stubber block is ran only once, correctly (once) runs the factory block, captures its result, and keeps wrapping over it and returning the same result to all method invocations.
I realize why working with static results is OK most of the time. I’m not proposing to change anything about current behavior, but rather, to add a capability to stubber where it would let me return fresh results from a factory. I suppose it would be a new stubbing policy in addition to
wrap
anddrop
.The text was updated successfully, but these errors were encountered: