Mocking.jl icon indicating copy to clipboard operation
Mocking.jl copied to clipboard

use splat operator for `apply` call

Open fchorney opened this issue 3 years ago • 0 comments

Looking at this, https://github.com/invenia/Mocking.jl/blob/master/src/patch.jl#L138-L140

Would anybody be opposed to adding something like

function apply(body::Function, patches...; debug::Bool=false)
    return apply(body, collect(patches);  debug)
end

This is mostly just a visual enhancement, and has some small usability improvements.

Let's say I have a patch that I generally use for multiple tests, but sometimes I want to add a secondary patch you end up with

apply(patch_1) do ... end

apply([patch_1, patch_2]) do ... end

IMO it would look nicer if we could just add n number of patches without having to enclose them in an array

apply(patch_1) do ... end

apply(patch_1, patch_2) do ... end

fchorney avatar Oct 11 '22 19:10 fchorney