correios_sigep 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/correios_sigep.gemspec +1 -1
- data/lib/correios_sigep/logistic_reverse/base_client.rb +3 -4
- data/lib/correios_sigep/version.rb +1 -1
- metadata +4 -90
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.rubocop.yml +0 -1160
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -16
- data/Gemfile +0 -8
- data/Rakefile +0 -15
- data/bin/rake +0 -16
- data/spec/correios_sigep/builders/xml/request_collect_number_spec.rb +0 -22
- data/spec/correios_sigep/builders/xml/request_spec.rb +0 -34
- data/spec/correios_sigep/builders/xml/request_sro_spec.rb +0 -17
- data/spec/correios_sigep/configuration_spec.rb +0 -87
- data/spec/correios_sigep/logistic_reverse/base_client_spec.rb +0 -93
- data/spec/correios_sigep/logistic_reverse/request_collect_number_spec.rb +0 -106
- data/spec/correios_sigep/logistic_reverse/request_sro_spec.rb +0 -86
- data/spec/correios_sigep/models/collect_spec.rb +0 -149
- data/spec/correios_sigep/models/logistic_reverse_spec.rb +0 -221
- data/spec/correios_sigep/models/object_spec.rb +0 -53
- data/spec/correios_sigep/models/product_spec.rb +0 -37
- data/spec/correios_sigep/models/recipient_spec.rb +0 -108
- data/spec/correios_sigep/models/sender_spec.rb +0 -141
- data/spec/correios_sigep/models/sro_spec.rb +0 -40
- data/spec/correios_sigep_spec.rb +0 -27
- data/spec/fixtures/builders/logistic_reverse.xml +0 -66
- data/spec/fixtures/builders/request_collect_number.xml +0 -64
- data/spec/fixtures/builders/request_sro.xml +0 -4
- data/spec/fixtures/correios/request_collect_number/response_already_in_use.xml +0 -14
- data/spec/fixtures/correios/request_collect_number/response_inexistent_zipcode.xml +0 -14
- data/spec/fixtures/correios/request_collect_number/response_not_answered_for_zipcode.xml +0 -14
- data/spec/fixtures/correios/request_collect_number/response_not_configured_client.xml +0 -14
- data/spec/fixtures/correios/request_collect_number/response_success.xml +0 -27
- data/spec/fixtures/correios/request_collect_number/response_unavailable_house_collect.xml +0 -14
- data/spec/fixtures/correios/request_collect_number/response_unavailable_service.xml +0 -14
- data/spec/fixtures/correios/request_collect_number/response_unexpected.xml +0 -14
- data/spec/fixtures/correios/request_sro/response_array_success.xml +0 -38
- data/spec/fixtures/correios/request_sro/response_collect_number_not_found.xml +0 -13
- data/spec/fixtures/correios/request_sro/response_required_fields.xml +0 -13
- data/spec/fixtures/correios/request_sro/response_sro_not_ready.xml +0 -30
- data/spec/fixtures/correios/request_sro/response_success.xml +0 -30
- data/spec/fixtures/correios/request_sro/response_unknown_error.xml +0 -13
- data/spec/fixtures/correios/wsdl.xml +0 -650
- data/spec/fixtures/requests/collect_number_request.xml +0 -66
- data/spec/fixtures/requests/sro_request.xml +0 -6
- data/spec/spec_helper.rb +0 -39
- data/spec/support/fixture_helper.rb +0 -13
- data/spec/support/logistic_reverse_helper.rb +0 -15
@@ -1,149 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CorreiosSigep
|
4
|
-
module Models
|
5
|
-
describe Collect do
|
6
|
-
it { should respond_to :aditional_service }
|
7
|
-
it { should respond_to :ag }
|
8
|
-
it { should respond_to :ar }
|
9
|
-
it { should respond_to :card }
|
10
|
-
it { should respond_to :checklist }
|
11
|
-
it { should respond_to :client_id }
|
12
|
-
it { should respond_to :declared_value }
|
13
|
-
it { should respond_to :description }
|
14
|
-
it { should respond_to :number }
|
15
|
-
it { should respond_to :type }
|
16
|
-
it { should respond_to :product }
|
17
|
-
it { should respond_to :product_params }
|
18
|
-
it { should respond_to :sender }
|
19
|
-
it { should respond_to :sender_params }
|
20
|
-
it { should respond_to :objects }
|
21
|
-
|
22
|
-
describe '#initialize' do
|
23
|
-
let(:collect) { described_class.new params }
|
24
|
-
|
25
|
-
context 'with aditional service param' do
|
26
|
-
let(:params) { { aditional_service: '100.5' } }
|
27
|
-
it 'set aditional service value' do
|
28
|
-
expect(collect.aditional_service).to eq '100.5'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'with ag param' do
|
33
|
-
let(:params) { { ag: '1' } }
|
34
|
-
it 'set ag value' do
|
35
|
-
expect(collect.ag).to eq '1'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'with ar param' do
|
40
|
-
let(:params) { { ar: '2' } }
|
41
|
-
it 'set ar value' do
|
42
|
-
expect(collect.ar).to eq '2'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'with card param' do
|
47
|
-
let(:params) { { card: '12345' } }
|
48
|
-
it 'set card value' do
|
49
|
-
expect(collect.card).to eq '12345'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'with checklist param' do
|
54
|
-
let(:params) { { checklist: 'CK' } }
|
55
|
-
it 'set checklist value' do
|
56
|
-
expect(collect.checklist).to eq 'CK'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'with client_id param' do
|
61
|
-
let(:params) { { client_id: '10965' } }
|
62
|
-
it 'set client_id value' do
|
63
|
-
expect(collect.client_id).to eq '10965'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'with declared value param' do
|
68
|
-
let(:params) { { declared_value: '200.5' } }
|
69
|
-
it 'set declared_value value' do
|
70
|
-
expect(collect.declared_value).to eq '200.5'
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'with description param' do
|
75
|
-
let(:params) { { description: 'description' } }
|
76
|
-
it 'set declared_value value' do
|
77
|
-
expect(collect.description).to eq 'description'
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context 'with number param' do
|
82
|
-
let(:params) { { number: 3 } }
|
83
|
-
it 'set number value' do
|
84
|
-
expect(collect.number).to eq 3
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context 'with type param' do
|
89
|
-
let(:params) { { type: 'type' } }
|
90
|
-
it 'set type value' do
|
91
|
-
expect(collect.type).to eq 'type'
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
context 'with product param' do
|
97
|
-
let(:product) { double('product') }
|
98
|
-
let(:params) { { product: product } }
|
99
|
-
it 'set product as the object passed in param' do
|
100
|
-
expect(collect.product).to eq product
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context 'with product_params param' do
|
105
|
-
let(:params) { { product_params: { code: 'code' } } }
|
106
|
-
it 'set product as new object created with passed product_params' do
|
107
|
-
expect(collect.product).to be_a CorreiosSigep::Models::Product
|
108
|
-
expect(collect.product.code).to eq 'code'
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context 'with sender param' do
|
113
|
-
let(:sender) { double('sender') }
|
114
|
-
let(:params) { { sender: sender } }
|
115
|
-
it 'set sender as the object passed in param' do
|
116
|
-
expect(collect.sender).to eq sender
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'with sender_params param' do
|
121
|
-
let(:params) { { sender_params: { name: 'sender name' } } }
|
122
|
-
it 'set sender as new object created with passed sender_params' do
|
123
|
-
expect(collect.sender).to be_a CorreiosSigep::Models::Sender
|
124
|
-
expect(collect.sender.name).to eq 'sender name'
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
context 'objects param' do
|
129
|
-
context 'present' do
|
130
|
-
let(:objects) { [ double('object1'), double('object2') ] }
|
131
|
-
let(:params) { { objects: objects } }
|
132
|
-
it 'return the objects passed in parameter' do
|
133
|
-
expect(collect.objects.size).to eq 2
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context 'not present' do
|
138
|
-
let(:params) { {} }
|
139
|
-
it 'returns an empty array' do
|
140
|
-
expect(collect.objects).to be_a(Array)
|
141
|
-
expect(collect.objects).to be_empty
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
@@ -1,221 +0,0 @@
|
|
1
|
-
module CorreiosSigep
|
2
|
-
module Models
|
3
|
-
describe LogisticReverse do
|
4
|
-
it { should respond_to :collect }
|
5
|
-
it { should respond_to :recipient }
|
6
|
-
|
7
|
-
describe ".build" do
|
8
|
-
let(:recipient) do
|
9
|
-
CorreiosSigep::Models::Recipient.new({
|
10
|
-
address: 'Endereco',
|
11
|
-
area_code: 'DDD',
|
12
|
-
city: 'Cidade',
|
13
|
-
complement: 'Complemento',
|
14
|
-
email: 'Email',
|
15
|
-
name: 'Nome',
|
16
|
-
neighborhood: 'Bairro',
|
17
|
-
number: 'Numero',
|
18
|
-
phone: 'Telefone',
|
19
|
-
postal_code: 'CEP',
|
20
|
-
reference: 'Referencia',
|
21
|
-
state: 'Estado'
|
22
|
-
})
|
23
|
-
end
|
24
|
-
|
25
|
-
let(:sender) do
|
26
|
-
CorreiosSigep::Models::Sender.new({
|
27
|
-
address: 'Endereco',
|
28
|
-
area_code: 'DDD',
|
29
|
-
city: 'Cidade',
|
30
|
-
complement: 'Complemento',
|
31
|
-
email: 'Email',
|
32
|
-
name: 'Nome',
|
33
|
-
neighborhood: 'Bairro',
|
34
|
-
number: 'Numero',
|
35
|
-
phone: 'Telefone',
|
36
|
-
postal_code: 'CEP',
|
37
|
-
reference: 'Referencia',
|
38
|
-
state: 'Estado'
|
39
|
-
})
|
40
|
-
end
|
41
|
-
|
42
|
-
let(:collect) do
|
43
|
-
CorreiosSigep::Models::Collect.new({
|
44
|
-
aditional_service: '10.00',
|
45
|
-
ag: '5',
|
46
|
-
ar: '1',
|
47
|
-
card: '',
|
48
|
-
checklist: '2',
|
49
|
-
client_id: '102030',
|
50
|
-
declared_value: '1000.00',
|
51
|
-
description: 'Descricao',
|
52
|
-
number: '',
|
53
|
-
type: 'A'
|
54
|
-
})
|
55
|
-
end
|
56
|
-
|
57
|
-
let(:product) do
|
58
|
-
CorreiosSigep::Models::Product.new({
|
59
|
-
code: '116600403',
|
60
|
-
type: '0',
|
61
|
-
quantity: 1
|
62
|
-
})
|
63
|
-
end
|
64
|
-
|
65
|
-
subject do
|
66
|
-
described_class.build do
|
67
|
-
with_recipient do
|
68
|
-
address 'Endereco'
|
69
|
-
area_code 'DDD'
|
70
|
-
city 'Cidade'
|
71
|
-
complement 'Complemento'
|
72
|
-
email 'Email'
|
73
|
-
name 'Nome'
|
74
|
-
neighborhood 'Bairro'
|
75
|
-
number 'Numero'
|
76
|
-
phone 'Telefone'
|
77
|
-
postal_code 'CEP'
|
78
|
-
reference 'Referencia'
|
79
|
-
state 'Estado'
|
80
|
-
end
|
81
|
-
|
82
|
-
with_collect do
|
83
|
-
aditional_service '10.00'
|
84
|
-
ag '5'
|
85
|
-
ar '1'
|
86
|
-
card ''
|
87
|
-
checklist '2'
|
88
|
-
client_id '102030'
|
89
|
-
declared_value '1000.00'
|
90
|
-
description 'Descricao'
|
91
|
-
number ''
|
92
|
-
type 'A'
|
93
|
-
|
94
|
-
with_sender do
|
95
|
-
address 'Endereco'
|
96
|
-
area_code 'DDD'
|
97
|
-
city 'Cidade'
|
98
|
-
complement 'Complemento'
|
99
|
-
email 'Email'
|
100
|
-
name 'Nome'
|
101
|
-
neighborhood 'Bairro'
|
102
|
-
number 'Numero'
|
103
|
-
phone 'Telefone'
|
104
|
-
postal_code 'CEP'
|
105
|
-
reference 'Referencia'
|
106
|
-
state 'Estado'
|
107
|
-
end
|
108
|
-
|
109
|
-
with_product do
|
110
|
-
code '116600403'
|
111
|
-
type '0'
|
112
|
-
quantity 1
|
113
|
-
end
|
114
|
-
|
115
|
-
add_object do
|
116
|
-
item 'Item'
|
117
|
-
id '1'
|
118
|
-
description 'Descricao'
|
119
|
-
num ''
|
120
|
-
end
|
121
|
-
|
122
|
-
add_object do
|
123
|
-
item 'Item'
|
124
|
-
id '2'
|
125
|
-
description 'Descricao'
|
126
|
-
num ''
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'initializes with the correct recipient' do
|
133
|
-
%i(address area_code city complement email name neighborhood number
|
134
|
-
phone postal_code reference state).each do |property|
|
135
|
-
expect(subject.recipient.send(property)).to eq(recipient.send(property))
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'initializes with the correct collect' do
|
140
|
-
%i(aditional_service ag ar card checklist declared_value description
|
141
|
-
number type client_id).each do |property|
|
142
|
-
expect(subject.collect.send(property)).to eq(collect.send(property))
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'initializes with the correct sender' do
|
147
|
-
%i(address area_code city complement email name neighborhood number
|
148
|
-
phone postal_code reference state).each do |property|
|
149
|
-
expect(subject.collect.sender.send(property)).to eq(sender.send(property))
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'initializes with the correct product' do
|
154
|
-
%i(code type quantity).each do |property|
|
155
|
-
expect(subject.collect.product.send(property)).to eq(product.send(property))
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'initializes with the correct objects' do
|
160
|
-
expect(subject.collect.objects.length).to eq(2)
|
161
|
-
expect(subject.collect.objects.first.id).to eq('1')
|
162
|
-
expect(subject.collect.objects.first.item).to eq('Item')
|
163
|
-
expect(subject.collect.objects.first.description).to eq('Descricao')
|
164
|
-
expect(subject.collect.objects.last.id).to eq('2')
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe '#initialize' do
|
169
|
-
let(:logistic_reverse) { described_class.new params }
|
170
|
-
|
171
|
-
context 'collect params' do
|
172
|
-
context 'present' do
|
173
|
-
let(:collect) { double(:collect) }
|
174
|
-
let(:params) { { collect: collect } }
|
175
|
-
it 'sets collect value as the same in the param' do
|
176
|
-
expect(logistic_reverse.collect).to eq collect
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
context 'not present' do
|
181
|
-
let(:params) { {} }
|
182
|
-
it 'sets collect as a new Collect model' do
|
183
|
-
expect(Models::Collect).to receive(:new).and_call_original
|
184
|
-
expect(logistic_reverse.collect).to be_a(Models::Collect)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
context 'recipient param' do
|
191
|
-
context 'present' do
|
192
|
-
let(:recipient) { double(:recipient) }
|
193
|
-
let(:params) { { recipient: recipient } }
|
194
|
-
it 'set recipient value as the same in the param' do
|
195
|
-
expect(logistic_reverse.recipient).to eq recipient
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
context 'not present' do
|
200
|
-
let(:params) { {} }
|
201
|
-
it 'sets recipient as a new Recipient model' do
|
202
|
-
expect(Models::Recipient).to receive(:new).and_call_original
|
203
|
-
expect(logistic_reverse.recipient).to be_a(Models::Recipient)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
end
|
209
|
-
|
210
|
-
describe '#to_xml' do
|
211
|
-
let(:logistic_reverse) { described_class.new }
|
212
|
-
let(:expected_xml) { builders_fixture('logistic_reverse.xml') }
|
213
|
-
before { seed_logistic_reverse(logistic_reverse) }
|
214
|
-
|
215
|
-
it 'generates the correct XMl of the logistic_reverse' do
|
216
|
-
expect(logistic_reverse.to_xml).to match expected_xml
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CorreiosSigep
|
4
|
-
module Models
|
5
|
-
describe Object do
|
6
|
-
it { should respond_to :description }
|
7
|
-
it { should respond_to :id }
|
8
|
-
it { should respond_to :item }
|
9
|
-
it { should respond_to :num }
|
10
|
-
it { should respond_to :ship }
|
11
|
-
|
12
|
-
describe '#initialize' do
|
13
|
-
let(:object) { described_class.new params }
|
14
|
-
|
15
|
-
context 'with description param' do
|
16
|
-
let(:params) { { description: 'description' } }
|
17
|
-
it 'set description value' do
|
18
|
-
expect(object.description).to eq 'description'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'with id param' do
|
23
|
-
let(:params) { { id: 1234 } }
|
24
|
-
it 'set id value' do
|
25
|
-
expect(object.id).to eq 1234
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with item param' do
|
30
|
-
let(:params) { { item: 'Item' } }
|
31
|
-
it 'set item value' do
|
32
|
-
expect(object.item).to eq 'Item'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'with num param' do
|
37
|
-
let(:params) { { num: 2 } }
|
38
|
-
it 'set num value' do
|
39
|
-
expect(object.num).to eq 2
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'with ship param' do
|
44
|
-
let(:params) { { ship: 'Ship' } }
|
45
|
-
it 'set ship value' do
|
46
|
-
expect(object.ship).to eq 'Ship'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CorreiosSigep
|
4
|
-
module Models
|
5
|
-
describe Product do
|
6
|
-
it { should respond_to :code }
|
7
|
-
it { should respond_to :type }
|
8
|
-
it { should respond_to :quantity }
|
9
|
-
|
10
|
-
describe '#initialize' do
|
11
|
-
let(:product) { described_class.new params }
|
12
|
-
|
13
|
-
context 'with code param' do
|
14
|
-
let(:params) { { code: 'code' } }
|
15
|
-
it 'set code value' do
|
16
|
-
expect(product.code).to eq 'code'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'with type param' do
|
21
|
-
let(:params) { { type: 'type' } }
|
22
|
-
it 'set type value' do
|
23
|
-
expect(product.type).to eq 'type'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'with quantity param' do
|
28
|
-
let(:params) { { quantity: 2 } }
|
29
|
-
it 'set quantity value' do
|
30
|
-
expect(product.quantity).to eq 2
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|