Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gar3thjon3s committed Oct 29, 2011
0 parents commit 0eb3b3c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
@@ -0,0 +1,6 @@
pom.xml
*jar
/lib/
/classes/
.lein-failures
.lein-deps-sum
31 changes: 31 additions & 0 deletions README.md
@@ -0,0 +1,31 @@
# lein-expectations

A leiningen plugin to make running tests written using [expectations](https://github.com/jaycfields/expectations) library.

## Usage

In your project.clj:

:dev-dependencies [[lein-expectations "0.0.1"]]

or install as a plugin:

$ lein plugin install lein-expectations "0.0.1"

To run all your tests:

$ lein expectations

To run specific test namespaces:

$ lein expectations my.test.namespace1 my.test.namespace2

To run test namespaces by regex:

$ lein expectations my.tests.foo.* my.tests.bar.*

## License

Copyright (C) 2011 FIXME

Distributed under the Eclipse Public License, the same as Clojure.
4 changes: 4 additions & 0 deletions project.clj
@@ -0,0 +1,4 @@
(defproject lein-expectations "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.2.1"]]
:eval-in-leiningen true)
30 changes: 30 additions & 0 deletions src/leiningen/expectations.clj
@@ -0,0 +1,30 @@
(ns leiningen.expectations
(:use [leiningen.compile :only [eval-in-project]]
[leiningen.util.ns :only [namespaces-in-dir]]))

(defn matching-ns?
[to-match]
(fn [ns]
(if (empty? to-match)
ns
(->> (for [m to-match
:let [m (re-pattern m)]]
(re-matches m (name ns)))
(some identity)))))

(defn expectations
"Executes expectation tests in your project.
By default all test namespaces will be run, or you can specify
which namespaces to run using regex syntax to filter."
[project & args]
(let [ns (->> (namespaces-in-dir (:test-path project))
(filter (matching-ns? args)))]
(eval-in-project
project
`(do
(doseq [n# '~ns]
(require n# :reload)))
nil
nil
'(require ['expectations]))))

0 comments on commit 0eb3b3c

Please sign in to comment.