-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent and confusing behavior with with-redefs #126
Comments
Usually I've used (ns myapp.test
(:require [speclj.core :refer :all]))
(def db "database-a")
(describe "db"
(around [it] (with-redefs [db "database-b"] (it)))
(it "should be called database-b"
(should= db "database-b"))) Not sure why the difference between |
I wonder if this could have to do with Speclj internally requiring a different version of Clojure when run with the vigilant runner than with the standard, so that, when |
@trptcolin thanks for the suggestion. That works; however, the following does not:
Throws
-- this more closely matches what we want to do (dry out DB mocking to use an in-memory test DB rather than a "real" one). Any suggestions (I know you know one or two things about macros AND speclj :-) )? Thanks in advance! |
@eigenhombre I believe this is solved by changing |
@sdegutis It's complaining about |
@eigenhombre Yep! (ns myapp.test
(:require [myapp.test :refer :all]
[speclj.core :refer :all]))
(def db "database-a")
(defmacro describe-with-db [text & body]
`(describe ~text
(around [it#] (with-redefs [db "database-b"] (it#)))
~@body))
(describe-with-db "db"
(it "should be called database-b"
(should= db "database-b"))) Does that do the trick for you? |
@trptcolin works for our minimal test case -- trying it in our app. I also called it |
Yep, inside |
@trptcolin We're unblocked -- that worked for us. I guess there's still the open question of why this is only needed with |
I'm running into the same issue. It seems to be a difference between the standard runner and the vigilant runner. |
lein spec
andlein spec -a
treat the following differently; the test fails in the former, and passes in the latter.In general, we find that running
lein spec
requireswith-redefs
to be specified withinit
blocks (andlein spec -a
doesn't), making it harder to mock out e.g. a database connection for a whole set of tests. Can this be improved somehow?The text was updated successfully, but these errors were encountered: