songkick-transport 1.10.1 → 1.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fcdee184d275b052c905e2ac432d44fd9537119
4
- data.tar.gz: a5734e06ba187e5732933e0317ec250ba0e1c19c
3
+ metadata.gz: 202b4b22c7239286ab5be97b564663de2d727173
4
+ data.tar.gz: c4bb87d2c9b8c54638ed7dbcd852c105192a2fc8
5
5
  SHA512:
6
- metadata.gz: f7b4bdef2b4a12f85627e396255d294b601af05dc74feec90fbc33d1ca21928c8d6ff0f8f3061b8eac92cff7a6058528d4946d5754143923e2a30351d51f181c
7
- data.tar.gz: 04418c68863395f6ee958a34e13fd45b473423765207f186d9a6244969f85a78fa07f404e6249dc9c95ca7890edcceba63b68f251785caa4ad1c86f105f9be47
6
+ metadata.gz: b13944a9f8f9c2d65fe0a70304bcb85125c1cecc2a504ddfd2c8278c116eef54bfc7126f7d19b403e62e3817471f8f86cb3d2eb74f3daa73c1537e1e6ae71ad5
7
+ data.tar.gz: 5a301688cd64bedd7b05a19ab1fbdb575879114808b47bcfbe92e5e9de88ca9f2a59d610d6a4c6d7493ce050044cd814cea4db33e5d412331af1124f3fadd377
@@ -6,7 +6,6 @@ module Songkick
6
6
  class HttParty
7
7
  def self.new(host, options = {})
8
8
  adapter_class = options.delete(:adapter) || Adapter
9
- adapter_class.base_uri(host)
10
9
  adapter_class.format(options[:format] || DEFAULT_FORMAT)
11
10
  adapter_class.default_timeout(options[:timeout] || DEFAULT_TIMEOUT)
12
11
  adapter_class.new(host, options)
@@ -16,16 +15,22 @@ module Songkick
16
15
  include HTTParty
17
16
 
18
17
  def endpoint
19
- self.class.base_uri
18
+ @host
20
19
  end
21
20
 
22
21
  def execute_request(req)
23
22
  timeout = req.timeout || self.class.default_options[:timeout]
24
23
 
24
+ req_options = {
25
+ :base_uri => @host,
26
+ :headers => req.headers,
27
+ :timeout => timeout
28
+ }
29
+
25
30
  response = if req.use_body?
26
- self.class.__send__(req.verb, req.path, :body => req.body, :headers => req.headers, :timeout => timeout)
31
+ self.class.__send__(req.verb, req.path, req_options.merge(:body => req.body))
27
32
  else
28
- self.class.__send__(req.verb, req.url, :headers => req.headers, :timeout => timeout)
33
+ self.class.__send__(req.verb, req.url, req_options)
29
34
  end
30
35
 
31
36
  process(req, response.code, response.headers, response.parsed_response)
@@ -252,7 +252,34 @@ shared_examples_for "Songkick::Transport" do
252
252
  expect(transport.user_error_codes).to eq([409])
253
253
  end
254
254
  end
255
+ end
256
+
257
+ shared_examples_for "Songkick::Transport::HttpAdapter" do
258
+ describe 'multiple instances of the adapter' do
259
+ let!(:first_adapter) { described_class.new('http://localhost:8181') }
260
+ let!(:second_adapter) { described_class.new('http://localhost:8282') }
261
+
262
+ before do
263
+ @first_test_app = TestApp.listen(8181)
264
+ @second_test_app = TestApp.listen(8282)
265
+ end
255
266
 
267
+ after do
268
+ @first_test_app.stop
269
+ @second_test_app.stop
270
+ sleep 1
271
+ end
272
+
273
+ it 'should have the right endpoint on each adapter' do
274
+ expect(first_adapter.endpoint).to eq('http://localhost:8181')
275
+ expect(second_adapter.endpoint).to eq('http://localhost:8282')
276
+ end
277
+
278
+ it 'should call the right endpoint on each adapter' do
279
+ expect(first_adapter.get('/host').data).to eq({"host" => "localhost:8181"})
280
+ expect(second_adapter.get('/host').data).to eq({"host" => "localhost:8282"})
281
+ end
282
+ end
256
283
  end
257
284
 
258
285
  # Curb always times out talking to the web server in the other thread when run on 1.8
@@ -262,6 +289,7 @@ unless RUBY_VERSION =~ /^1.8/
262
289
  let(:endpoint) { "http://localhost:4567" }
263
290
  let(:transport) { described_class.new(endpoint, options) }
264
291
  it_should_behave_like "Songkick::Transport"
292
+ it_should_behave_like "Songkick::Transport::HttpAdapter"
265
293
  end
266
294
  end
267
295
 
@@ -270,6 +298,7 @@ describe Songkick::Transport::HttParty do
270
298
  let(:endpoint) { "http://localhost:4567" }
271
299
  let(:transport) { described_class.new(endpoint, options) }
272
300
  it_should_behave_like "Songkick::Transport"
301
+ it_should_behave_like "Songkick::Transport::HttpAdapter"
273
302
  end
274
303
 
275
304
  describe Songkick::Transport::RackTest do
data/spec/spec_helper.rb CHANGED
@@ -26,6 +26,10 @@ class TestApp < Sinatra::Base
26
26
  '}'
27
27
  end
28
28
 
29
+ get '/host' do
30
+ Yajl::Encoder.encode({"host" => request.env["HTTP_HOST"]})
31
+ end
32
+
29
33
  get '/with_headers' do
30
34
  headers 'Set-Cookie' => ['a', 'b']
31
35
  '{}'
@@ -89,6 +93,7 @@ class TestApp < Sinatra::Base
89
93
  thin = Rack::Handler.get('thin')
90
94
  app = Rack::Lint.new(self)
91
95
  thin.run(app, :Port => port) { |s| @server = s }
96
+ @server
92
97
  end
93
98
 
94
99
  def self.stop
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: songkick-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.1
4
+ version: 1.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lucraft
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2016-02-17 00:00:00.000000000 Z
17
+ date: 2016-02-19 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: multipart-post
@@ -164,34 +164,34 @@ extra_rdoc_files:
164
164
  - README.rdoc
165
165
  files:
166
166
  - README.rdoc
167
- - examples/tcp_server.rb
168
167
  - examples/example.rb
169
- - examples/thread_safety.rb
170
168
  - examples/loop.rb
171
169
  - examples/server.rb
172
- - lib/songkick/transport/reporting.rb
173
- - lib/songkick/transport/rack_test.rb
174
- - lib/songkick/transport/headers.rb
175
- - lib/songkick/transport/response.rb
176
- - lib/songkick/transport/curb.rb
177
- - lib/songkick/transport/http_error.rb
178
- - lib/songkick/transport/httparty.rb
170
+ - examples/tcp_server.rb
171
+ - examples/thread_safety.rb
172
+ - lib/songkick/transport/serialization.rb
179
173
  - lib/songkick/transport/service.rb
180
- - lib/songkick/transport/request.rb
174
+ - lib/songkick/transport/response.rb
181
175
  - lib/songkick/transport/authentication.rb
182
- - lib/songkick/transport/serialization.rb
183
- - lib/songkick/transport/upstream_error.rb
176
+ - lib/songkick/transport/request.rb
184
177
  - lib/songkick/transport/base.rb
178
+ - lib/songkick/transport/httparty.rb
179
+ - lib/songkick/transport/curb.rb
180
+ - lib/songkick/transport/upstream_error.rb
181
+ - lib/songkick/transport/http_error.rb
182
+ - lib/songkick/transport/headers.rb
183
+ - lib/songkick/transport/rack_test.rb
184
+ - lib/songkick/transport/reporting.rb
185
185
  - lib/songkick/transport.rb
186
- - spec/spec_helper.rb
187
186
  - spec/songkick/transport_spec.rb
188
- - spec/songkick/transport/curb_spec.rb
189
187
  - spec/songkick/transport/service_spec.rb
190
- - spec/songkick/transport/request_spec.rb
191
188
  - spec/songkick/transport/authentication_spec.rb
192
189
  - spec/songkick/transport/httparty_spec.rb
193
190
  - spec/songkick/transport/base_spec.rb
191
+ - spec/songkick/transport/request_spec.rb
192
+ - spec/songkick/transport/curb_spec.rb
194
193
  - spec/songkick/transport/response_spec.rb
194
+ - spec/spec_helper.rb
195
195
  - lib/songkick/transport/html_report.html.erb
196
196
  homepage: http://github.com/songkick/transport
197
197
  licenses:
@@ -220,3 +220,4 @@ signing_key:
220
220
  specification_version: 4
221
221
  summary: HTTP client abstraction for service clients
222
222
  test_files: []
223
+ has_rdoc: