marick / Midje

Midje provides a migration path from clojure.test to a more flexible, readable, abstract, and gracious style of testing
MIT License
1.68k stars 128 forks source link

Metaconstants are elided by Integrant's init method #424

Closed WhittlesJr closed 6 years ago

WhittlesJr commented 6 years ago

Sorry to pile on another spurious issue, but maybe you'll have an idea of what's going on here with metaconstants and Integrant. I first submitted an issue there, but the author doesn't suspect that Integrant is the cause of the issue.

(I'll add that even putting the defmethod inside of the fact yields the same behavior)

(defmethod ig/init-key :some/component
  [_ config]
  (:config-key config))

(fact
  (ig/init {:some/component {:config-key ..value..}})

  => {:some/component ..value..})

Produces:

Error Metaconstants (..value..) can't be compared for equality with {}.

Whereas the following passes:

(fact
  (ig/init {:some/component {:config-key "value"}})

  => {:some/component "value"})

Thank you! And thank you for Midje in general. It's a joy to test with it and it has made my code so much better.

marick commented 6 years ago

TL/DR: The problem you're having is that it's complicated to fit metaconstants into Clojure. The string example that passes is, I think, a perfectly fine test. I'd just use it (maybe putting .. in the string to signal that it's acting like a metaconstant).


Metaconstants were an outgrowth of my typical testing practice in Ruby and other dynamically-typed languages:

WhittlesJr commented 6 years ago

So it's just something I'll have to work around, huh. Understood.