Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

simplify projects.clj and update README

  • Loading branch information...
commit a6c31c63517d00bd36b6fdffe5ac1eaa5cc44e56 1 parent 2d4ef45
@slagyr authored
View
7 CHANGES.md
@@ -1,6 +1,11 @@
+# 3.0.0
+
+* Merges CLJ and CLJS into one jar using CLJX (specljs is no more)
+* `lein spec` tasks defaults to `:eval-in :subprocess` rather than `:eval-in leiningen`
+
# 2.9.1
-# adds :* and fn matchers to stub invokation checking
+* adds :* and fn matchers to stub invokation checking
# 2.9.0
View
96 README.md
@@ -2,9 +2,7 @@
### (pronounced "speckle" [spek-uhl]) ###
It's a TDD/BDD framework for [Clojure](http://clojure.org/) and [Clojurescript](http://clojurescript.org/), based on [RSpec](http://rspec.info/).
-[Installation](https://github.com/AndrewZures/speclj_again/edit/master/README.md#installation)
-[Clojure](https://github.com/AndrewZures/speclj_again/edit/master/README.md#clojure)
-[ClojureScript](https://github.com/AndrewZures/speclj_again/edit/master/README.md#clojurescript)
+[Installation](#installation) | [Clojure](#clojure) | [ClojureScript](#clojurescript)
# Installation
@@ -40,7 +38,7 @@ $ lein install
## Usage
-## File Structure
+### File Structure
All your `speclj` code should go into a a directory named `spec` at the root of your project. Conventionally, the `spec` directory will mirror the `src` directory structure except that all the `spec` files will have the '_spec.clj' postfix.
| sample_project
@@ -55,7 +53,7 @@ All your `speclj` code should go into a a directory named `spec` at the root of
| (All your other test code)
-## A Sample Spec File
+### A Sample Spec File
Checkout this example spec file. It would be located at `sample_project/spec/sample/core_spec.clj`. Below we'll look at it piece by piece.
```clojure
@@ -74,7 +72,7 @@ Checkout this example spec file. It would be located at `sample_project/spec/sam
(run-specs)
```
-### speclj.core namespace
+#### speclj.core namespace
Your spec files should `:require` the `speclj.core` in it's entirety. It's a clean namespace and you're likely going to use all the definitions within it. Don't forget to pull in the library that you're testing as well (sample.core in this case).
```clojure
@@ -82,21 +80,21 @@ Your spec files should `:require` the `speclj.core` in it's entirety. It's a cl
(use 'sample.core)
```
-### describe
+#### describe
`describe` is the outer most container for specs. It takes a `String` name and any number of _spec components_.
```clojure
(describe "Truth" ...)
```
-### it
+#### it
`it` specifies a _characteristic_ of the subject. This is where assertions go. Be sure to provide good names as the first parameter of `it` calls.
```clojure
(it "is true" ...)
```
-### should and should-not
+#### should and should-not
Assertions. All assertions begin with `should`. `should` and `should-not` are just two of the many assertions available. They both take expressions that they will check for truthy-ness and falsy-ness respectively.
```clojure
@@ -104,57 +102,57 @@ Assertions. All assertions begin with `should`. `should` and `should-not` are
(should-not ...)
```
-### run-specs
+#### run-specs
At the very end of the file is an invocation of `(run-specs)`. This will invoke the specs and print a summary. When running a suite of specs, this call is benign.
```clojure
(run-specs)
```
-## should Variants (Assertions)
+### should Variants (Assertions)
There are several ways to make assertions. They are documented on the wiki: [Should Variants](https://github.com/slagyr/speclj/wiki/Should-variants)
-## Spec Components
+### Spec Components
`it` or characteristics are just one of several spec components allowed in a `describe`. Others like `before`, `with`, `around`, etc are helpful in keeping your specs clean and dry. Check out the listing on the wiki: [Spec Components](https://github.com/slagyr/speclj/wiki/Spec-components)
-# Running Specs
+## Running Specs
-## With Leiningen
+### With Leiningen
Speclj includes a Leiningen task to execute `speclj.main`.
```bash
$ lein spec
```
-## Using `lein run`
+### Using `lein run`
The command below will run all the specs found in `"spec"` directory.
```bash
$ lein run -m speclj.main
```
-## As a Java command
+### As a Java command
The command below will run all the specs found in `"spec"` directory.
```bash
$ java -cp <...> speclj.main
```
-## Autotest
+### Autotest
The command below will start a process that will watch the source files and run specs for any updated files.
```bash
$ lein spec -a
```
-## Options
+### Options
There are several options for the runners. Use the `--help` options to see them all. Or visit [Command Line Options](https://github.com/slagyr/speclj/wiki/Command-Line-Options).
```bash
$ lein spec --help
```
-## `:eval-in`
+### `:eval-in`
To make your tests start up slightly faster, you can add `:speclj-eval-in :leiningen` to your project map.
@@ -178,37 +176,25 @@ All your `speclj` code should go into a a directory named `spec` at the root of
|-- core_spec.cljs
| (All your other test code)
+## 1. Configure Your project.clj File
-##Set Up Your Project.clj File
-Speclj for ClojureScript requires a few changes to your project.clj file.
-
-
-##### 1. Configure Your Project.clj File
-
-Speclj works with `lein-cljsbuild` which can be found [here](https://github.com/emezeske/lein-cljsbuild)
-
-You'll need to make a few changes to `:cljsbuild` map:
+[`lein-cljsbuild`](https://github.com/emezeske/lein-cljsbuild) is a Leiningen plugin that'll get you up and running with ClojureScript. You'll need to add a `:cljsbuild` configuration map to your `project.clj`.
```clojure
- :cljsbuild ~(let [run-specs ["bin/speclj_runner.js" "resources/public/javascript/your_project_dev.js"]]
- {:builds {:dev {
- :source-paths ["src/cljs" "spec/cljs"]
- :compiler {:output-to "resources/public/javascript/your_project_dev.js"}
- }
- }
- :prod {:source-paths ["src/cljs"]
- :compiler {:output-to "resources/public/javascript/your_project.js"}
- }
- }
- :test-commands {"test" run-specs}
- )
+:cljsbuild {:builds {:dev {:source-paths ["src/cljs" "spec/cljs"]
+ :compiler {:output-to "path/to/compiled.js"}
+ :notify-command ["bin/speclj" "path/to/compiled.js"]}
+ :prod {:source-paths ["src/cljs"]
+ :compiler {:output-to "path/to/prod.js"
+ :optimizations :simple}}}
+ :test-commands {"test" ["bin/speclj" "path/to/compiled.js"]}}
```
-Speclj works by operating on your compiled ClojureScript. The `:notify-command` will execute the `run-specs` command after your cljs is compiled. The `run-specs` command will use speclj to evaluate your compiled ClojureScript.
+Speclj works by operating on your compiled ClojureScript. The `:notify-command` will execute the `bin/speclj` command after your cljs is compiled. The `bin/speclj` command will use speclj to evaluate your compiled ClojureScript.
-##### 2. Configure Your speclj.js File
+## 2. Create test runner executable
-Create a file named `speclj.js` in your `bin` directory and copy the code below:
+Create a file named `speclj` in your `bin` directory and copy the code below:
```JavaScript
#! /usr/bin/env phantomjs
@@ -257,7 +243,8 @@ Checkout this example spec file. It would be located at `sample_project/spec/clj
### speclj.core namespace
Your spec files should `:require` the `speclj.core` just like in clojure. Don't forget to pull in the library that you're testing as well (sample.core in this case).
-You'll also need to `:require-macros` the `speclj.core` and `:refer` each speclj test word that you want to use. In the example below, we are using __describe__, __it__, __should__, __should-not__, and __run-spec__. If you wanted to use __context__ you would simply add it to the current `:refer` collection. For a list of speclj test words go to the [speclj documentation](http://speclj.com/docs)
+You'll also need to `:require-macros` the `speclj.core` and `:refer` each speclj test word that you want to use. In the example below, we are using __describe__, __it__, __should__, __should-not__, and __run-spec__.
+If you wanted to use __context__ you would simply add it to the current `:refer` collection. For a list of speclj test words go to the [speclj documentation](http://speclj.com/docs)
As a final note, your own library must be __aliased__ using `:as`. This is a current ClojureScript requirement.
@@ -267,15 +254,22 @@ As a final note, your own library must be __aliased__ using `:as`. This is a cu
[sample.core :as my-core]))
```
-# Running Specs
+## Running Specs
-## With Leiningen
-Speclj includes a Leiningen task to execute `speclj.main`.
+### With Leiningen
+We defer to `cljsbuild` to run our test command.
```bash
$ lein cljsbuild test
```
+### Bash
+The command below will start a process that will watch the source files and run specs for any updated files.
+
+```bash
+$ bin/speclj path/to/compiled.js
+```
+
# Community
* Source code: [https://github.com/slagyr/speclj](https://github.com/slagyr/speclj)
@@ -293,13 +287,11 @@ $ cd speclj
$ lein spec
```
-To make sure you didn't break the cljs version of specljs:
+To make sure tests pass ClojureScript too:
```bash
-$ cd cljs
-$ lein translate
-$ lein cljsbuild clean
-$ lein cljsbuild once
+lein cljsbuild clean
+lein cljsbuild once
```
Make patches and submit them along with an issue (see below).
View
2  bin/specljs
@@ -17,7 +17,7 @@ var result = p.evaluate(function () {
speclj.run.standard.armed = true;
return speclj.run.standard.run_specs(
cljs.core.keyword("color"), true
- // cljs.core.keyword("reporters"), ["documentation"]
+ // , cljs.core.keyword("reporters"), ["documentation"]
);
});
View
131 project.clj
@@ -3,95 +3,56 @@
(defproject speclj speclj.version/string
:description "speclj: Pronounced 'speckle', is a Behavior Driven Development framework for Clojure."
:url "http://speclj.com"
- :license {:name "The MIT License"
- :url "file://LICENSE"
+ :license {:name "The MIT License"
+ :url "file://LICENSE"
:distribution :repo
- :comments "Copyright 2011-2014 Micah Martin All Rights Reserved."}
+ :comments "Copyright 2011-2014 Micah Martin All Rights Reserved."}
+ :jar-exclusions [#"\.cljx|\.swp|\.swo|\.DS_Store"]
+ :javac-options ["-target" "1.5" "-source" "1.5"]
+ :source-paths ["src/clj" "src/cljs"]
+ :test-paths ["spec/clj" "target/test-classes"]
:hooks [cljx.hooks]
- :profiles {
- :dev {:dependencies [[org.clojure/clojure "1.5.1"]
- [com.keminglabs/cljx "0.3.1"]]
- :plugins [ [com.keminglabs/cljx "0.3.1"]]
- :cljx {:builds [{:source-paths ["src/cljx"]
- :output-path "target/generated/src/clj"
- :rules :clj}
- {:source-paths ["src/cljx"]
- :output-path "target/generated/src/cljs"
- :rules :cljs}
- {:source-paths ["spec/cljx"]
- :output-path "target/generated/spec/clj"
- :rules :clj}
- {:source-paths ["spec/cljx"]
- :output-path "target/generated/spec/cljs"
- :rules :cljs}]}}
-
- :production {:dependencies [[org.clojure/clojure "1.5.1"]
- [com.keminglabs/cljx "0.3.1"]
- [fresh "1.0.2"]
- [mmargs "1.2.0"]]
- :plugins [[com.keminglabs/cljx "0.3.1"]
- [lein-cljsbuild "1.0.0"]]
-
- :cljx {:builds [{:source-paths ["src/cljx"]
- :output-path "target/generated/src/clj"
- :rules :clj}
- {:source-paths ["src/cljx"]
- :output-path "target/generated/src/cljs"
- :rules :cljs}
- {:source-paths ["spec/cljx"]
- :output-path "target/generated/spec/clj"
- :rules :clj}
- {:source-paths ["spec/cljx"]
- :output-path "target/generated/spec/cljs"
- :rules :cljs}]}
-
- :source-paths ["target/generated/src/clj" "src/clj"]
- :resource-paths ["target/generated/src/cljs" "src/cljs"]
- :java-source-paths ["src/clj"]
- }
-
- :clj {:dependencies [[org.clojure/clojure "1.5.1"]
- [fresh "1.0.2"]
- [mmargs "1.2.0"]]
-
- :source-paths ["target/generated/src/clj" "src/clj"]
- :test-paths ["target/generated/spec/clj" "spec/clj"]
- :java-source-paths ["src/clj"]
- }
-
- :cljs {:dependencies
- [[org.clojure/clojure "1.5.1"]
- [org.clojure/tools.reader "0.7.10"] ;necessary for current version of speclj
- [org.clojure/clojurescript "0.0-2014"] ;necessary for current version of speclj
- [lein-cljsbuild "1.0.0"]]
- :plugins [[lein-cljsbuild "1.0.0"]]
-
- :source-paths ["src/cljs" "src/clj" "spec/clj"]
-
- :cljsbuild ~(let [test-command ["bin/specljs" "target/tests.js"]]
- {:builds
- {:dev {:source-paths ["target/generated/src/cljs" "src/cljs" "target/generated/spec/cljs" "spec/cljs"]
- :compiler {:output-to "target/tests.js"
+ :dependencies [[org.clojure/clojure "1.5.1"]
+ [fresh "1.0.2"]
+ [mmargs "1.2.0"]]
+
+ :cljx {:builds [{:source-paths ["src/cljx"]
+ :output-path "target/classes"
+ :rules :clj}
+ {:source-paths ["src/cljx"]
+ :output-path "target/classes"
+ :rules :cljs}
+ {:source-paths ["spec/cljx"]
+ :output-path "target/test-classes"
+ :rules :clj}
+ {:source-paths ["spec/cljx"]
+ :output-path "target/test-classes"
+ :rules :cljs}]}
+
+ :java-source-paths ["src/clj"]
+
+ :profiles {:dev {:dependencies [[com.keminglabs/cljx "0.3.2"]
+ [org.clojure/clojurescript "0.0-2014"]]
+ ;[org.clojure/clojurescript "0.0-2173"]]
+ :plugins [[com.keminglabs/cljx "0.3.2"]
+ [lein-cljsbuild "1.0.2"]]}}
+
+ :cljsbuild {:builds {:dev {:source-paths ["target/classes" "src/cljs" "target/test-classes" "spec/cljs"]
+ :compiler {:output-to "target/tests.js"
:pretty-print true}
- :notify-command test-command
- }}
- :test-commands {"unit" test-command}})
-
- :aliases {"clean" ["cljsbuild" "clean"]
- "compile" ["cljsbuild" "once"]
- "test" ["do" "clean" "," "compile"]}}}
-
- :aliases {"cljsbuild" ["with-profile" "cljs" "cljsbuild"]
- "cljx" ["with-profile" "dev" "cljx"]
- "clj-test" ["do" "clean," "with-profile" "clj" "run" "-m" "speclj.main" "-c" "-b" "target/generated/spec/clj" "spec/clj"]
- "cljs-test" ["do" "clean," "cljx," "with-profile" "cljs" "test"]
- "all-tests" ["do" "clj-test," "cljs-test"]
- }
-
- ;:eval-in-leiningen true
- ;:uberjar-exclusions [#"^clojure/.*"]
- :javac-options ["-target" "1.5" "-source" "1.5"]
+ :notify-command ["bin/specljs" "target/tests.js"]
+ }}
+ :test-commands {"unit" ["bin/specljs" "target/tests.js"]}}
+
+ ;:aliases {"cljsbuild" ["with-profile" "cljs" "cljsbuild"]
+ ; "cljx" ["with-profile" "dev" "cljx"]
+ ; "clj-test" ["do" "clean," "with-profile" "clj" "run" "-m" "speclj.main" "-c" "-b" "target/generated/spec/clj" "spec/clj"]
+ ; "cljs-test" ["do" "clean," "cljx," "with-profile" "cljs" "test"]
+ ; "all-tests" ["do" "clj-test," "cljs-test"]}
+
+ :eval-in :leiningen
+ :speclj-eval-in :leiningen
)
View
17 resources/leiningen/build.clj
@@ -1,17 +0,0 @@
-(ns leiningen.build
- (:require [cljs.closure]
- [leiningen.core.eval :refer [eval-in-project]]))
-
-(def options {:output-to "js/speclj.js"
- :output-dir "js"
- :optimizations :simple})
-
-(defrecord Sources [paths]
- cljs.closure/Compilable
- (-compile [_ options] (mapcat #(cljs.closure/-compile % options) paths)))
-
-(defn build [project & args]
- (let [sources (vec (:source-paths project))]
- (println "Compiling " (pr-str sources))
- (eval-in-project project
- `(cljs.closure/build (Sources. ~sources) ~options))))
View
55 resources/leiningen/translate.clj
@@ -1,55 +0,0 @@
-(ns leiningen.translate
- (:require [clojure.java.io :refer [copy file]]))
-
-(defn remove-cljs-ignores [src]
- (.replaceAll
- (.matcher
- (java.util.regex.Pattern/compile ";cljs-ignore->.*?;<-cljs-ignore"
- (bit-or java.util.regex.Pattern/MULTILINE java.util.regex.Pattern/DOTALL))
- src)
- ""))
-
-(defn translate-file [from to]
- (let [to-f (file to)
- src (slurp from)]
- (println (format "copying %s to %s" from to))
- (.mkdirs (.getParentFile to-f))
- (copy
- (-> src
- (.replace "speclj" "specljs")
- (.replace "(:require ;cljs-macros" "(:require-macros")
- (.replace "java.lang.Throwable" "js/Object")
- (.replace "java.lang.Exception" "js/Error")
- (.replace "java.lang.Object" "js/Object")
- (.replace ";cljs-include " "")
- remove-cljs-ignores)
- to-f)))
-
-(def translations
- {"../src/speclj/components.clj" "src/translated/specljs/components.cljs"
- "../src/speclj/config.clj" "src/translated/specljs/config.cljs"
- "../src/speclj/core.clj" "src/translated/specljs/core.clj"
- "../src/speclj/report/documentation.clj" "src/translated/specljs/report/documentation.cljs"
- "../src/speclj/report/progress.clj" "src/translated/specljs/report/progress.cljs"
- "../src/speclj/report/silent.clj" "src/translated/specljs/report/silent.cljs"
- "../src/speclj/reporting.clj" "src/translated/specljs/reporting.cljs"
- "../src/speclj/results.clj" "src/translated/specljs/results.cljs"
- "../src/speclj/running.clj" "src/translated/specljs/running.cljs"
- "../src/speclj/stub.clj" "src/translated/specljs/stub.cljs"
- "../src/speclj/tags.clj" "src/translated/specljs/tags.cljs"
- "../src/speclj/version.clj" "src/translated/specljs/version.cljs"
- ; Specs
- "../spec/speclj/config_spec.clj" "spec/translated/specljs/config_spec.cljs"
- "../spec/speclj/core_spec.clj" "spec/translated/specljs/core_spec.cljs"
- "../spec/speclj/report/documentation_spec.clj" "spec/translated/specljs/report/documentation_spec.cljs"
- "../spec/speclj/report/progress_spec.clj" "spec/translated/specljs/report/progress_spec.cljs"
- "../spec/speclj/reporting_spec.clj" "spec/translated/specljs/reporting_spec.cljs"
- "../spec/speclj/should_spec.clj" "spec/translated/specljs/should_spec.cljs"
- "../spec/speclj/spec_helper.clj" "spec/translated/specljs/spec_helper.clj"
- "../spec/speclj/stub_spec.clj" "spec/translated/specljs/stub_spec.cljs"
- "../spec/speclj/tags_spec.clj" "spec/translated/specljs/tags_spec.cljs"
- })
-
-(defn translate [project]
- (doseq [[to from] translations]
- (translate-file to from)))
View
13 resources/speclj/repl.clj
@@ -1,13 +0,0 @@
-(ns speclj.repl
- (:require [cemerick.piggieback :as piggieback]))
-
-;(defn browser-repl []
-; (println "Starting browser repl on port 9000")
-; (println "[don't forget to load the browser page!]")
-; (require 'cljs.repl.browser)
-; (piggieback/cljs-repl
-; :repl-env (doto ((ns-resolve 'cljs.repl.browser 'repl-env) :port 9000)
-; cljs.repl/-setup)))
-
-(defn rhino-repl []
- (piggieback/cljs-repl))
View
5 src/clj/leiningen/spec.clj
@@ -2,7 +2,10 @@
(:require [leiningen.core.eval :refer [eval-in-project]]))
(defn- exit-if-needed [exit-code]
- (when-not (zero? exit-code)
+ (cond
+ (nil? exit-code) 0
+ (not (number? exit-code)) (println *err* (str "Unusual exit code: " exit-code))
+ (not (zero? exit-code))
(try
(require 'leiningen.core.main)
((ns-resolve (the-ns 'leiningen.core.main) 'exit) exit-code)
View
6 src/clj/speclj/version.clj
@@ -1,9 +1,9 @@
(ns speclj.version
(:require [clojure.string :as str]))
-(def major 2)
-(def minor 9)
-(def tiny 4)
+(def major 3)
+(def minor 0)
+(def tiny 0)
(def snapshot false)
(def string
(str
Please sign in to comment.
Something went wrong with that request. Please try again.