Permalink
Browse files

Merge branch 'master' into arohner_master

Conflicts:
	project.clj
	src/tentacles/core.clj
  • Loading branch information...
2 parents 709b0a8 + 2929e95 commit c5f3835abd941e2b7a257a07e2703fc50308914b @arohner arohner committed May 5, 2012
Showing with 6 additions and 124 deletions.
  1. +5 −7 project.clj
  2. +1 −2 src/tentacles/core.clj
  3. +0 −29 test/tentacles/core_test.clj
  4. +0 −4 test/tentacles/test_utils.clj
  5. +0 −82 test/tentacles/users_test.clj
View
@@ -1,8 +1,6 @@
-(defproject tentacles "0.1.3"
+(defproject tentacles "0.1.4"
:description "A library for working with the Github API."
- :dependencies [[clojure "1.3.0"]
- [clj-http "0.2.5"]
- [cheshire "2.0.2"]
- [slingshot "0.9.0"]
- [com.cemerick/url "0.0.6"]]
- :dev-dependencies [[midje "1.3.0-RC4"]])
+ :dependencies [[org.clojure/clojure "1.4.0"]
+ [clj-http "0.4.0"]
+ [cheshire "4.0.0"]
+ [com.cemerick/url "0.0.6"]])
View
@@ -47,8 +47,7 @@
If 400, 422, 404, 204, or 500, return the original response with the body parsed
as json. Otherwise, parse and return the body."
[resp]
-
- (if (#{400 204 422 404 500} (:status resp))
+ (if (#{400 401 204 422 404 500} (:status resp))
(update-in resp [:body] parse-json)
(let [links (parse-links (get-in resp [:headers "link"] ""))]
(with-meta (parse-json (:body resp)) {:links links}))))
@@ -1,29 +0,0 @@
-(ns tentacles.core-test
- (:use midje.sweet
- tentacles.core))
-
-(fact
- (query-map {:foo 0
- :foo-bar 0
- "baz-quux" 0}) => {"foo" 0 "foo_bar" 0 "baz_quux" 0})
-
-(fact
- (parse-json nil) => nil?
- (parse-json "{\"foo\" : 0}") => {:foo 0})
-
-(letfn [(status-map [status] {:status status :body 0})]
- (tabular
- (fact
- (safe-parse {:status ?status :body "0"}) => ?expected
- (provided))
- ?status ?expected
- 404 (status-map 404)
- 400 (status-map 400)
- 422 (status-map 422)
- 500 (status-map 500)
- 204 (status-map 204)
- 200 0))
-
-(fact
- (no-content? {:status 204}) => truthy
- (no-content? {:status 200}) => falsey)
@@ -1,4 +0,0 @@
-(ns tentacles.test-utils)
-
-(def test-info (read-string (slurp "testinfo.clj")))
-(def auth {:auth (str (:user test-info) ":" (:pass test-info))})
@@ -1,82 +0,0 @@
-(ns tentacles.users-test
- (:use tentacles.users
- tentacles.test-utils
- midje.sweet))
-
-(against-background
- [(around :contents (let [my (me auth)
- loc (:location my)]
- ?form))]
- (fact "Returns a user info map."
- (user "amalloy") => (contains {:login "amalloy"}))
-
- (fact "Contains the authenticated user's info."
- my => (contains {:login (:user test-info)}))
-
- (fact "Edits a user's info."
- (against-background
- (after :facts (edit-user (merge auth {:location loc}))))
- (edit-user (merge auth {:location "foo"})) => (contains {:location "foo"})))
-
-(against-background
- [(around :contents (let [adds (emails auth)
- fake-email ["foo@bar.baz"]]
- ?form))]
- (fact "A sequence of email strings."
- adds => (has every? string?))
-
- (fact "Contains the added email."
- (add-emails fake-email auth) => (contains fake-email))
-
- (fact "Does not contain the deleted email."
- (delete-emails fake-email auth) =not=> (contains fake-email)))
-
-
-(fact "A sequence of maps."
- (followers "Raynes") => (has every? map?))
-
-(fact "A sequence of maps."
- (my-followers auth) => (has every? map?))
-
-(fact "A sequence of maps."
- (following "Raynes") => (has every? map?))
-
-(fact "A sequence of maps."
- (my-following auth) => (has every? map?))
-
-(fact "User does follow this user."
- (following? (:follows test-info) auth) => truthy)
-
-(fact "User does not follow this user."
- (following? "ni3rfj34infn34" auth) => falsey)
-
-(fact "Can follow a user."
- (follow "defunkt" auth) => truthy)
-
-(fact "Can unfollow that user."
- (unfollow "defunkt" auth) => truthy)
-
-(fact "Cannot unfollow a non-existent user."
- (unfollow "3nv4nvoi45n" auth) => falsey)
-
-(against-background
- [(around :contents (let [ks (keys auth)
- key (first ks)]
- ?form))]
- (fact "A sequence of maps of keys."
- ks => (has every? map?))
-
- (fact "Can get a specific key with an id."
- (specific-key (:id key) auth) => key))
-
-(against-background
- [(around :contents (let [new-key (create-key "foo" "ssh-rsa fakefakefakefake" auth)]
- ?form))]
- (fact "Can create a new key."
- new-key => (contains {:title "foo"}))
-
- (fact "Can edit tht key."
- (edit-key (:id new-key) (merge auth {:title "bar"})) => (contains {:title "bar"}))
-
- (fact "Can delete that key."
- (delete-key (:id new-key) auth) => truthy))

0 comments on commit c5f3835

Please sign in to comment.