midje

timgilbert 2018-07-13T20:45:24.000214Z

Hi all. I'm trying to wrap my head around how to use (provided).

timgilbert 2018-07-13T20:46:29.000347Z

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.

timgilbert 2018-07-13T20:47:31.000356Z

In my refactoring I'm changing the API so that it accepts a vararg list of strings instead: (git-command "describe" "--long" "--match" "v*.*")

timgilbert 2018-07-13T20:48:34.000131Z

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*)]  [...]

timgilbert 2018-07-13T20:49:39.000184Z

As I read it, the existing test is "when the single argument to git-command begins with describe, return this"

timgilbert 2018-07-13T20:51:08.000239Z

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

timgilbert 2018-07-13T20:51:35.000383Z

...but I can't figure out if there are midje controls to do this, does anyone know?

timgilbert 2018-07-13T21:03:39.000224Z

Aha! Got it, the syntax I was looking for was (#'leiningen.v.git/git-command "describe" & anything)