math-api 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/math-api.rb +5 -2
- data/spec/mathapi_spec.rb +1 -1
- metadata +1 -1
data/lib/math-api.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'pp'
|
2
3
|
|
3
4
|
module Math
|
4
5
|
class API
|
5
6
|
|
6
|
-
VERSION = "0.0.
|
7
|
+
VERSION = "0.0.3"
|
7
8
|
|
8
9
|
include HTTParty
|
9
10
|
format :json
|
@@ -23,9 +24,11 @@ module Math
|
|
23
24
|
|
24
25
|
|
25
26
|
def authenticate
|
26
|
-
|
27
|
+
|
28
|
+
resp = self.class.get('/api/1/users/profile.json', query: { accesskey: @accesskey })
|
27
29
|
|
28
30
|
raise Error.new("Unauthorized") unless resp.code == 200
|
31
|
+
|
29
32
|
end
|
30
33
|
|
31
34
|
|
data/spec/mathapi_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe Math::API do
|
|
26
26
|
before(:all) do
|
27
27
|
FakeWeb.clean_registry
|
28
28
|
|
29
|
-
FakeWeb.register_uri(:get, "#{API_ROOT}/api/1/users/profile.json", :status => ["200"])
|
29
|
+
FakeWeb.register_uri(:get, "#{API_ROOT}/api/1/users/profile.json?accesskey=#{ACCESSKEY}", :status => ["200"])
|
30
30
|
FakeWeb.register_uri(:post, "#{API_ROOT}/api/1/users/#{USER_ID}/records.json", :status => ["201"])
|
31
31
|
|
32
32
|
@api = Math::API.new( accesskey: ACCESSKEY, user_id: USER_ID, math_url: API_ROOT )
|