marick / Midje

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

Test failure on master #488

Closed NoahTheDuke closed 10 months ago

NoahTheDuke commented 12 months ago

In #485, mocking clojure.core/str was disallowed. However, the below test wasn't updated and so fails when running lein midje.

https://github.com/marick/Midje/blob/34819ae8d24a11b0f953d461f94e09a2638ff385/test/midje/parsing/2_to_lexical_maps/t_fakes.clj#L25-L28

Failure output:

FAIL at (t_fakes.clj:28)
The checking function `(fact-captured-throwable-with-message #"You seem to have created a prerequisite*")` threw the exception:
#<java.lang.IllegalArgumentException@548e0f04 java.lang.IllegalArgumentException: No implementation of method: :throwable of protocol: #'midje.util.exceptions/ICapturedThrowable found for class: nil>

When checked against the actual result:
{:notes ("You seem to have created a prerequisite for"
         "#'clojure.core/str that interferes with that function's use in Midje's"
         "own code. To fix, define a function of your own that uses str, then"
         "describe that function in a provided clause. For example, instead of this:"
         "  (provided (every? even? ..xs..) => true)"
         "do this:"
         "  (def all-even? (partial every? even?))"
         "  ;; ..."
         "  (provided (all-even? ..xs..) => true)")
 :position ("t_fakes.clj" 27)
 :type :parse-error}

If the provided call is changed to (provided (noop (my-fn 'url)) => 'some-result) (which seems like was the intention), then a different error is thrown:

FAIL at (t_fakes.clj:28)
The checking function `(fact-captured-throwable-with-message #"You seem to have created a prerequisite*")` threw the exception:
#<java.lang.IllegalArgumentException@47d1798c java.lang.IllegalArgumentException: No implementation of method: :throwable of protocol: #'midje.util.exceptions/ICapturedThrowable found for class: midje.data.metaconstant.Metaconstant>

When checked against the actual result:
{:actual ...my-fn-value-1...
 :arrow =>
 :call-form (my-fn (quote url))
 :check-expectation :expect-match
 :description ["results in stack overflow"]
 :expected-result some-result
 :expected-result-form (quote some-result)
 :function-under-test #<midje.parsing.2_to_lexical_maps.t_fakes$eval11961$fn__11962$fn__11963$fn__11964@29beac4e>
 :namespace #<clojure.lang.Namespace@12f1b76c midje.parsing.2-to-lexical-maps.t-fakes>
 :position ["t_fakes.clj" 26]
 :type :actual-result-did-not-match-expected-value
 :midje.parsing.lexical-maps/a-midje-checkable-map? true}

I'd offer to fix it, but this test suite is very complex and I don't quite get how these helper functions work lol