boa_vista_stubs 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/boa_vista_stubs/document/extension.rb +1 -1
- data/app/models/boa_vista_stubs/document/response/cnpj.rb +1 -1
- data/app/models/boa_vista_stubs/document/response/cpf.rb +1 -1
- data/app/services/boa_vista_stubs/document_service/sleep.rb +13 -0
- data/app/services/boa_vista_stubs/document_service.rb +2 -2
- data/lib/boa_vista_stubs/version.rb +1 -1
- data/spec/dummy/log/test.log +44 -0
- data/spec/services/document_service/sleep_spec.rb +16 -0
- data/spec/services/document_service_spec.rb +9 -4
- metadata +4 -4
- data/app/services/boa_vista_stubs/document_service/timeout.rb +0 -7
- data/spec/services/document_service/timeout_spec.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f9c44e27cc8598668404368b23b3ed57b4e7ffc
|
4
|
+
data.tar.gz: 083306f952237798684b1c4c0d23d8d8d05a4705
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e1c26c3ed01681a5b836133676883f17fa0594637c8715495d2fb2373038336d406aa4255c3f6584e2cfb05b0a24a2c569b511cb94dc94d2d85402673995f35
|
7
|
+
data.tar.gz: 36dcfff66e211d60dc23d4257264f32d7ca80e82451d43164a5e2f2385f3bf9ff2be0cf11c4395b492603ba738f3b0dfc7d8a6741d15c03d1dcb45b98f40bc74
|
@@ -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
|
-
|
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
|
data/spec/dummy/log/test.log
CHANGED
@@ -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 '
|
17
|
-
expect
|
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) {
|
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) {
|
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.
|
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/
|
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/
|
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/
|
250
|
+
- spec/services/document_service/sleep_spec.rb
|
251
251
|
- spec/services/document_service_spec.rb
|
252
252
|
- spec/spec_helper.rb
|