Permalink
Browse files

Use Streamer in all requests

  • Loading branch information...
1 parent 6581009 commit c6b9c837548fa5e4c7865c07f2ae6382330c7f61 @hakanensari hakanensari committed Jul 11, 2012
Showing with 11 additions and 13 deletions.
  1. +1 −4 examples/debug.rb
  2. +7 −2 lib/jeff.rb
  3. +3 −7 spec/jeff_spec.rb
View
@@ -28,10 +28,7 @@ def find(asins)
'ItemId' => Array(asins).join(',')
}
- streamer = Streamer.new
- res = get query: params, response_block: streamer
- res.body = streamer
- res
+ get query: params
end
private
View
@@ -89,8 +89,13 @@ def secret=(key)
Excon::HTTP_VERBS. each do |method|
eval <<-DEF
def #{method}(opts = {})
- opts.update method: :#{method}
- connection.request sign opts
+ streamer = Streamer.new
+ opts.update method: :#{method},
+ response_block: streamer
+ res = connection.request sign opts
+ res.body = streamer
+
+ res
end
DEF
end
View
@@ -120,22 +120,18 @@
Excon::HTTP_VERBS.each do |method|
describe "##{method}" do
- subject { client.send(method, mock: true).body }
+ subject { client.send(method, mock: true).body.root['request'] }
before do
Excon.stub({ method: method.to_sym }) do |params|
- { body: params }
+ { body: "<request>#{params[:method]}</request>" }
end
end
after { Excon.stubs.clear }
it "should make a #{method.upcase} request" do
- subject[:method].should eql method.to_sym
- end
-
- it 'should append a signature' do
- subject[:query].should match /.+&Signature=[^&]+$/
+ should eql method
end
end
end

0 comments on commit c6b9c83

Please sign in to comment.