slagyr / speclj

pronounced "speckle": a TDD/BDD framework for Clojure.
MIT License
459 stars 58 forks source link

"specljs" : Could not locate specljs/core__init.class #107

Closed GetContented closed 9 years ago

GetContented commented 10 years ago

Hi Using speclj 3.1.0 The clj side is working beautifully, but I can't for the life of me get the cljs side working. I installed the script in bin/speclj, and I'm fairly sure my project is right.

Relevant portion of my project.cljs file:

  :profiles {
    :test {
      :test-paths ["spec/clj" "spec/cljs"]
      :dependencies [[speclj "3.1.0"]
                     [ring-mock "0.1.5"]]
      :plugins [[com.keminglabs/cljx "0.4.0" :exclusions [org.clojure/clojure]]
                [speclj "3.1.0"]]}

The file under test is a simple dummy file, not one using cljx yet. I can build files just fine and it runs in my browser like a lovely thing. I'm just trying to get the cljs tests side set up.

This is the rest of the pertinent bits of my project file:

  :cljsbuild ~(let [run-specs ["bin/speclj" "target/tests.js"]] {
    :builds {
      :dev   { :source-paths ["src/cljs" "target/classes"]
               :compiler {
                 :output-to "resources/public/js/main.js"
                 :output-dir "resources/public/js/out"
                 :optimizations :none
                 :source-map true } }
      :test  { :source-paths ["src/cljs" "target/classes" "src/cljs" "spec/clj" "spec/cljs"]
               :compiler { :output-to "target/tests.js"
                           :pretty-print true }
               :notify-command run-specs } }
    :test-commands {"test" run-specs
                    "spec" run-specs}})
  :cljx {:builds [{:source-paths ["src/cljx"]
                   :output-path "target/classes"
                   :rules :clj}
                  {:source-paths ["src/cljx"]
                   :output-path "target/classes"
                   :rules :cljs}]}

I'm using cljsbuild 1.0.3, clj 1.6.0 and cljs 0.0-2322

Ordinarily I'd just post to stack overflow, but getting this set up was a major pain, and I'd be incredibly surprised if others didn't have the same problem. It took me ages to realise that the cljs side was baked into the clj project... so I was hunting around the web for a "specljs"...

FWIW, I've tried cleaning several times, too.

GetContented commented 10 years ago

Oh, and this is the TOP of the error messages:

Compiling ClojureScript.
Compiling "target/tests.js" from ["src/cljs" "target/classes" "src/cljs" "spec/clj" "spec/cljs"]...
ReferenceError: Can't find variable: speclj

  phantomjs://webpage.evaluate():2
  phantomjs://webpage.evaluate():6
  phantomjs://webpage.evaluate():6
Compiling "target/tests.js" failed.
clojure.lang.ExceptionInfo: Could not locate specljs/core__init.class or specljs/core.clj on classpath:  at line 1 
GetContented commented 10 years ago

... and this is my bin/speclj file:

! /usr/bin/env phantomjs

var fs = require("fs");
var p = require('webpage').create();
var sys = require('system');

p.onConsoleMessage = function (x) {
fs.write("/dev/stdout", x, "w");
};

p.injectJs(phantom.args[0]);

var result = p.evaluate(function () {
speclj.run.standard.armed = true;
return speclj.run.standard.run_specs(
cljs.core.keyword("color"), true
);
});

phantom.exit(result);
trptcolin commented 9 years ago

Based on the clojure.lang.ExceptionInfo: Could not locate specljs/core__init.class or specljs/core.clj on classpath: at line 1 error, it looks like there's something trying to (:require [specljs.core]), but I don't see this error, and I don't see anything in the 3.1.0 release that tries to load such a file.

Any chance you had a stray s character in your specs, such that (:require [specljs.core]) was there instead of (require [speclj.core])?

GetContented commented 9 years ago

Thank you so much for your comments...

I tried... different error now, and I'm not sure I even got it to run...I'll try again later. The setup for testing cljs seem incredibly complicated to me... it'd be nice if there were clear instructions about what everything did. Oh well :)

Thanks for the help.

trptcolin commented 9 years ago

Yeah, agreed, cljs tooling needs work. In my (limited) experience with cljs tooling, the problem is often mismatches in version support across tools (lein-cljsbuild, clojurescript, other libraries), and how the APIs change.

I'll close this for now - feel free to re-open if you get this error again on a recent release of speclj, and feel free to open another issue if you have a different error.

GetContented commented 9 years ago

Thank you very much :)

skrat commented 9 years ago

I'm having issues too, (run-specs apparently uses require function, which isn't available in CLJS environment. Hence TypeError: undefined is not an object (evaluating 'cljs.core.require.call')