Permalink
Browse files

midje.config: use `change-defaults` and `running-in-repl?`

  • Loading branch information...
1 parent 3f1d665 commit fb2c9aafef948b5991c4c03ed36a18237e31570f @marick committed Dec 5, 2012
Showing with 16 additions and 11 deletions.
  1. +2 −2 .midje.clj
  2. +4 −2 src/midje/config.clj
  3. +7 −4 src/midje/doc.clj
  4. +3 −3 test/midje/t_config.clj
View
@@ -1,2 +1,2 @@
-(override-with :visible-deprecation false
- :visible-future false)
+(change-defaults :visible-deprecation false
+ :visible-future false)
View
@@ -1,6 +1,8 @@
(ns ^{:doc "Customizable configuration"}
midje.config
- (:use [midje.error-handling.exceptions :only [user-error]])
+ (:use [midje.error-handling.exceptions :only [user-error]]
+ ;; use this one function so that it's available to config files
+ [midje.util.ecosystem :only [running-in-repl?]])
(:require midje.ideas.reporting.level-defs
[clojure.set :as set]
[midje.util.ecosystem :as ecosystem]))
@@ -56,7 +58,7 @@
(validate! additions)
(alter-var-root #'*config* merge additions))
-(defn override-with
+(defn change-defaults
"Adds key-value pairs to the root configuration.
Does not affect any temporary (dynamic) configurations."
[& kvs]
View
@@ -242,10 +242,13 @@
(def ^{:doc "
On startup, Midje loads ${HOME}/.midje.clj and ./.midje.clj
(in that order). To affect the default configuration, use
- code like this:
- (override-with :visible-deprecation false
- :visible-future false
- :print-level :print-namespaces)
+ code like this in those files:
+ (change-defaults :visible-deprecation false
+ :visible-future false
+ :print-level :print-namespaces)
+
+ If you want different configurations for repl and command-line
+ Midje, use the `running-in-repl?` predicate.
You can temporarily override the configuration like this:
(midje.config/with-augmented-config {:print-level :print-no-summary}
View
@@ -2,13 +2,13 @@
(:use [midje sweet util test-util])
(:require [midje.config :as config]))
-(fact "overriding defaults"
+(fact "changing defaults"
(let [stashed-config config/*config*]
(try
(config/choice :print-level) =not=> :print-nothing
(config/with-augmented-config {:print-level :print-facts}
;; emphasizes that override overrides the root binding
- (config/override-with :print-level :print-nothing))
+ (config/change-defaults :print-level :print-nothing))
(config/choice :print-level) => :print-nothing
(finally
(config/merge-permanently! stashed-config)))))
@@ -32,7 +32,7 @@
(config/merge-permanently! valid-map) => irrelevant
(provided (config/validate! valid-map) => anything)
- (config/override-with :print-level :print-normally) => irrelevant
+ (config/change-defaults :print-level :print-normally) => irrelevant
(provided (config/validate! valid-map) => anything)
(finally

0 comments on commit fb2c9aa

Please sign in to comment.