yam 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/yam/api.rb +1 -6
- data/lib/yam/configuration.rb +1 -0
- data/lib/yam/connection.rb +1 -1
- data/lib/yam/request.rb +1 -1
- data/lib/yam/version.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/yam/client_spec.rb +12 -5
- data/spec/yam_spec.rb +6 -8
- metadata +2 -2
data/lib/yam/api.rb
CHANGED
@@ -25,6 +25,7 @@ module Yam
|
|
25
25
|
include Connection
|
26
26
|
include Request
|
27
27
|
attr_reader *Configuration::VALID_OPTIONS_KEYS
|
28
|
+
attr_reader :oauth_token, :endpoint
|
28
29
|
|
29
30
|
class_eval do
|
30
31
|
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
@@ -48,11 +49,5 @@ module Yam
|
|
48
49
|
send("#{key}=", options[key])
|
49
50
|
end
|
50
51
|
end
|
51
|
-
|
52
|
-
def method_missing(method, *args, &block)
|
53
|
-
if method.to_s.match /^(.*)\?$/
|
54
|
-
return !self.send($1.to_s).nil?
|
55
|
-
end
|
56
|
-
end
|
57
52
|
end
|
58
53
|
end
|
data/lib/yam/configuration.rb
CHANGED
data/lib/yam/connection.rb
CHANGED
data/lib/yam/request.rb
CHANGED
data/lib/yam/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/yam/client_spec.rb
CHANGED
@@ -16,28 +16,35 @@
|
|
16
16
|
# permissions and limitations under the License.
|
17
17
|
|
18
18
|
require 'spec_helper'
|
19
|
-
ENDPOINT = Yam::Configuration::DEFAULT_API_ENDPOINT
|
20
19
|
|
21
20
|
describe Yam::Client, '#get' do
|
22
21
|
it 'makes requests' do
|
23
|
-
stub_request(:get, ENDPOINT)
|
24
22
|
access_token = 'ABC123'
|
23
|
+
endpoint_with_token = "#{ENDPOINT}?access_token=#{access_token}"
|
24
|
+
stub_request(:get, endpoint_with_token).
|
25
|
+
with(:headers => { 'Authorization'=>'Token token="ABC123"' })
|
25
26
|
|
26
27
|
instance = Yam::Client.new(access_token, ENDPOINT)
|
27
28
|
instance.get('/')
|
28
29
|
|
29
|
-
expect(a_request(:get,
|
30
|
+
expect(a_request(:get, endpoint_with_token).
|
31
|
+
with(:headers => { 'Authorization'=>'Token token="ABC123"' })).
|
32
|
+
to have_been_made
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
describe Yam::Client, '#post' do
|
34
37
|
it 'makes requests' do
|
35
|
-
stub_request(:post, ENDPOINT)
|
36
38
|
access_token = 'ABC123'
|
39
|
+
endpoint_with_token = "#{ENDPOINT}?access_token=#{access_token}"
|
40
|
+
stub_request(:post, endpoint_with_token).
|
41
|
+
with(:headers => { 'Authorization'=>'Token token="ABC123"' })
|
37
42
|
|
38
43
|
instance = Yam::Client.new(access_token, ENDPOINT)
|
39
44
|
instance.post('/')
|
40
45
|
|
41
|
-
expect(a_request(:post,
|
46
|
+
expect(a_request(:post, endpoint_with_token).
|
47
|
+
with(:headers => { 'Authorization'=>'Token token="ABC123"' })).
|
48
|
+
to have_been_made
|
42
49
|
end
|
43
50
|
end
|
data/spec/yam_spec.rb
CHANGED
@@ -21,11 +21,9 @@ class TestClass
|
|
21
21
|
end
|
22
22
|
|
23
23
|
describe Yam do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
ENDPOINT = Yam::Configuration::DEFAULT_API_ENDPOINT
|
24
|
+
after do
|
25
|
+
Yam.set_defaults
|
26
|
+
end
|
29
27
|
|
30
28
|
it 'responds to \'new\' message' do
|
31
29
|
Yam.should respond_to :new
|
@@ -34,7 +32,7 @@ describe Yam do
|
|
34
32
|
it 'receives \'new\' and initialize an instance' do
|
35
33
|
access_token = 'ABC123'
|
36
34
|
|
37
|
-
instance = Yam.new(access_token,
|
35
|
+
instance = Yam.new(access_token, Yam::Configuration::DEFAULT_API_ENDPOINT)
|
38
36
|
|
39
37
|
instance.should be_a Yam::Client
|
40
38
|
end
|
@@ -43,7 +41,7 @@ describe Yam do
|
|
43
41
|
access_token = 'ABC123'
|
44
42
|
Yam::Client.any_instance.stubs(:stubbed_method)
|
45
43
|
|
46
|
-
instance = Yam.new(access_token,
|
44
|
+
instance = Yam.new(access_token, Yam::Configuration::DEFAULT_API_ENDPOINT)
|
47
45
|
instance.stubbed_method
|
48
46
|
|
49
47
|
Yam::Client.any_instance.should have_received(:stubbed_method)
|
@@ -63,7 +61,7 @@ describe Yam do
|
|
63
61
|
end
|
64
62
|
|
65
63
|
it 'returns the default end point' do
|
66
|
-
Yam.endpoint.should ==
|
64
|
+
Yam.endpoint.should == Yam::Configuration::DEFAULT_API_ENDPOINT
|
67
65
|
end
|
68
66
|
|
69
67
|
it 'allows setting the endpoint' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-12-
|
13
|
+
date: 2012-12-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hashie
|