api_client 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/api_client.gemspec CHANGED
@@ -18,16 +18,16 @@ Gem::Specification.new do |s|
18
18
  s.specification_version = 3
19
19
 
20
20
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
21
- s.add_runtime_dependency(%q<faraday>, [">= 0.7.5"])
21
+ s.add_runtime_dependency(%q<faraday>, [">= 0.8.1"])
22
22
  s.add_runtime_dependency(%q<hashie>, [">= 1.2.0"])
23
23
  s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
24
24
  else
25
- s.add_dependency(%q<faraday>, [">= 0.7.5"])
25
+ s.add_dependency(%q<faraday>, [">= 0.8.1"])
26
26
  s.add_dependency(%q<hashie>, [">= 1.2.0"])
27
27
  s.add_dependency(%q<yajl-ruby>, [">= 0"])
28
28
  end
29
29
  else
30
- s.add_dependency(%q<faraday>, [">= 0.7.5"])
30
+ s.add_dependency(%q<faraday>, [">= 0.8.1"])
31
31
  s.add_dependency(%q<hashie>, [">= 1.2.0"])
32
32
  s.add_dependency(%q<yajl-ruby>, [">= 0"])
33
33
  end
@@ -30,9 +30,7 @@ module ApiClient
30
30
  # * headers - (optional) headers sent along with the request
31
31
  #
32
32
  def get(path, data = {}, headers = {})
33
- query = Faraday::Utils.build_nested_query(data || {})
34
- path = [path, query].join('?') unless query.empty?
35
- handle_response @handler.get(path, headers)
33
+ handle_response @handler.get(path, data, headers)
36
34
  end
37
35
 
38
36
  #### ApiClient::Connection::Abstract#post
@@ -71,9 +69,7 @@ module ApiClient
71
69
  #
72
70
  # This method automatically adds the application token header
73
71
  def delete(path, data = {}, headers = {})
74
- query = Faraday::Utils.build_nested_query(data || {})
75
- path = [path, query].join('?') unless query.empty?
76
- handle_response @handler.delete(path, headers)
72
+ handle_response @handler.delete(path, data, headers)
77
73
  end
78
74
 
79
75
  private
@@ -1,3 +1,3 @@
1
1
  module ApiClient
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -36,33 +36,43 @@ describe ApiClient::Connection::Basic do
36
36
  @headers = { "header" => "token" }
37
37
  @params = { "param" => "1", "nested" => { "param" => "1" } }
38
38
  @response = Faraday::Response.new(:status => 200)
39
+ @faraday_request_params = mock
40
+ @faraday_request = mock(:params => @faraday_request_params)
39
41
  end
40
42
 
41
43
  it "can perform GET requests" do
42
- @instance.handler.should_receive(:get) do |path, headers|
43
- headers.should == @headers
44
- Faraday::Utils.send(:parse_nested_query, path.split("?").last).should == @params
45
- @response
46
- end
44
+ @instance.handler.
45
+ should_receive(:run_request).
46
+ with(:get, '/home', nil, @headers).
47
+ and_yield(@faraday_request).
48
+ and_return(@response)
49
+ @faraday_request_params.should_receive(:update).with(@params)
47
50
  @instance.get "/home", @params, @headers
48
51
  end
49
52
 
50
53
  it "can perform POST requests" do
51
- @instance.handler.should_receive(:post).with("/home", @params, @headers).and_return(@response)
54
+ @instance.handler.
55
+ should_receive(:run_request).
56
+ with(:post, '/home', @params, @headers).
57
+ and_return(@response)
52
58
  @instance.post "/home", @params, @headers
53
59
  end
54
60
 
55
61
  it "can perform PUT requests" do
56
- @instance.handler.should_receive(:put).with("/home", @params, @headers).and_return(@response)
62
+ @instance.handler.
63
+ should_receive(:run_request).
64
+ with(:put, '/home', @params, @headers).
65
+ and_return(@response)
57
66
  @instance.put "/home", @params, @headers
58
67
  end
59
68
 
60
69
  it "can perform DELETE requests" do
61
- @instance.handler.should_receive(:delete) do |path, headers|
62
- headers.should == @headers
63
- Faraday::Utils.send(:parse_nested_query, path.split("?").last).should == @params
64
- @response
65
- end
70
+ @instance.handler.
71
+ should_receive(:run_request).
72
+ with(:delete, '/home', nil, @headers).
73
+ and_yield(@faraday_request).
74
+ and_return(@response)
75
+ @faraday_request_params.should_receive(:update).with(@params)
66
76
  @instance.delete "/home", @params, @headers
67
77
  end
68
78
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.7.5
21
+ version: 0.8.1
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.7.5
29
+ version: 0.8.1
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: hashie
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project: api_client
140
- rubygems_version: 1.8.21
140
+ rubygems_version: 1.8.24
141
141
  signing_key:
142
142
  specification_version: 3
143
143
  summary: API client builder