/
running_spec.clj
106 lines (100 loc) · 3.54 KB
/
running_spec.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
(ns speclj.running-spec
(:use
[speclj.core]
[speclj.running :only (run-and-report)]
[speclj.results :only (pass? fail?)]
[speclj.run.standard :only (new-standard-runner)]
[speclj.config :only (*reporters* *runner* *tag-filter*)]
[speclj.report.silent :only (new-silent-reporter)])
(:import (speclj SpecFailure)))
(def bauble (atom nil))
(describe "Running"
(with runner (new-standard-runner))
(around [_]
; (println "#'runner: " (meta #'runner))
; (println "(deref #'runner): " (deref #'runner))
; (println "runner: " runner)
; (println "PUBLICS")
; (prn (ns-publics 'speclj.running-spec))
; (doseq [[key val] (ns-publics 'speclj.running-spec)]
; (println key (deref val)))
; (println *ns*)
; (println "runner: " runner)
; (println "(ns-resolve 'speclj.running-spec runner): " (ns-resolve 'speclj.running-spec 'runner))
; (println "deref (ns-resolve 'speclj.running-spec runner): " (deref (ns-resolve 'speclj.running-spec 'runner)))
; (println "@runner: " @runner)
(binding [*runner* @runner
*reporters* [(new-silent-reporter)]
*ns* (the-ns 'speclj.running-spec)]
(_)))
(it "tracks one pass"
(eval
'(describe "Dummy"
(it "has a pass"
(should (= 1 1)))))
(run-and-report *runner* *reporters*)
(let [results @(.results *runner*)
result (first results)]
(should= 1 (count results))
(should= "has a pass" (.name (.characteristic result)))
(should-not (fail? result))))
; (eval
; (it "tracks one fail"
; '(describe "Dummy"
; (it "has a fail"
; (should= 1 2))))
; (run-and-report *runner* *reporters*)
; (let [results @(.results *runner*)
; result (first results)]
; (should= 1 (count results))
; (should= "has a fail" (.name (.characteristic result)))
; (should-not= nil (.failure result))
; (should= SpecFailure (class (.failure result)))))
;
; (it "runs afters with failures"
; (eval
; '(describe "Dummy"
; (after (reset! bauble nil))
; (it "changes the bauble"
; (reset! bauble :something)
; (should-fail))))
; (run-and-report *runner* *reporters*)
; (should= nil @bauble))
;
; (it "runs afters with error"
; (eval
; '(describe "Dummy"
; (after (reset! bauble nil))
; (it "changes the bauble"
; (reset! bauble :something)
; (throw (Exception. "blah")))))
; (run-and-report *runner* *reporters*)
; (should= nil @bauble))
;
; (it "doesn't crash when declaring a with named the same as a pre-existing var"
; (let [spec
; `(describe "Dummy"
; (with bauble "foo")
; (it "uses the new value of bauble"
; (should= "foo" @bauble)))]
; (should-not-throw (eval spec))
; (run-and-report *runner* *reporters*)
; (let [results @(.results *runner*)
; result (first results)]
; (should= 1 (count results))
; (should-not (fail? result)))))
;
; (it "only executed contexts that pass the tag filter"
; (let [spec
; (eval
; `(describe "Dummy" (tags :one)
; (it "one tag" :filler)
; (context "Fool" (tags :two)
; (it "one, two tag" :filler))))]
; (binding [*tag-filter* {:includes #{:one :two} :excludes #{}}]
; (run-and-report *runner* *reporters*))
; (let [results @(.results *runner*)]
; (should= 1 (count results))
; (should= "one, two tag" (.name (.characteristic (first results)))))))
)
(run-specs)