marick / lein-midje

Leiningen plugin for Midje
MIT License
78 stars 29 forks source link

inject bultitude dependency via plugin middleware #31

Closed mwmitchell closed 11 years ago

mwmitchell commented 11 years ago

Hi, here's another patch to automatically inject bultitude to the [:profiles :dev :dependencies] list in project map.

mwmitchell commented 11 years ago

Just a note to say that the 2.0.2 release works, but will raise an exception unless the project's dev dependencies include bultitude. This patch makes that problem go away.

damionjunk commented 11 years ago

I am experiencing an issue similar to this with 2.0.3 and the latest lein2 snapshot:

lein new testproj
Generating a project called testproj based on the 'default' template.
To see other templates (app, lein plugin, etc), try `lein help new`.

lein midje
Exception in thread "main" java.io.FileNotFoundException: Could not locate bultitude/core__init.class or bultitude/core.clj on classpath: 
    at clojure.lang.RT.load(RT.java:432)
    at clojure.lang.RT.load(RT.java:400)
    at clojure.core$load$fn__4890.invoke(core.clj:5415)
    at clojure.core$load.doInvoke(core.clj:5414)

My ~/.lein/profiles.clj

{:user {:plugins [ 
                  [lein-midje "2.0.3"] 
 ...
                  ]}

The project.clj

(defproject testproj "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [midje "1.4.0"]])

If I manually add the bultitude dependency the tests run.

marick commented 11 years ago

Someone sent in a pull request that (I believe) fixed fixed this in lein-midje 2.0.4. Also, lein-midje 3.0-alpha1 has been completely rewritten to use the Midje repl tools. That should also fix the problem.

Let me know if either of them doesn't.

pmonks commented 11 years ago

<disclaimer> lein/midje/clojure n00b </disclaimer>

Just as a data point, this does indeed work with lein-midje 2.0.4, provided midje itself is upgraded to 1.5.x (the latest I could find was 1.5-alpha8). I also tried with lein-midje 3.0-alpha1 and although the tests appeared to run as expected, I got a ClassCastException afterwards (apologies for messed up formatting - github md sux):

$ lein midje >>> Output from clojure.test tests:   FAIL in (a-test) (core_test.clj:16) FIXME, I fail. Exception in thread "main" expected: (= 0 1) actual: (not (= 0 1))   FAIL in (a-test) (core_test.clj:16) FIXME, I fail. expected: (= 0 1) actual: (not (= 0 1))   2 failures, 0 errors. >>> Midje summary: No facts were checked. Is that what you wanted? java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.Number at user$eval5662.invoke(NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:6511) at clojure.lang.Compiler.eval(Compiler.java:6501) at clojure.lang.Compiler.eval(Compiler.java:6477) at clojure.core$eval.invoke(core.clj:2797) at clojure.main$eval_opt.invoke(main.clj:297) at clojure.main$initialize.invoke(main.clj:316) at clojure.main$null_opt.invoke(main.clj:349) at clojure.main$main.doInvoke(main.clj:427) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:419) at clojure.lang.AFn.applyToHelper(AFn.java:163) at clojure.lang.Var.applyTo(Var.java:532) at clojure.main.main(main.java:37) Subprocess failed

marick commented 11 years ago

Lein-midje is at 3.0-alpha4, and that version requires the alpha8 version of Midje. This need to keep the versions in sync is an unfortunate side-effect of making lein-midje-ish behavior available from the repl (thus making lein-midje a shallow wrapper over Midje itself). The good news is that the Midje repl interface is nearly stable, so that lein-midje releases will soon be able to assume a stable API.

pmonks commented 11 years ago

Thanks for the head's up @marick. I just have to say that "lein midje --lazytest" is rocking my world. ;-)

marick commented 11 years ago

I'm glad. (Note that the current preferred style is lein midje :autotest.)