fat_zebra 3.0.7 → 3.0.8

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: 618e6720f8f02177f35f4b23f6abebe58deed3aa
4
- data.tar.gz: 81d4a6d0c8817a79a491a513e76df2ca58a3249c
3
+ metadata.gz: 1f2329184b0e60cacc02215da4013523ab92bb73
4
+ data.tar.gz: 9c51d54b355199794f37019cb844bc71bbbfb215
5
5
  SHA512:
6
- metadata.gz: a3f2c60541dfed2240fabe1e9ad82c8d4dd8bb574541b63f0c282765b575163243351a2ff4d52ae343fcf7c42a749b99dc5b34f3513f386708b67f71c6d80c1a
7
- data.tar.gz: a0e013320cb329528bebe850588210de2eada793fe64829a3d8ec7c1012fe76316a78e07f18b324f0bad2044d576742dc92e3d26351e811708c3cbc22e5d351c
6
+ metadata.gz: 3bae07687f60d964bac95cd305c5f21f3a724f0e310286b8c15007d54c176d88964f3517e8b49dacbd3b55835b4c0248a4896ea1ce8cc3071d5c0d9bb0345fd0
7
+ data.tar.gz: 58bf0fd4d32eb643acb7b11464a10218afacdc8e52dc1c2d8d62fb565b500ab1975b1710026c3a9dd6e40b5bb58a4268e40022a73b2696f485f2f0c25df6046d
@@ -49,7 +49,10 @@ module FatZebra
49
49
 
50
50
  def initialize(params = {})
51
51
  @params = params
52
- @http = Net::HTTP.new(uri.host, uri.port, uri_proxy.host, uri_proxy.port)
52
+ @http = Net::HTTP.new(uri.host,
53
+ uri.port,
54
+ proxy_host,
55
+ uri_proxy.port)
53
56
 
54
57
  setup_ssl if params[:use_ssl]
55
58
  end
@@ -163,5 +166,12 @@ module FatZebra
163
166
  end
164
167
  end
165
168
 
169
+ def proxy_host
170
+ if !uri_proxy.host.nil?
171
+ uri_proxy.host
172
+ else
173
+ :ENV
174
+ end
175
+ end
166
176
  end
167
177
  end
@@ -1,3 +1,3 @@
1
1
  module FatZebra
2
- VERSION = '3.0.7'.freeze
2
+ VERSION = '3.0.8'.freeze
3
3
  end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe FatZebra::Request do
4
+ describe '#initalize' do
5
+ subject do
6
+ FatZebra::Request
7
+ .new(params)
8
+ .http
9
+ end
10
+ let(:params) do
11
+ {
12
+ url: 'https://cool.dudes/v2/swagtopia.json',
13
+ }.merge!(proxy_params)
14
+ end
15
+ let(:formatted_proxy) { [host, port].join(':') }
16
+ let(:formatted_host) { URI.parse(host).host }
17
+ let(:host) { "http://squidward.net" }
18
+ let(:port) { 6969 }
19
+
20
+ context 'with default params' do
21
+ let(:proxy_params) {{}}
22
+
23
+ it 'does not use a proxy configuration' do
24
+ expect(subject.proxy?).to eq(false)
25
+ end
26
+ end
27
+
28
+ context 'with env var specifying http proxy' do
29
+ let(:proxy_params) {{}}
30
+ before do
31
+ allow(ENV).to receive(:[]).with("NO_PROXY").and_return(nil)
32
+ allow(ENV).to receive(:[]).with("no_proxy").and_return(nil)
33
+ allow(ENV).to receive(:[]).with("http_proxy").and_return(formatted_proxy)
34
+ end
35
+
36
+ it 'draws the proxy configuration from the environment var' do
37
+ expect(subject.proxy?).to eq(true)
38
+ expect(subject.proxy_from_env?).to eq(true)
39
+ expect(subject.proxy_address).to eq(formatted_host)
40
+ expect(subject.proxy_port).to eq(port)
41
+ end
42
+ end
43
+
44
+ context 'with custom http_proxy params to the constructor passed via initializer or similar' do
45
+ let(:proxy_params) do
46
+ {
47
+ proxy: formatted_proxy
48
+ }
49
+ end
50
+
51
+ it 'draws the proxy host and port configuration from the environment var' do
52
+ expect(subject.proxy?).to eq(true)
53
+ expect(subject.proxy_from_env?).to eq(false)
54
+ expect(subject.proxy_address).to eq(formatted_host)
55
+ expect(subject.proxy_port).to eq(port)
56
+ end
57
+ end
58
+ end
59
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_zebra
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
4
+ version: 3.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Savage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-22 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -376,6 +376,7 @@ files:
376
376
  - spec/lib/fat_zebra/payment_plan_spec.rb
377
377
  - spec/lib/fat_zebra/purchase_spec.rb
378
378
  - spec/lib/fat_zebra/refund_spec.rb
379
+ - spec/lib/fat_zebra/request_spec.rb
379
380
  - spec/lib/fat_zebra/util_spec.rb
380
381
  - spec/lib/fat_zebra/validation_spec.rb
381
382
  - spec/lib/fat_zebra/web_hook_spec.rb
@@ -401,7 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
402
  version: '0'
402
403
  requirements: []
403
404
  rubyforge_project: fat_zebra
404
- rubygems_version: 2.6.8
405
+ rubygems_version: 2.4.5.2
405
406
  signing_key:
406
407
  specification_version: 4
407
408
  summary: Fat Zebra payments gem - integrate your ruby app with Fat Zebra