Skip to content

Commit

Permalink
Fixed raw creating invalid filenames under Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianBirch committed May 6, 2010
1 parent a7ba0c0 commit 2eeb1fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/circumspec/raw.clj
Expand Up @@ -5,7 +5,8 @@
(defn dump-file
"Create dump file name for a test run"
[]
(File. ".circumspec/raw/" (.toString (java.util.Date.))))
(File. (str ".circumspec/raw/" (.replace (.toString (java.util.Date.)) \: \_))))
; Replace colons with underscores for windows compatibility

(defn dump-results
"Spit results into a file, return java.io.File instance."
Expand Down
15 changes: 11 additions & 4 deletions test/circumspec/raw_test.clj
@@ -1,15 +1,22 @@
(ns circumspec.raw-test
(:use circumspec circumspec.raw))
(:use circumspec circumspec.raw)
(:import java.io.File)
)

;; TODO: better filename convention
(describe dump-file
(it "creates a file in .circumspec/raw"
(let [file (dump-file)]
(let [file (dump-file)
separator (java.io.File/separator)
escapedSeparator (if (= separator "\\") "\\\\" (str separator))
filePattern (str "[.]circumspec" escapedSeparator "raw" escapedSeparator ".*")
]
(should (instance? java.io.File file))
(should (re-find #"\.circumspec/raw/.*" (.toString file))))))
(should (not (re-find #":" (.toString file))))
(should (re-find (re-pattern filePattern) (.toString file))))))

(describe dump-results
(it "writes complete restuls to a file"
(it "writes complete results to a file"
(let [file (dump-results (take 2 (repeat {:sample true})))]
(should (= "{:sample true}\n{:sample true}\n" (slurp (.toString file))))
(should (.delete file) "deleting sample result data"))))

0 comments on commit 2eeb1fb

Please sign in to comment.