yam 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -14,6 +14,7 @@
14
14
  #
15
15
  # See the Apache Version 2.0 License for specific language governing
16
16
  # permissions and limitations under the License.
17
+
17
18
  require 'yam/version'
18
19
 
19
20
  module Yam
@@ -34,7 +34,7 @@ module Yam
34
34
  USER_AGENT => user_agent
35
35
  },
36
36
  :ssl => { :verify => true },
37
- :url => options.fetch(:endpoint) { Yam.endpoint }
37
+ :url => options.fetch(:endpoint) { endpoint }
38
38
  }.merge(options)
39
39
  end
40
40
 
data/lib/yam/request.rb CHANGED
@@ -30,7 +30,7 @@ module Yam
30
30
  conn = connection(options)
31
31
  path = (conn.path_prefix + path).gsub(/\/\//,'/') if conn.path_prefix != '/'
32
32
 
33
- response = conn.send(method,path,params)
33
+ response = conn.send(method, path, params)
34
34
  response.body
35
35
  end
36
36
  end
data/lib/yam/version.rb CHANGED
@@ -16,5 +16,5 @@
16
16
  # permissions and limitations under the License.
17
17
 
18
18
  module Yam
19
- VERSION = '0.0.4'
19
+ VERSION = '0.0.5'
20
20
  end
data/spec/spec_helper.rb CHANGED
@@ -26,6 +26,8 @@ require 'yam'
26
26
  require 'webmock/rspec'
27
27
  require 'bourne'
28
28
 
29
+ ENDPOINT = Yam::Configuration::DEFAULT_API_ENDPOINT
30
+
29
31
  RSpec.configure do |config|
30
32
  config.mock_with :mocha
31
33
  config.include WebMock::API
@@ -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, ENDPOINT)).to have_been_made
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, ENDPOINT)).to have_been_made
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
- # after do
25
- # Yam.set_defaults
26
- # end
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, ENDPOINT)
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, ENDPOINT)
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 == ENDPOINT
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
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 00:00:00.000000000 Z
13
+ date: 2012-12-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hashie