Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Switch over remaining tests to clojure.test.

  • Loading branch information...
commit 881fab0b3ce9c802d3ba4563482c9ecdabae2933 1 parent 1abaf7c
@duelinmarkers authored
View
2  README.textile
@@ -133,7 +133,7 @@ Attribute serialization uses clojure.core's pr and read functions, so anything t
---
-clj-record is being TDD'd using clojure.contrib.test-is, largely with high-level full-stack tests, so see "the tests":http://github.com/duelinmarkers/clj-record/tree/master/test/clj_record for details of everything that works.
+clj-record is being TDD'd using clojure.test, largely with high-level full-stack tests, so see "the tests":http://github.com/duelinmarkers/clj-record/tree/master/test/clj_record for details of everything that works.
See "TODO.txt":http://github.com/duelinmarkers/clj-record/tree/master/TODO.txt for what else I'm thinking about, and feel free to suggest.
View
11 test/clj_record/associations_test.clj
@@ -2,7 +2,7 @@
(:require
[clj-record.test-model.manufacturer :as manufacturer]
[clj-record.test-model.product :as product])
- (:use clojure.contrib.test-is
+ (:use clojure.test
clj-record.test-helper))
@@ -33,9 +33,8 @@
prod3 (product/create {:name "prod3" :manufacturer_id (:id manu2)})
prod4 (product/create {:name "prod4" :manufacturer_id (:id manu2)})]
(let [[eager-manu1 eager-manu2] (manufacturer/find-records {:grade 99} {:include [:products]})]
- (are (= _1 _2)
- "manu1" (:name eager-manu1)
- "manu2" (:name eager-manu2)
- [prod1 prod2] (:products eager-manu1)
- [prod3 prod4] (:products eager-manu2)))))
+ (is (= "manu1" (:name eager-manu1)))
+ (is (= "manu2" (:name eager-manu2)))
+ (is (= [prod1 prod2] (:products eager-manu1)))
+ (is (= [prod3 prod4] (:products eager-manu2))))))
)
View
2  test/clj_record/callbacks_built_ins_test.clj
@@ -1,5 +1,5 @@
(ns clj-record.callbacks-built-ins-test
- (:use clojure.contrib.test-is)
+ (:use clojure.test)
(:require [clj-record.callbacks.built-ins :as cbfunc]))
View
2  test/clj_record/callbacks_test.clj
@@ -2,7 +2,7 @@
(:require
[clj-record.test-model.manufacturer :as manufacturer]
[clj-record.callbacks :as callbacks])
- (:use clojure.contrib.test-is
+ (:use clojure.test
clj-record.test-helper))
View
2  test/clj_record/main.clj
@@ -1,6 +1,6 @@
(ns clj-record.main
(:require [clojure.contrib.sql :as sql]
- [clojure.contrib.test-is :as test-is])
+ [clojure.test :as test-is])
(:use clj-record.test-model.config
clojure.contrib.str-utils))
View
4 test/clj_record/query_test.clj
@@ -4,7 +4,7 @@
[clj-record.query :as query]
[clj-record.test-model.manufacturer :as manufacturer]
[clj-record.test-model.product :as product])
- (:use clojure.contrib.test-is
+ (:use clojure.test
clj-record.test-helper))
@@ -64,7 +64,7 @@
(is (= #{sozooke foyoto ghysler} (set (manufacturer/find-records {:name (query/not-in "GMB Motors" "Merledas Automotive")}))))))
(deftest attempt-to-supply-nil-value
- (are (thrown? IllegalArgumentException _1)
+ (are [bad-call] (thrown? IllegalArgumentException bad-call)
(query/equal nil)
(query/not-equal nil)
(query/greater-than nil)
View
10 test/clj_record/serialization_test.clj
@@ -2,17 +2,17 @@
(:require
[clj-record.serialization :as serialization]
[clj-record.test-model.manufacturer :as manufacturer])
- (:use clojure.contrib.test-is
+ (:use clojure.test
clj-record.test-helper))
(deftest serializes-simple-clojure-types
- (are (= _1 (serialization/serialize _2))
+ (are [serialized-value value] (= serialized-value (serialization/serialize value))
"\"123\"" "123"
"123" 123))
(deftest serializes-and-deserializes-clojure-types-symmetrically
- (are (= _1 (serialization/deserialize (serialization/serialize _1)))
+ (are [value] (= value (serialization/deserialize (serialization/serialize value)))
nil
[1 2 3]
{:a "Aee" :b "Bee" :c "See"}
@@ -23,8 +23,8 @@
(restoring-ref (manufacturer/model-metadata)
(serialization/serialize-attribute "manufacturer" :name)
(let [record (manufacturer/create valid-manufacturer)]
- (are (=
- (do (manufacturer/update (assoc record :name _1)) _1)
+ (are [value] (=
+ (do (manufacturer/update (assoc record :name value)) value)
((manufacturer/get-record (record :id)) :name))
"some string"
23
View
2  test/clj_record/test_helper.clj
@@ -1,6 +1,6 @@
(ns clj-record.test-helper
(:require [clj-record.core :as core])
- (:use clojure.contrib.test-is))
+ (:use clojure.test))
(defmacro defdbtest [name & body]
View
2  test/clj_record/underscore_test.clj
@@ -2,7 +2,7 @@
(:require
[clj-record.test-model.thing-one :as thing-one]
[clj-record.test-model.thing-two :as thing-two])
- (:use clojure.contrib.test-is
+ (:use clojure.test
clj-record.test-helper))
View
32 test/clj_record/util_test.clj
@@ -1,10 +1,11 @@
(ns clj-record.util-test
(:require
[clj-record.util :as util])
- (:use clojure.contrib.test-is))
+ (:use clojure.test))
-(deftest singularize (are (= _1 (util/singularize _2))
+(deftest singularize
+ (are [singular plural] (= singular (util/singularize plural))
"foo" "foos"
"baby" "babies"
"beach" "beaches"
@@ -14,7 +15,8 @@
"visit" "visits"
"type" "types"))
-(deftest pluralize (are (= _1 (util/pluralize _2))
+(deftest pluralize
+ (are [plural singular] (= plural (util/pluralize singular))
"foos" "foo"
"beaches" "beach"
"babies" "baby"
@@ -23,21 +25,12 @@
"buses" "bus"
"types" "type"))
-(deftest provides-id-query-for-derby
- (are (= _1 (util/id-query-for _2 "table_name"))
- "VALUES IDENTITY_VAL_LOCAL()" {:classname "org.apache.derby.jdbc.EmbeddedDriver" :subprotocol "derby"}))
-
-(deftest provides-id-query-for-postgresql
- (are (= _1 (util/id-query-for _2 "table_name"))
- "SELECT currval(pg_get_serial_sequence('table_name','id'))" {:classname "org.postgresql.Driver" :subprotocol "postgresql"}))
-
-(deftest provides-id-query-for-mysql
- (are (= _1 (util/id-query-for _2 "table_name"))
- "SELECT LAST_INSERT_ID()" {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql"}))
-
-(deftest provides-id-query-for-h2
- (are (= _1 (util/id-query-for _2 "table_name"))
- "CALL IDENTITY()" {:subprotocol "h2"}))
+(deftest provides-id-queries-for-various-drivers
+ (are [id-query db-spec] (= id-query (util/id-query-for db-spec "table_name"))
+ "VALUES IDENTITY_VAL_LOCAL()" {:classname "org.apache.derby.jdbc.EmbeddedDriver" :subprotocol "derby"}
+ "SELECT currval(pg_get_serial_sequence('table_name','id'))" {:classname "org.postgresql.Driver" :subprotocol "postgresql"}
+ "SELECT LAST_INSERT_ID()" {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql"}
+ "CALL IDENTITY()" {:subprotocol "h2"}))
(deftest throws-if-asked-for-id-query-of-unrecognized-db-spec
(is (thrown? Exception
@@ -47,7 +40,6 @@
(str "made up query"))
(deftest provides-id-query-for-whatever-dbms-you-like-if-you-defmethod-for-it
- (are (= _1 (util/id-query-for _2 "table_name"))
- "made up query" {:subprotocol "fake subprotocol"}))
+ (is (= "made up query" (util/id-query-for {:subprotocol "fake subprotocol"} "table_name"))))
View
14 test/clj_record/validation_built_ins_test.clj
@@ -1,12 +1,12 @@
(ns clj-record.validation-built-ins-test
- (:use clojure.contrib.test-is)
+ (:use clojure.test)
(:require [clj-record.validation.built-ins :as v]))
(deftest match-creates-a-matching-fn-for-the-given-pattern
(let [matches-foo? (v/match #"foo")]
(is (matches-foo? "yes foo does"))
- (are (not (matches-foo? _1))
+ (are [s] (not (matches-foo? s))
"no bar doesn't"
nil
123))
@@ -16,20 +16,20 @@
(deftest non-match-creates-an-anti-matching-fn-for-the-given-pattern
(let [non-matches-foo? (v/non-match #"foo")]
(is (not (non-matches-foo? "foo doesn't not")))
- (are (non-matches-foo? _1)
+ (are [s] (non-matches-foo? s)
"bar non-matches"
nil
123)))
(deftest numeric?
- (are (v/numeric? _1)
+ (are [n] (v/numeric? n)
123
"123")
- (are (not (v/numeric? _1))
+ (are [s] (not (v/numeric? s))
"foo"))
(deftest email?
- (are (v/email? _1)
+ (are [s] (v/email? s)
"a@b.cd"
"abcdef@abcdef.abcdef.abc"
"a.b@c.de"
@@ -37,7 +37,7 @@
"a-b@c.de"
"a@b.c.de"
"a@b-c.de")
- (are (not (v/email? _1))
+ (are [s] (not (v/email? s))
""
"a"
"abcdef"
View
4 test/clj_record/validation_test.clj
@@ -3,7 +3,7 @@
[clj-record.validation :as validation]
[clj-record.test-model.manufacturer :as manufacturer]
[clj-record.test-model.product :as product])
- (:use clojure.contrib.test-is))
+ (:use clojure.test))
(deftest validate-returns-valid-for-a-model-without-validations
@@ -28,6 +28,6 @@
(deftest validate-with-errors-on-multiple-attributes
(let [validation-result (manufacturer/validate {:name "" :founded "oh"})]
- (are (= _1 (validation/messages-for validation-result _2))
+ (are [messages attribute-name] (= messages (validation/messages-for validation-result attribute-name))
["empty!"] :name
["must be numeric"] :founded)))
Please sign in to comment.
Something went wrong with that request. Please try again.