Open milt opened 9 years ago
I have the same error when running tests from the LightTable repl.
In my opinion, this behavior is associated with how speclj determines what language we use ClojureScript or Clojure.
The namespace «speclj.core» have the following code:
(def ^:private ^:no-doc cljs? (boolean (find-ns 'cljs.analyzer)))
(defmacro ^:no-doc -new-failure [message]
(if cljs? `(speclj.platform.SpecFailure. ~message) `(speclj.SpecFailure. ~message)))
In the first line Speclj determines a language (ClojureScript or Clojure) is used, based on the presence of the loaded namespace named 'cljs.analyzer. That is, for ClojureScript value cljs? It must be true, and for code in Clojure - false.
In the second line variable cljs? is used to select the implementation SpecFailure, which for Clojure and ClojureScript located in different namespace.
The problem of this implementation cljs? is for example IDE LightTable in the repl mode itself uses and loads ns cljs.analyzer, no matter what code (Clojure or ClojureScript) it executes.
I can suggest the following workaround code for Clojure tests:
(remove-ns 'cljs.analyzer)
(ns test.spec
(:require
[speclj.core :refer :all :exclude [with]]))
(require '[cljs.analyzer])
(describe "test"
(it "is true"
(should= 2 2)))
In the spec-files at first remove cljs.analyzer, that cljs? It was calculated with the value false. And then restored as it was.
also getting this
Maybe this is an artifact of some of the other tooling involved, but I am getting a strange behavior when I attempt to compile cljs speclj tests from cljc (reader conditional) source. When I attempt to build the tests (using cljsbuild, so
lein cljsbuild once dev
) I get the oldclojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException: speclj.platform.SpecFailure
error, but then it builds, and any test commands execute properly. If the source is just a .cljs file, this does not happen.Built an example repo to illustrate this here: https://github.com/milt/spectest
To see the error run
lein cljsbuild once dev-cljc
. For a normal cljs-only build that works fine,lein cljsbuild once dev-cljs
.