ey_api_hmac 0.0.10 → 0.0.11

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ey_api_hmac (0.0.10.pre)
4
+ ey_api_hmac (0.0.11.pre)
5
5
  json
6
6
  rack-client
7
7
 
@@ -7,7 +7,7 @@ module EY
7
7
  class BaseConnection
8
8
  attr_reader :auth_id, :auth_key
9
9
 
10
- def initialize(auth_id, auth_key, user_agent = nil, &rack_builder_block)
10
+ def initialize(auth_id, auth_key, user_agent = nil)
11
11
  @auth_id = auth_id
12
12
  @auth_key = auth_key
13
13
  @standard_headers = {
@@ -16,7 +16,6 @@ module EY
16
16
  'HTTP_DATE' => Time.now.httpdate,
17
17
  'USER_AGENT' => user_agent || default_user_agent
18
18
  }
19
- @rack_builder_block = rack_builder_block
20
19
  end
21
20
 
22
21
  def default_user_agent
@@ -69,7 +68,7 @@ module EY
69
68
  request(:get, url, &block)
70
69
  end
71
70
 
72
- def handle_errors_with(error_handler)
71
+ def handle_errors_with(&error_handler)
73
72
  @error_handler = error_handler
74
73
  end
75
74
 
@@ -80,12 +79,8 @@ module EY
80
79
  #damn you scope!
81
80
  auth_id_arg = auth_id
82
81
  auth_key_arg = auth_key
83
- rack_builder_block = @rack_builder_block
84
82
  @client ||= Rack::Client.new do
85
83
  use EY::ApiHMAC::ApiAuth::Client, auth_id_arg, auth_key_arg
86
- if rack_builder_block
87
- instance_eval(&rack_builder_block)
88
- end
89
84
  run bak
90
85
  end
91
86
  end
@@ -101,7 +96,7 @@ module EY
101
96
  handle_response(url, response, &block)
102
97
  rescue => e
103
98
  request_hash = {:method => method, :url => url, :headers => request_headers, :body => body}
104
- response_hash = {:status => response.status, :body => response.body} if response
99
+ response_hash = {:status => response.status, :body => response.body, :headers => response.headers} if response
105
100
  handle_error(request_hash, (response_hash || {}), e) || (raise e)
106
101
  end
107
102
 
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module ApiHMAC
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
  end
5
5
  end
@@ -17,19 +17,27 @@ describe EY::ApiHMAC::BaseConnection do
17
17
  end
18
18
  it "calls the error handler if one is registered" do
19
19
  errors = []
20
- @connection.handle_errors_with(lambda {|*args| errors << [args]; "handled"})
20
+ @connection.handle_errors_with{|*args| errors << [args]; "handled"}
21
21
  @connection.post("/", "blah").should eq("handled")
22
22
  end
23
23
  end
24
24
  describe "on bad body" do
25
25
  it "calls the error handler" do
26
26
  @connection.backend = lambda do |env|
27
- ["200", {"Content-Type" => "application/json"}, "200 OK"]
27
+ ["200", {"Content-Type" => "application/json"}, ["200 OK"]]
28
28
  end
29
29
  errors = []
30
- @connection.handle_errors_with(lambda {|*args| errors << [args]; false})
30
+ @connection.handle_errors_with{|*args| errors << args; false}
31
31
  lambda { @connection.post("/", "blah") {} }.should raise_exception(JSON::ParserError)
32
32
  errors.should_not be_empty
33
+ request, response, exception = *errors.first
34
+ request[:url].should eq("/")
35
+ request[:body].should eq("blah")
36
+ request[:method].should eq :post
37
+ request[:headers]["Accept"].should eq "application/json"
38
+ response[:status].should eq 200
39
+ response[:body].should eq("200 OK")
40
+ response[:headers].should eq({"Content-Type" => "application/json"})
33
41
  end
34
42
  end
35
43
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_api_hmac
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 10
10
- version: 0.0.10
9
+ - 11
10
+ version: 0.0.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Jacob Burkhart & Thorben Schr\xC3\xB6der & David Calavera & others"