boa_vista 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjA4OTMwMzkxMDcwNzdmNjE5MTAxOWYxYWMyODgyM2ExMGJkOGNmMg==
4
+ N2NiOTk2YTgzM2U2ODc5MWFhOWEzMTA0NjQ2YWQxMzRhMzgwNzYzYw==
5
5
  data.tar.gz: !binary |-
6
- YWY2NjM3MDlmZTdhOWU4OGIxNzJiODAxYmE1MGRlYTI3YTU4ZTQ5YQ==
6
+ MmVmYjA4NDk3NDVmMmIwMGRjYzg4NTJmN2E4OGQ4NjcyMGVlNjczYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjA0NTY2ZTNlZTJmN2Q0NzQ1YzY2ZTI1MTE3Mjc0MDg4ODgzOTEwMTYzMmU3
10
- MGJmOTU4ZjhiY2U2NDRiOTk4ZWJmYTYzY2NiYjk1MzU4Zjc4Zjc4ZWE0MDZh
11
- MzU2ZjQxNDg5NGE3YWIyMzNhMjFjNDNkNTlmN2JmNjIyZjhkMWQ=
9
+ OTE5MDcwMDUyNGQ2MGQyY2UwNjZjYTJlYjEzZTE1MjEyNjM5ZmRkMmZmNTZj
10
+ YjAxOTU2NTc0MzRiZTk1NDk2YjMxYTBmOTQ5Mzk4YTY0YTc2ZDNlZTU2YmRh
11
+ NDJmZGE5Nzc2NTAxMjE5ZTMzNjUzNjlhOWUxMzk5MmE1ZjJkZDM=
12
12
  data.tar.gz: !binary |-
13
- MDVmOTY4MjVlZWE0ZGE2ZmY5MTY5MmQ4ZTNkOTk1ODUzNDkxNjQ1MGJjYTgx
14
- ODAxOThhYjEwNmYzODVjZGU1NGI5Njc1MjVhNjhmZGFiYjc5YzIwZmFiZGJh
15
- M2VjYTY1NWVjMTJlMzM5N2E5YWYwYzFjMjc3YjZlNDk2NzI0NWQ=
13
+ YTcwNzliYTgxYzU5NTI1NTU4YjM4ODlhMzQyODYyMjU4ZTVjNjFhNDEzNWE5
14
+ Y2QwNjU5NjQ1ZWI5M2JmYmM5YzMxMDYyNWEyZjM0ZGUwYmQxZTIzNTAxZDU5
15
+ MTg1YWY5YzM5MGZiMjIxYTE4N2RmNWQ4ZmI3Y2NjODAyMWRjNmY=
@@ -16,12 +16,12 @@ module BoaVista
16
16
  def execute_request_using_proxy
17
17
  BoaVista.log(:debug, "Executing with proxy: #{BoaVista.configuration.proxy_url}")
18
18
  BoaVista.log(:debug, "Executing request for uri: #{@uri}")
19
- ::Faraday.new(proxy: BoaVista.configuration.proxy_url, url: @uri).get
19
+ ::Faraday.new(proxy: BoaVista.configuration.proxy_url, url: @uri, ssl: { verify: false, version: 'TLSv1'}).get
20
20
  end
21
21
 
22
22
  def execute_request
23
23
  BoaVista.log(:debug, "Executing request for uri: #{@uri}")
24
- ::Faraday.new(url: @uri).get
24
+ ::Faraday.new(url: @uri, ssl: { verify: false, version: 'TLSv1'}).get
25
25
  end
26
26
  end
27
27
  end
@@ -4,9 +4,11 @@ module BoaVista
4
4
  extend self
5
5
 
6
6
  def build(*args)
7
- (args + default_args).reverse.inject({}) do |acc, attrs|
7
+ acc = (args + default_args).reverse.inject({}) do |acc, attrs|
8
8
  acc.merge(attrs)
9
9
  end
10
+ acc[:document_number] = acc[:document_number].rjust(14, '0')
11
+ acc
10
12
  end
11
13
 
12
14
  protected
@@ -1,3 +1,3 @@
1
1
  module BoaVista
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
@@ -0,0 +1,56 @@
1
+ RSpec.describe BoaVista::Http do
2
+ let(:instance) { described_class.new(url) }
3
+ let(:proxy_url) { 'www.proxy.com' }
4
+ let(:url) { 'www.bla.com' }
5
+ let(:ssl) { { verify: false, version: 'TLSv1'} }
6
+ let(:connection) { instance_double(Faraday::Connection) }
7
+
8
+ before do
9
+ allow(Faraday).to receive(:new).and_return(connection)
10
+ end
11
+
12
+ describe "#call" do
13
+ context 'when use proxy' do
14
+ before do
15
+ BoaVista.configure do |config|
16
+ config.proxy_url = proxy_url
17
+ end
18
+ end
19
+
20
+ subject { instance.call }
21
+
22
+ it 'calls execute using proxy' do
23
+ expect(instance).to receive(:execute_request_using_proxy).once
24
+ subject
25
+ end
26
+
27
+ it 'call faraday with proxy' do
28
+ expect(Faraday).to receive(:new).with(proxy: proxy_url, url: url, ssl: ssl).once
29
+ expect(connection).to receive(:get).once
30
+ subject
31
+ end
32
+ end
33
+ end
34
+
35
+ context 'when dont use proxy' do
36
+ before do
37
+ BoaVista.configure do |config|
38
+ config.proxy_url = nil
39
+ end
40
+ end
41
+
42
+
43
+ subject { instance.call }
44
+
45
+ it 'calls execute request' do
46
+ expect(instance).to receive(:execute_request).once
47
+ subject
48
+ end
49
+
50
+ it 'call faraday' do
51
+ expect(Faraday).to receive(:new).with(url: url, ssl: ssl).once
52
+ expect(connection).to receive(:get).once
53
+ subject
54
+ end
55
+ end
56
+ end
@@ -35,7 +35,7 @@ RSpec.describe BoaVista::Line do
35
35
  subject { instance.write }
36
36
 
37
37
  its(:size) { is_expected.to eq(142) }
38
- it { is_expected.to eq('CSR60 01 CODE PASSWORDCADPJ 032C2 X') }
38
+ it { is_expected.to eq('CSR60 01 CODE PASSWORDCADPJ 032C200000000000000 X') }
39
39
  end
40
40
  end
41
41
 
@@ -51,7 +51,7 @@ RSpec.describe BoaVista::Line do
51
51
  subject { instance.write }
52
52
 
53
53
  its(:size) { is_expected.to eq(84) }
54
- it { is_expected.to eq('CSR60 01 CODE PASSWORDSINTON 012C1 X') }
54
+ it { is_expected.to eq('CSR60 01 CODE PASSWORDSINTON 012C100000000000000X') }
55
55
  end
56
56
  end
57
57
 
@@ -9,7 +9,7 @@ RSpec.describe BoaVista::Request::Factory do
9
9
  describe '.build' do
10
10
  it 'returns the attributes' do
11
11
  expect(cpf_factory_attributes).to be_a_instance_of(Hash)
12
- expect(cpf_factory_attributes[:document_number]).to eq('30630968810')
12
+ expect(cpf_factory_attributes[:document_number]).to eq('00030630968810')
13
13
  expect(cpf_factory_attributes[:document_type]).to eq('1')
14
14
  expect(cpf_factory_attributes[:transaction]).to eq('CSR60')
15
15
  expect(cpf_factory_attributes[:code]).to eq('CODE')
@@ -1,3 +1,3 @@
1
1
  RSpec.describe BoaVista::VERSION do
2
- specify { expect(BoaVista::VERSION).to eq '0.0.11' }
2
+ specify { expect(BoaVista::VERSION).to eq '0.0.12' }
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boa_vista
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Souza
@@ -171,6 +171,7 @@ files:
171
171
  - spec/lib/boa_vista/field/writer_spec.rb
172
172
  - spec/lib/boa_vista/field_spec.rb
173
173
  - spec/lib/boa_vista/fixtures.rb
174
+ - spec/lib/boa_vista/http_spec.rb
174
175
  - spec/lib/boa_vista/line_spec.rb
175
176
  - spec/lib/boa_vista/request/default_spec.rb
176
177
  - spec/lib/boa_vista/request/factory_spec.rb
@@ -240,6 +241,7 @@ test_files:
240
241
  - spec/lib/boa_vista/field/writer_spec.rb
241
242
  - spec/lib/boa_vista/field_spec.rb
242
243
  - spec/lib/boa_vista/fixtures.rb
244
+ - spec/lib/boa_vista/http_spec.rb
243
245
  - spec/lib/boa_vista/line_spec.rb
244
246
  - spec/lib/boa_vista/request/default_spec.rb
245
247
  - spec/lib/boa_vista/request/factory_spec.rb