/
t_colorize.clj
39 lines (33 loc) · 1.39 KB
/
t_colorize.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(ns midje.emission.t-colorize
(:use midje.sweet
[midje.util.ecosystem :only [getenv on-windows?]])
(:require [midje.emission.colorize :as color]))
(tabular
(fact "wraps string in ascii color when env variable is not explicitly set to FALSE"
(do
(color/init!)
(?color-fn "string")) => ?result
(provided
(on-windows?) => ?on-windows :times (range)
(getenv "MIDJE_COLORIZE") => ?env-var))
?color-fn ?env-var ?on-windows ?result
color/fail "FALSE" false "string"
color/fail "TRUE" false "\u001b[31mstring\u001b[0m"
color/fail "reverse" false "\u001b[41mstring\u001b[0m"
color/fail nil false "\u001b[31mstring\u001b[0m"
color/fail nil true "string"
color/note "FALSE" false "string"
color/note "TRUE" false "\u001b[36mstring\u001b[0m"
color/note "reverse" false "\u001b[46mstring\u001b[0m"
color/note nil false "\u001b[36mstring\u001b[0m"
color/note nil true "string")
;; Reset to user's default colorization.
(color/init!)
(fact "access environment vars only when namespace is loaded"
(do
(color/fail "a")
(color/note "b")
(color/fail "c")
(color/note "d")) => anything
(provided
(getenv "MIDJE_COLORIZE") => anything :times 0))