Hi all. I'm trying to wrap my head around how to use (provided)
.
What I'm doing is refactoring a library that calls out to git. The previous interface was (git-command "describe --long --match v*.*")
, where everything is one string.
In my refactoring I'm changing the API so that it accepts a vararg list of strings instead: (git-command "describe" "--long" "--match" "v*.*")
What I'm having trouble with is trying to refactor tests that resemble this:
(fact "dirty missing tag and fallback is parsed"
(version) => (just [nil 2 "abcd" true])
(provided
(#'leiningen.v.git/git-command #"describe.*")
=> [(format "%s-%s" (subs "abcdef0123456789" 0 *min-sha-length*) *dirty-mark*)] [...]
As I read it, the existing test is "when the single argument to git-command begins with describe
, return this"
What I'd like to do is change it to something more like (provided (#'leiningen.v.git/git-command "describe" anything) => [...])
, so if the first parameter to the function is the literal string "describe"
it returns the value given
...but I can't figure out if there are midje controls to do this, does anyone know?
Aha! Got it, the syntax I was looking for was (#'leiningen.v.git/git-command "describe" & anything)