slagyr / speclj

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

There's no spec-specific Leiningen profile #153

Open ideal-knee opened 8 years ago

ideal-knee commented 8 years ago

The default Leiningen test task merges in a test-specific profile, which allows libraries such as Environ to appropriately use dev or test configurations depending on task.

My proposed patch:

--- a/src/leiningen/spec.clj
+++ b/src/leiningen/spec.clj
@@ -1,5 +1,6 @@
 (ns leiningen.spec
   (:require [leiningen.core.eval :refer [eval-in-project]]
+            [leiningen.core.project :refer [merge-profiles]]
             [leiningen.core.main :as main]))

 (defn make-run-form [project speclj-args]
@@ -36,7 +37,9 @@ documentation, as opposed to this message provided by Leiningen, try this:

 That ought to do the trick."
   [project & args]
-  (let [project (assoc project :eval-in (get project :speclj-eval-in :subprocess))
+  (let [project (-> project
+                    (assoc :eval-in (get project :speclj-eval-in :subprocess))
+                    (merge-profiles [:spec]))
         speclj-args (build-args project args)
         run-form (make-run-form project speclj-args)
         init-form '(require 'speclj.cli)]

This would allow users to define spec-specific profiles. All specs run by lein spec passed with this change (I do not have phantomjs installed to run the ClojureScript specs). I also could not find any specs for the leiningen.spec namespace, so I didn't write any tests.

ideal-knee commented 8 years ago

A potential README patch:

--- a/README.md
+++ b/README.md
@@ -36,6 +36,16 @@ Include speclj in your `:dev` profile `:dependencies` and`:plugins`. Then change
 :test-paths ["spec"]
 \```

+### `spec` Profile
+
+You can specify a `:spec` profile for testing-specific configuration.  E.g. for [Environ](https://github.com/weavejester/environ):
+
+```
+; - snip
+:profiles {:dev {:env {:database-url "<dev-db-url>"}}
+           :spec {:env {:database-url "<spec-db-url>"}}}
+```
+
 ## Manual installation

 1. Check out the source code: [https://github.com/slagyr/speclj](https://github.com/slagyr/speclj)

(I manually added a \ in that patch to get it to render correcty.)

ideal-knee commented 8 years ago

If anyone is interested in using this patch, it is available on Clojars: https://clojars.org/org.clojars.ideal-knee/speclj