Skip to content
Browse files

add helpers for testing auth'd api

  • Loading branch information...
1 parent 8ff20c9 commit c712eed8eab36f2b71b7286a38369795281ab7ac @maddox maddox committed Apr 10, 2012
Showing with 31 additions and 1 deletion.
  1. +31 −1 test/helper.rb
View
32 test/helper.rb
@@ -27,4 +27,34 @@ def app
def parse_json(json)
Yajl.load(json, :symbolize_keys => true)
-end
+end
+
+def authorized_rack_header
+ user = User.create('maddox', 'maddox@github.com')
+ {"HTTP_AUTHORIZATION" => user.token}
+end
+
+def authorized_get(uri, opts={})
+ get uri, opts, authorized_rack_header
+end
+
+def authorized_post(uri, opts={})
+ post uri, opts, authorized_rack_header
+end
+
+def authorized_put(uri, opts={})
+ put uri, opts, authorized_rack_header
+end
+
+def authorized_delete(uri, opts={})
+ delete uri, opts, authorized_rack_header
+end
+
+def unauthorized_get(uri, opts={})
+ rack_env = {"HTTP_AUTHORIZATION" => "xxxxxxxxxxxxxxxxxx"}
+ get uri, opts, rack_env
+end
+
+
+
+

0 comments on commit c712eed

Please sign in to comment.
Something went wrong with that request. Please try again.