boa_vista_stubs 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0285aad01b8149445d2509b9c8c2b1e772515db5
4
- data.tar.gz: a8351f090e2728fb2a9f3f270f6d95445eb929e3
3
+ metadata.gz: 3f9c44e27cc8598668404368b23b3ed57b4e7ffc
4
+ data.tar.gz: 083306f952237798684b1c4c0d23d8d8d05a4705
5
5
  SHA512:
6
- metadata.gz: 6ee9eb48ca639b6edbfb1392b60012d5658f032c042f5d89501123f6fd6a451a621ab8eb86e7f7cd35d7d286b45835360d862314e260ee519e3e50aa62a8cb2c
7
- data.tar.gz: e06f1760029b1012cd03471839c25780e80fce19b83cebbd0103c445adcd775a617a88ddcd52d9374b123af0176a60d3feeb0a1a9be8b78cf5f0b98397f4e099
6
+ metadata.gz: 7e1c26c3ed01681a5b836133676883f17fa0594637c8715495d2fb2373038336d406aa4255c3f6584e2cfb05b0a24a2c569b511cb94dc94d2d85402673995f35
7
+ data.tar.gz: 36dcfff66e211d60dc23d4257264f32d7ca80e82451d43164a5e2f2385f3bf9ff2be0cf11c4395b492603ba738f3b0dfc7d8a6741d15c03d1dcb45b98f40bc74
@@ -2,7 +2,7 @@ module BoaVistaStubs
2
2
  module Document::Extension
3
3
 
4
4
  def timeout_document?
5
- validator(document_number).timeout?
5
+ validator(document_number).timeout_document?
6
6
  end
7
7
 
8
8
  protected
@@ -2,7 +2,7 @@ module BoaVistaStubs
2
2
  class Document
3
3
  class Response::Cnpj < Response::Base
4
4
  LAYOUTS = {
5
- valid: 138,
5
+ valid: 353,
6
6
  invalid: 901
7
7
  }
8
8
 
@@ -2,7 +2,7 @@ module BoaVistaStubs
2
2
  class Document
3
3
  class Response::Cpf < Response::Base
4
4
  LAYOUTS = {
5
- valid: 221,
5
+ valid: 249,
6
6
  invalid: 999
7
7
  }
8
8
 
@@ -0,0 +1,13 @@
1
+ module BoaVistaStubs
2
+ class DocumentService
3
+ class Sleep
4
+ def self.invoke
5
+ sleep(timeout_seconds_required)
6
+ end
7
+
8
+ def self.timeout_seconds_required
9
+ BoaVista.configuration.timeout + 1
10
+ end
11
+ end
12
+ end
13
+ end
@@ -5,10 +5,10 @@ module BoaVistaStubs
5
5
  # Returns a Document::CPF or Document::CNPJ instance
6
6
  document = BoaVistaStubs::Document.identify(search_params)
7
7
 
8
- Timeout.invoke if document.timeout_document?
8
+ BoaVistaStubs::DocumentService::Sleep.invoke if document.timeout_document?
9
9
 
10
10
  # Returns a Document::Response::CPF or Document::Response::CNPJ
11
- response = BoaVistaStubs::Document::Response.identify(document.document_type)
11
+ response = BoaVistaStubs::Document::Response.identify(document.document_type).new
12
12
 
13
13
  if document.valid?
14
14
  # renders valid response for specific type of document
@@ -1,3 +1,3 @@
1
1
  module BoaVistaStubs
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -110,3 +110,47 @@ Processing by BoaVistaStubs::RequestsController#index as HTML
110
110
  Parameters: {"consulta"=>"my search string"}
111
111
  Rendered text template (0.0ms)
112
112
  Completed 200 OK in 22.7ms (Views: 22.1ms)
113
+ Processing by BoaVistaStubs::RequestsController#index as HTML
114
+ Parameters: {"consulta"=>"my search string"}
115
+ Rendered text template (0.0ms)
116
+ Completed 200 OK in 39.9ms (Views: 39.1ms)
117
+ Processing by BoaVistaStubs::RequestsController#index as HTML
118
+ Parameters: {"consulta"=>"my search string"}
119
+ Rendered text template (0.0ms)
120
+ Completed 200 OK in 24.4ms (Views: 23.5ms)
121
+ Processing by BoaVistaStubs::RequestsController#index as HTML
122
+ Parameters: {"consulta"=>"my search string"}
123
+ Rendered text template (0.0ms)
124
+ Completed 200 OK in 6.4ms (Views: 6.0ms)
125
+ Processing by BoaVistaStubs::RequestsController#index as HTML
126
+ Parameters: {"consulta"=>"my search string"}
127
+ Rendered text template (0.1ms)
128
+ Completed 200 OK in 6.0ms (Views: 5.6ms)
129
+ Processing by BoaVistaStubs::RequestsController#index as HTML
130
+ Parameters: {"consulta"=>"my search string"}
131
+ Rendered text template (0.0ms)
132
+ Completed 200 OK in 22.7ms (Views: 22.0ms)
133
+ Processing by BoaVistaStubs::RequestsController#index as HTML
134
+ Parameters: {"consulta"=>"my search string"}
135
+ Rendered text template (0.0ms)
136
+ Completed 200 OK in 22.0ms (Views: 21.1ms)
137
+ Processing by BoaVistaStubs::RequestsController#index as HTML
138
+ Parameters: {"consulta"=>"my search string"}
139
+ Rendered text template (0.0ms)
140
+ Completed 200 OK in 39.8ms (Views: 38.9ms)
141
+ Processing by BoaVistaStubs::RequestsController#index as HTML
142
+ Parameters: {"consulta"=>"my search string"}
143
+ Rendered text template (0.0ms)
144
+ Completed 200 OK in 23.3ms (Views: 22.7ms)
145
+ Processing by BoaVistaStubs::RequestsController#index as HTML
146
+ Parameters: {"consulta"=>"my search string"}
147
+ Rendered text template (0.0ms)
148
+ Completed 200 OK in 22.8ms (Views: 22.2ms)
149
+ Processing by BoaVistaStubs::RequestsController#index as HTML
150
+ Parameters: {"consulta"=>"my search string"}
151
+ Rendered text template (0.0ms)
152
+ Completed 200 OK in 24.5ms (Views: 23.7ms)
153
+ Processing by BoaVistaStubs::RequestsController#index as HTML
154
+ Parameters: {"consulta"=>"my search string"}
155
+ Rendered text template (0.0ms)
156
+ Completed 200 OK in 22.8ms (Views: 22.1ms)
@@ -0,0 +1,16 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe BoaVistaStubs::DocumentService::Sleep do
4
+ describe '.invoke' do
5
+ let(:timeout_seconds_required) { 2 }
6
+
7
+ before do
8
+ allow(BoaVista.configuration).to receive(:timeout) { 1 }
9
+ end
10
+
11
+ it 'sleeps for some time' do
12
+ expect(described_class).to receive(:sleep).with(timeout_seconds_required)
13
+ described_class.invoke
14
+ end
15
+ end
16
+ end
@@ -3,6 +3,7 @@ require 'rails_helper'
3
3
  RSpec.describe BoaVistaStubs::DocumentService do
4
4
  describe '#call' do
5
5
  let(:document) { BoaVistaStubs::Document::Cpf.new('12345') }
6
+ let(:fake_class) { double }
6
7
 
7
8
  before do
8
9
  allow(BoaVistaStubs::Document).to receive(:identify).with('search params') { document }
@@ -13,8 +14,10 @@ RSpec.describe BoaVistaStubs::DocumentService do
13
14
  allow(document).to receive(:timeout_document?) { true }
14
15
  end
15
16
 
16
- it 'raises timeout error' do
17
- expect { BoaVistaStubs::DocumentService.call('search params') }.to raise_error(BoaVista::Errors::Timeout)
17
+ it 'calls sleep to cause timeout error' do
18
+ expect(BoaVistaStubs::DocumentService::Sleep).to receive(:invoke)
19
+
20
+ BoaVistaStubs::DocumentService.call('search params')
18
21
  end
19
22
  end
20
23
 
@@ -25,7 +28,8 @@ RSpec.describe BoaVistaStubs::DocumentService do
25
28
  allow(document).to receive(:valid?) { true }
26
29
  allow(document).to receive(:timeout_document?) { false }
27
30
 
28
- allow(BoaVistaStubs::Document::Response).to receive(:identify).with(anything) { response }
31
+ allow(BoaVistaStubs::Document::Response).to receive(:identify).with(anything) { fake_class }
32
+ allow(fake_class).to receive(:new) { response }
29
33
  end
30
34
 
31
35
  it 'returns the valid response' do
@@ -40,7 +44,8 @@ RSpec.describe BoaVistaStubs::DocumentService do
40
44
  allow(document).to receive(:valid?) { false }
41
45
  allow(document).to receive(:timeout_document?) { false }
42
46
 
43
- allow(BoaVistaStubs::Document::Response).to receive(:identify).with(anything) { response }
47
+ allow(BoaVistaStubs::Document::Response).to receive(:identify).with(anything) { fake_class }
48
+ allow(fake_class).to receive(:new) { response }
44
49
  end
45
50
 
46
51
  it 'returns the invalid response' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boa_vista_stubs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kleber Shimabuku
@@ -107,7 +107,7 @@ files:
107
107
  - app/models/boa_vista_stubs/document/response/cpf.rb
108
108
  - app/models/boa_vista_stubs/document/validate_expression.rb
109
109
  - app/services/boa_vista_stubs/document_service.rb
110
- - app/services/boa_vista_stubs/document_service/timeout.rb
110
+ - app/services/boa_vista_stubs/document_service/sleep.rb
111
111
  - app/views/layouts/boa_vista_stubs/application.html.erb
112
112
  - config/routes.rb
113
113
  - lib/boa_vista_stubs.rb
@@ -167,7 +167,7 @@ files:
167
167
  - spec/models/boa_vista_stubs/document/validate_expression_spec.rb
168
168
  - spec/models/boa_vista_stubs/document_spec.rb
169
169
  - spec/rails_helper.rb
170
- - spec/services/document_service/timeout_spec.rb
170
+ - spec/services/document_service/sleep_spec.rb
171
171
  - spec/services/document_service_spec.rb
172
172
  - spec/spec_helper.rb
173
173
  homepage: https://github.com/klebershimabuku/boa_vista_stubs
@@ -247,6 +247,6 @@ test_files:
247
247
  - spec/models/boa_vista_stubs/document/validate_expression_spec.rb
248
248
  - spec/models/boa_vista_stubs/document_spec.rb
249
249
  - spec/rails_helper.rb
250
- - spec/services/document_service/timeout_spec.rb
250
+ - spec/services/document_service/sleep_spec.rb
251
251
  - spec/services/document_service_spec.rb
252
252
  - spec/spec_helper.rb
@@ -1,7 +0,0 @@
1
- module BoaVistaStubs
2
- class DocumentService::Timeout
3
- def self.invoke
4
- fail(BoaVista::Errors::Timeout)
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe BoaVistaStubs::DocumentService::Timeout do
4
- describe '.invoke' do
5
- it { expect { described_class.invoke }.to raise_error(BoaVista::Errors::Timeout) }
6
- end
7
- end