Closed
Description
Sometimes you don't know or want to paste the exact arguments to some mocked function, but you still want to assert that it was called in a certain manner, and you do know some things about the call arguments.
For example:
using Random: randstring
using SimpleMock: called_with, mock, SomethingThatIDontKnowWhatToName
f(x) = x * randstring()
mock(*) do star
f("foo")
@test called_with(star, "foo", SomethingThatIDontKnowWhatToName(x -> match(r"\s{8}", x) !== nothing)
end
Instead of comparing the observed argument, which in this case is the output of randstring()
, to the expected argument by value, the function x -> match(r"\s{8}", x) !== nothing
would run on the observed argument, and be considered a match if that outputted true
.