This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns blog-expectations | |
(:use expectations)) | |
(expect (interaction (spit "/tmp/hello-world" "some data" :append true)) | |
(do | |
(spit "/tmp/somewhere-else" "nil") | |
(spit "/tmp/hello-world" "some data" :append true))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(expect (interaction (one "hello" {:a :b :c {:dd :ee :ff :gg}})) | |
(do | |
(one "hello") | |
(one "hello" "world" "here") | |
(one "hello" {:a 1 2 3}))) | |
; expected: (one "hello" {:a :b, :c {:ff :gg, :dd :ee}}) once | |
; | |
; got: (one "hello") | |
; {:a :b, :c {:ff :gg, :dd :ee}} are in expected, but not in actual |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(expect (interaction (one "hello" :anything)) | |
(one "help" {:a 1 2 3})) | |
; expected: (one "hello" :anything) once | |
; | |
; got: (one "help" {2 3, :a 1}) | |
; expected arg1: hello | |
; actual arg1: help | |
; matches: "hel" | |
; diverges: "lo" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns blog-expectations | |
(:use expectations) | |
(:import [org.joda.time DateTime])) | |
(defn add-timestamp [m] | |
(assoc m :time (DateTime.))) | |
(expect {:time (DateTime. 1)} | |
(freeze-time (DateTime. 1) | |
(add-timestamp {}))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns blog-expectations | |
(:use expectations) | |
(:import [org.joda.time DateTime])) | |
(defn timestamp-event [m t] | |
(assoc m :time t)) | |
(expect-let [now (DateTime.)] | |
{:time now} | |
(timestamp-event {} now)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns blog-expectations | |
(:use expectations.scenarios)) | |
(scenario | |
;;; real tests will call domain code, | |
;;; I avoid that here for simplicity | |
(let [x [1 2] | |
y (map-indexed vector x)] | |
(expect vector? x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(scenario | |
(do-work) | |
(do-more-work) | |
(expect a b) | |
(expect c d) | |
(expect e f)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns blog-expectations | |
(:use expectations)) | |
(given [expected actual] | |
(expect expected | |
(let [x [1 2] | |
y (map-indexed vector x)] | |
actual)) | |
vector? x | |
[0 1] (first y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns blog-expectations | |
(:use expectations)) | |
(expect vector? [1 2]) | |
(given [x y-fn] (expect x | |
(y-fn | |
(map-indexed vector [1 2]))) | |
[0 1] first | |
java.util.List identity) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns blog-expectations | |
(:use expectations)) | |
(expect vector? [1 2]) | |
(given [x y-fn] (expect x | |
(y-fn | |
(map-indexed vector [1 2]))) | |
[0 1] first | |
java.util.List identity) |