boa_vista 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1 -0
  3. data/lib/boa_vista/configuration.rb +5 -0
  4. data/lib/boa_vista/field/reader.rb +10 -0
  5. data/lib/boa_vista/field/writer.rb +20 -0
  6. data/lib/boa_vista/field.rb +15 -0
  7. data/lib/boa_vista/line.rb +64 -0
  8. data/lib/boa_vista/request/default.rb +33 -0
  9. data/lib/boa_vista/request/factory.rb +30 -0
  10. data/lib/boa_vista/request/layout/cnpj.rb +13 -0
  11. data/lib/boa_vista/request/layout/cpf.rb +11 -0
  12. data/lib/boa_vista/request/layout.rb +24 -0
  13. data/lib/boa_vista/request.rb +31 -0
  14. data/lib/boa_vista/response/layout/layout_138.rb +21 -0
  15. data/lib/boa_vista/response/layout/layout_221.rb +18 -0
  16. data/lib/boa_vista/response/layout/layout_249.rb +22 -0
  17. data/lib/boa_vista/response/layout/layout_282.rb +17 -0
  18. data/lib/boa_vista/response/layout/layout_283.rb +23 -0
  19. data/lib/boa_vista/response/layout/layout_285.rb +15 -0
  20. data/lib/boa_vista/response/layout/layout_353.rb +34 -0
  21. data/lib/boa_vista/response/layout/layout_354.rb +22 -0
  22. data/lib/boa_vista/response/layout/layout_901.rb +15 -0
  23. data/lib/boa_vista/response/layout/layout_999.rb +13 -0
  24. data/lib/boa_vista/response/layout.rb +29 -0
  25. data/lib/boa_vista/response.rb +21 -0
  26. data/lib/boa_vista/version.rb +3 -0
  27. data/lib/boa_vista.rb +47 -0
  28. data/spec/fixtures/base.txt +1 -0
  29. data/spec/fixtures/layout_138.txt +1 -0
  30. data/spec/fixtures/layout_221.txt +1 -0
  31. data/spec/fixtures/layout_249.txt +1 -0
  32. data/spec/fixtures/layout_282.txt +1 -0
  33. data/spec/fixtures/layout_283.txt +1 -0
  34. data/spec/fixtures/layout_285.txt +1 -0
  35. data/spec/fixtures/layout_353.txt +1 -0
  36. data/spec/fixtures/layout_354.txt +1 -0
  37. data/spec/fixtures/layout_901.txt +1 -0
  38. data/spec/fixtures/layout_999.txt +1 -0
  39. data/spec/fixtures/layout_cpf.txt +1 -0
  40. data/spec/lib/boa_vista/configuration_spec.rb +6 -0
  41. data/spec/lib/boa_vista/field/writer_spec.rb +22 -0
  42. data/spec/lib/boa_vista/field_spec.rb +2 -0
  43. data/spec/lib/boa_vista/line_spec.rb +58 -0
  44. data/spec/lib/boa_vista/request/default_spec.rb +40 -0
  45. data/spec/lib/boa_vista/request/factory_spec.rb +18 -0
  46. data/spec/lib/boa_vista/request/layout/cnpj_spec.rb +31 -0
  47. data/spec/lib/boa_vista/request/layout/cpf_spec.rb +28 -0
  48. data/spec/lib/boa_vista/request/layout_spec.rb +18 -0
  49. data/spec/lib/boa_vista/request_spec.rb +43 -0
  50. data/spec/lib/boa_vista/response/layout/layout_138_spec.rb +16 -0
  51. data/spec/lib/boa_vista/response/layout/layout_221_spec.rb +17 -0
  52. data/spec/lib/boa_vista/response/layout/layout_249_spec.rb +21 -0
  53. data/spec/lib/boa_vista/response/layout/layout_282_spec.rb +16 -0
  54. data/spec/lib/boa_vista/response/layout/layout_283_spec.rb +22 -0
  55. data/spec/lib/boa_vista/response/layout/layout_285_spec.rb +14 -0
  56. data/spec/lib/boa_vista/response/layout/layout_353_spec.rb +32 -0
  57. data/spec/lib/boa_vista/response/layout/layout_354_spec.rb +21 -0
  58. data/spec/lib/boa_vista/response/layout/layout_901_spec.rb +14 -0
  59. data/spec/lib/boa_vista/response/layout/layout_999_spec.rb +12 -0
  60. data/spec/lib/boa_vista/response/layout_spec.rb +2 -0
  61. data/spec/lib/boa_vista/response_spec.rb +18 -0
  62. data/spec/lib/boa_vista/version_spec.rb +3 -0
  63. data/spec/spec_helper.rb +16 -0
  64. metadata +200 -0
@@ -0,0 +1,22 @@
1
+ RSpec.describe BoaVista::Field::Writer do
2
+ let(:options) { { range: 1..8, value: 'CSR60' } }
3
+ let(:instance) { described_class.new(:transaction, options) }
4
+
5
+ describe '#call' do
6
+ it { expect(instance.call).to eq('CSR60 ') }
7
+ end
8
+
9
+ describe '#size' do
10
+ it { expect(instance.size).to eq(8) }
11
+ end
12
+
13
+ describe '#truncate' do
14
+ let(:options) { { range: 1..8, value: 'CSR601234' } }
15
+
16
+ it { expect(instance.truncate.value).to eq('CSR60123') }
17
+ end
18
+
19
+ describe '#adjust' do
20
+ it { expect(instance.adjust.value).to eq('CSR60 ') }
21
+ end
22
+ end
@@ -0,0 +1,2 @@
1
+ RSpec.describe BoaVista::Field do
2
+ end
@@ -0,0 +1,58 @@
1
+ RSpec.describe BoaVista::Line do
2
+ let(:line) { File.read('./spec/fixtures/base.txt') }
3
+
4
+ context 'when layout is BoaVista::Response::Layout' do
5
+ let(:instance) { described_class.prepare_for_read(line, BoaVista::Response::Layout) }
6
+
7
+ describe '#read' do
8
+ subject { instance.read }
9
+
10
+ its(:transaction) { is_expected.to eq('T' * 8) }
11
+ its(:version) { is_expected.to eq('V' * 2) }
12
+ its(:reserved_requester) { is_expected.to eq('R' * 10) }
13
+ its(:reserved_boa_vista) { is_expected.to eq('B' * 20) }
14
+ its(:code) { is_expected.to eq('C' * 8) }
15
+ its(:query) { is_expected.to eq('Q' * 8) }
16
+ its(:query_version) { is_expected.to eq('QV') }
17
+ its(:response_type) { is_expected.to eq('Y') }
18
+ its(:response_code) { is_expected.to eq('C') }
19
+ its(:query_number) { is_expected.to eq('N' * 7) }
20
+ its(:text_size) { is_expected.to eq('T' * 4) }
21
+ its(:record_size) { is_expected.to eq('Z' * 3) }
22
+ its(:record_type) { is_expected.to eq('P' * 3) }
23
+ end
24
+ end
25
+
26
+ context 'when write' do
27
+ context 'when CNPJ' do
28
+ let(:cnpj_values) do
29
+ BoaVista::Request::Factory.build(BoaVista::Request::Default::CNPJ)
30
+ end
31
+ let(:layout) { BoaVista::Request::Layout::Cnpj }
32
+ let(:instance) { described_class.prepare_for_write(cnpj_values, layout) }
33
+
34
+ describe '#write' do
35
+ subject { instance.write }
36
+
37
+ its(:size) { is_expected.to eq(142) }
38
+ it { is_expected.to eq('CSR60 01 CODE PASSWORDCADPJ 032C2 X') }
39
+ end
40
+ end
41
+
42
+ context 'when CPF' do
43
+ let(:cpf_values) do
44
+ BoaVista::Request::Factory.build(BoaVista::Request::Default::CPF)
45
+ end
46
+ let(:layout) { BoaVista::Request::Layout::Cpf }
47
+
48
+ let(:instance) { described_class.prepare_for_write(cpf_values, layout) }
49
+
50
+ describe '#create' do
51
+ subject { instance.write }
52
+
53
+ its(:size) { is_expected.to eq(84) }
54
+ it { is_expected.to eq('CSR60 01 CODE PASSWORDSINTON 012C1 X') }
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,40 @@
1
+ RSpec.describe BoaVista::Request::Default do
2
+ let(:instance) { described_class }
3
+
4
+ context 'default' do
5
+ subject { instance::DEFAULT }
6
+
7
+ its([:transaction]) { is_expected.to eq('CSR60') }
8
+ its([:version]) { is_expected.to eq('01') }
9
+ its([:response_type]) { is_expected.to eq('2') }
10
+ its([:end_text_indicator]) { is_expected.to eq('X') }
11
+
12
+ it { is_expected.to have_key(:document_number) }
13
+ end
14
+
15
+ context 'cpf' do
16
+ subject { instance::CPF }
17
+
18
+ its([:document_type]) { is_expected.to eq('1') }
19
+ its([:query]) { is_expected.to eq('SINTON') }
20
+ its([:query_version]) { is_expected.to eq('01') }
21
+ end
22
+
23
+ context 'cnpj' do
24
+ subject { instance::CNPJ }
25
+
26
+ its([:document_type]) { is_expected.to eq('2') }
27
+ its([:query]) { is_expected.to eq('CADPJ') }
28
+ its([:query_version]) { is_expected.to eq('03') }
29
+
30
+ it { is_expected.to have_key(:company_name) }
31
+ it { is_expected.to have_key(:facilitator_code) }
32
+ end
33
+
34
+ context 'options' do
35
+ subject { instance::OPTIONS }
36
+
37
+ it { is_expected.to have_key(:reserved_requester) }
38
+ it { is_expected.to have_key(:reserved_boa_vista) }
39
+ end
40
+ end
@@ -0,0 +1,18 @@
1
+ RSpec.describe BoaVista::Request::Factory do
2
+ let(:cpf_factory_attributes) do
3
+ BoaVista::Request::Factory.build(
4
+ { document_number: '30630968810' },
5
+ BoaVista::Request::Default::CPF
6
+ )
7
+ end
8
+
9
+ describe '.build' do
10
+ it 'returns the attributes' do
11
+ expect(cpf_factory_attributes).to be_a_instance_of(Hash)
12
+ expect(cpf_factory_attributes[:document_number]).to eq('30630968810')
13
+ expect(cpf_factory_attributes[:document_type]).to eq('1')
14
+ expect(cpf_factory_attributes[:transaction]).to eq('CSR60')
15
+ expect(cpf_factory_attributes[:code]).to eq('CODE')
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,31 @@
1
+ RSpec.describe BoaVista::Request::Layout::Cnpj do
2
+ let(:instance) { described_class }
3
+
4
+ subject { instance.attributes }
5
+
6
+ context 'includes all base attributes' do
7
+ it { is_expected.to have_key(:transaction) }
8
+ it { is_expected.to have_key(:version) }
9
+ it { is_expected.to have_key(:reserved_requester) }
10
+ it { is_expected.to have_key(:reserved_boa_vista) }
11
+ it { is_expected.to have_key(:code) }
12
+ it { is_expected.to have_key(:password) }
13
+ it { is_expected.to have_key(:query) }
14
+ it { is_expected.to have_key(:query_version) }
15
+ it { is_expected.to have_key(:response_type) }
16
+ it { is_expected.to have_key(:response_transmission_type) }
17
+ it { is_expected.to have_key(:document_type) }
18
+ it { is_expected.to have_key(:document_number) }
19
+ end
20
+
21
+ context 'cnpj attributes' do
22
+ it { is_expected.to have_key(:company_name) }
23
+ its([:company_name, :range]) { is_expected.to eq(84..133) }
24
+
25
+ it { is_expected.to have_key(:facilitator_code) }
26
+ its([:facilitator_code, :range]) { is_expected.to eq(134..141) }
27
+
28
+ it { is_expected.to have_key(:end_text_indicator) }
29
+ its([:end_text_indicator, :range]) { is_expected.to eq(142..142) }
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ RSpec.describe BoaVista::Request::Layout::Cpf do
2
+ let(:instance) { described_class }
3
+
4
+ subject { instance.attributes }
5
+
6
+ context 'includes all base attributes' do
7
+ it { is_expected.to have_key(:transaction) }
8
+ it { is_expected.to have_key(:version) }
9
+ it { is_expected.to have_key(:reserved_requester) }
10
+ it { is_expected.to have_key(:reserved_boa_vista) }
11
+ it { is_expected.to have_key(:code) }
12
+ it { is_expected.to have_key(:password) }
13
+ it { is_expected.to have_key(:query) }
14
+ it { is_expected.to have_key(:query_version) }
15
+ it { is_expected.to have_key(:response_type) }
16
+ it { is_expected.to have_key(:response_transmission_type) }
17
+ it { is_expected.to have_key(:document_type) }
18
+ it { is_expected.to have_key(:document_number) }
19
+ end
20
+
21
+ it 'includes the end_text_indicator with the right range' do
22
+ expect(subject).to have_key(:end_text_indicator)
23
+
24
+ expect(subject[:end_text_indicator][:range]).to cover(84)
25
+ expect(subject[:end_text_indicator][:range]).to_not cover(83)
26
+ expect(subject[:end_text_indicator][:range]).to_not cover(85)
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ RSpec.describe BoaVista::Request::Layout do
2
+ describe 'attributes_mapping_methods' do
3
+ subject { described_class.attributes }
4
+
5
+ its([:transaction, :range]) { is_expected.to eq(1..8) }
6
+ its([:version, :range]) { is_expected.to eq(9..10) }
7
+ its([:reserved_requester, :range]) { is_expected.to eq(11..20) }
8
+ its([:reserved_boa_vista, :range]) { is_expected.to eq(21..40) }
9
+ its([:code, :range]) { is_expected.to eq(41..48) }
10
+ its([:password, :range]) { is_expected.to eq(49..56) }
11
+ its([:query, :range]) { is_expected.to eq(57..64) }
12
+ its([:query_version, :range]) { is_expected.to eq(65..66) }
13
+ its([:response_type, :range]) { is_expected.to eq(67..67) }
14
+ its([:response_transmission_type, :range]) { is_expected.to eq(68..68) }
15
+ its([:document_type, :range]) { is_expected.to eq(69..69) }
16
+ its([:document_number, :range]) { is_expected.to eq(70..83) }
17
+ end
18
+ end
@@ -0,0 +1,43 @@
1
+ RSpec.describe BoaVista::Request do
2
+
3
+ let(:instance) { described_class.new(values) }
4
+
5
+ subject { instance.create }
6
+
7
+ context 'when document is cpf' do
8
+ let(:values) do
9
+ {
10
+ document_type: '1',
11
+ document_number: '00031030944410'
12
+ }.merge(BoaVista::Request::Default::CPF)
13
+ end
14
+
15
+ let(:document_type) { values[:document_type] }
16
+
17
+ it 'writes document number in the right position' do
18
+ expect(subject.slice(69..82)).to eq('00031030944410')
19
+ end
20
+ end
21
+
22
+ context 'when document is cnpj' do
23
+ let(:values) do
24
+ {
25
+ document_type: '2',
26
+ document_number: '12345678901234'
27
+ }.merge(BoaVista::Request::Default::CNPJ)
28
+ end
29
+
30
+ let(:document_type) { values[:document_type] }
31
+
32
+ it 'writes document number in the right position' do
33
+ expect(subject.slice(69..82)).to eq('12345678901234')
34
+ end
35
+ end
36
+
37
+ context 'when invalid document type' do
38
+ let(:values) { Hash.new }
39
+ let(:document_type) { '3' }
40
+
41
+ it { expect { subject }.to raise_error }
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ RSpec.describe BoaVista::Response::Layout::Layout138 do
2
+ let(:line) { File.read('./spec/fixtures/layout_138.txt') }
3
+
4
+ let(:instance) { BoaVista::Line.prepare_for_read(line, described_class) }
5
+
6
+ describe '#read' do
7
+ subject { instance.read }
8
+
9
+ its(:transaction) { is_expected.to eq('T' * 8) }
10
+ its(:record) { is_expected.to eq('S') }
11
+ its(:document_number) { is_expected.to eq('57487067000110') }
12
+ its(:company_name) { is_expected.to eq('R' * 115) }
13
+ its(:city) { is_expected.to eq('C' * 40) }
14
+ its(:uf) { is_expected.to eq('U' * 2) }
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ RSpec.describe BoaVista::Response::Layout::Layout221 do
2
+ let(:line) { File.read('./spec/fixtures/layout_221.txt') }
3
+
4
+ let(:instance) { BoaVista::Line.prepare_for_read(line, described_class) }
5
+
6
+ describe '#read' do
7
+ subject { instance.read }
8
+
9
+ its(:transaction) { is_expected.to eq('T' * 8) }
10
+ its(:record) { is_expected.to eq('R') }
11
+ its(:name) { is_expected.to eq('N' * 50) }
12
+ its(:document) { is_expected.to eq('30730866610') }
13
+ its(:birthday_date) { is_expected.to eq('25121982') }
14
+ its(:mothers_name) { is_expected.to eq('M' * 50) }
15
+ its(:voter_registration) { is_expected.to eq('V' * 13) }
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ RSpec.describe BoaVista::Response::Layout::Layout249 do
2
+ let(:line) { File.read('./spec/fixtures/layout_249.txt') }
3
+
4
+ let(:instance) { BoaVista::Line.prepare_for_read(line, described_class) }
5
+
6
+ describe '#read' do
7
+ subject { instance.read }
8
+
9
+ its(:transaction) { is_expected.to eq('T' * 8) }
10
+ its(:query_online) { is_expected.to eq('Q' * 1) }
11
+ its(:name) { is_expected.to eq('N' * 50) }
12
+ its(:document) { is_expected.to eq('30730866610') }
13
+ its(:birthday_date) { is_expected.to eq('25121982') }
14
+ its(:mothers_name) { is_expected.to eq('M' * 50) }
15
+ its(:voter_registration) { is_expected.to eq('V' * 13) }
16
+ its(:condition) { is_expected.to eq('C') }
17
+ its(:query_date) { is_expected.to eq('D' * 8) }
18
+ its(:query_time) { is_expected.to eq('T' * 6) }
19
+ its(:protocol) { is_expected.to eq('P' * 20) }
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ RSpec.describe BoaVista::Response::Layout::Layout282 do
2
+ let(:line) { File.read('./spec/fixtures/layout_282.txt') }
3
+
4
+ let(:instance) { BoaVista::Line.prepare_for_read(line, described_class) }
5
+
6
+ describe '#read' do
7
+ subject { instance.read }
8
+
9
+ its(:transaction) { is_expected.to eq('T' * 8) }
10
+ its(:record) { is_expected.to eq('S') }
11
+ its(:sequence_number) { is_expected.to eq('01') }
12
+ its(:company_name) { is_expected.to eq('C' * 50) }
13
+ its(:document_type) { is_expected.to eq('T') }
14
+ its(:document_number) { is_expected.to eq('57487067000110') }
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ RSpec.describe BoaVista::Response::Layout::Layout283 do
2
+ let(:line) { File.read('./spec/fixtures/layout_283.txt') }
3
+
4
+ let(:instance) { BoaVista::Line.prepare_for_read(line, described_class) }
5
+
6
+ describe '#read' do
7
+ subject { instance.read }
8
+
9
+ its(:transaction) { is_expected.to eq('T' * 8) }
10
+ its(:record) { is_expected.to eq('S') }
11
+ its(:sequence_number) { is_expected.to eq('00001') }
12
+ its(:company_name) { is_expected.to eq('C' * 50) }
13
+ its(:document_type) { is_expected.to eq('1') }
14
+ its(:document_number) { is_expected.to eq('57487067000110') }
15
+ its(:entry_date) { is_expected.to eq('D' * 8) }
16
+ its(:currency_type) { is_expected.to eq('M') }
17
+ its(:value) { is_expected.to eq('V' * 15) }
18
+ its(:function) { is_expected.to eq('F' * 20) }
19
+ its(:signs) { is_expected.to eq('S') }
20
+ its(:percentage) { is_expected.to eq('G' * 5) }
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ RSpec.describe BoaVista::Response::Layout::Layout285 do
2
+ let(:line) { File.read('./spec/fixtures/layout_285.txt') }
3
+
4
+ let(:instance) { BoaVista::Line.prepare_for_read(line, described_class) }
5
+
6
+ describe '#read' do
7
+ subject { instance.read }
8
+
9
+ its(:transaction) { is_expected.to eq('T' * 8) }
10
+ its(:record) { is_expected.to eq('S') }
11
+ its(:hive_activity_code) { is_expected.to eq('H' * 8) }
12
+ its(:hive_activity_description) { is_expected.to eq('D' * 55) }
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ RSpec.describe BoaVista::Response::Layout::Layout353 do
2
+ let(:line) { File.read('./spec/fixtures/layout_353.txt') }
3
+
4
+ let(:instance) { BoaVista::Line.prepare_for_read(line, described_class) }
5
+ describe '#read' do
6
+ subject { instance.read }
7
+
8
+ its(:transaction) { is_expected.to eq('T' * 8) }
9
+ its(:record) { is_expected.to eq('S') }
10
+ its(:document_number) { is_expected.to eq('D' * 14) }
11
+ its(:nire) { is_expected.to eq('N' * 11) }
12
+ its(:company_name) { is_expected.to eq('C' * 115) }
13
+ its(:condition) { is_expected.to eq('T') }
14
+ its(:foundation_date) { is_expected.to eq('F' * 8) }
15
+ its(:registration) { is_expected.to eq('R' * 14) }
16
+ its(:registration_status) { is_expected.to eq('S') }
17
+ its(:address) { is_expected.to eq('A' * 70) }
18
+ its(:district) { is_expected.to eq('B' * 20) }
19
+ its(:postal_code) { is_expected.to eq('P' * 8) }
20
+ its(:city) { is_expected.to eq('C' * 40) }
21
+ its(:uf) { is_expected.to eq('U' * 2) }
22
+ its(:phone_1) { is_expected.to eq('P' * 20) }
23
+ its(:phone_2) { is_expected.to eq('H' * 15) }
24
+ its(:fax) { is_expected.to eq('F' * 15) }
25
+ its(:ibge_code) { is_expected.to eq('G' * 8) }
26
+ its(:legal_nature_code) { is_expected.to eq('N' * 8) }
27
+ its(:legal_nature_description) { is_expected.to eq('D' * 55) }
28
+ its(:segment) { is_expected.to eq('S' * 79) }
29
+ its(:hive_activity_code) { is_expected.to eq('R' * 8) }
30
+ its(:hive_activity_description) { is_expected.to eq('D' * 55) }
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ RSpec.describe BoaVista::Response::Layout::Layout354 do
2
+ let(:line) { File.read('./spec/fixtures/layout_354.txt') }
3
+
4
+ let(:instance) { BoaVista::Line.prepare_for_read(line, described_class) }
5
+
6
+ describe '#read' do
7
+ subject { instance.read }
8
+
9
+ its(:transaction) { is_expected.to eq('T' * 8) }
10
+ its(:record) { is_expected.to eq('S') }
11
+ its(:document_number) { is_expected.to eq('D' * 14) }
12
+ its(:currency_social_capital) { is_expected.to eq('C' * 4) }
13
+ its(:value_social_capital) { is_expected.to eq('V' * 15) }
14
+ its(:home_organ) { is_expected.to eq('O' * 8) }
15
+ its(:register_date) { is_expected.to eq('D' * 8) }
16
+ its(:currency_current_capital) { is_expected.to eq('C' * 4) }
17
+ its(:value_current_capital) { is_expected.to eq('V' * 15) }
18
+ its(:current_organ) { is_expected.to eq('O' * 8) }
19
+ its(:change_date) { is_expected.to eq('D' * 8) }
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ RSpec.describe BoaVista::Response::Layout::Layout901 do
2
+ let(:line) { File.read('./spec/fixtures/layout_901.txt') }
3
+
4
+ let(:instance) { BoaVista::Line.prepare_for_read(line, described_class) }
5
+
6
+ describe '#read' do
7
+ subject { instance.read }
8
+
9
+ its(:transaction) { is_expected.to eq('T' * 8) }
10
+ its(:record) { is_expected.to eq('S') }
11
+ its(:message_type) { is_expected.to eq('Y') }
12
+ its(:message) { is_expected.to eq('M' * 130) }
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ RSpec.describe BoaVista::Response::Layout::Layout999 do
2
+ let(:line) { File.read('./spec/fixtures/layout_999.txt') }
3
+
4
+ let(:instance) { BoaVista::Line.prepare_for_read(line, described_class) }
5
+
6
+ describe '#read' do
7
+ subject { instance.read }
8
+
9
+ its(:transaction) { is_expected.to eq('T' * 8) }
10
+ its(:record) { is_expected.to eq('S') }
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ RSpec.describe BoaVista::Response::Layout do
2
+ end
@@ -0,0 +1,18 @@
1
+ RSpec.describe BoaVista::Response do
2
+ let(:instance) { described_class.new(line) }
3
+
4
+ context 'when use layout 353' do
5
+ let(:line) { File.read('./spec/fixtures/layout_353.txt') }
6
+
7
+ subject { instance.read }
8
+
9
+ its(:transaction) { is_expected.to eq('T' * 8) }
10
+ its(:legal_nature_code) { is_expected.to eq('N' * 8) }
11
+ its(:legal_nature_description) { is_expected.to eq('D' * 55) }
12
+ its(:record_type) { is_expected.to eq('353') }
13
+ its(:layout) { is_expected.to eq(BoaVista::Response::Layout::Layout353) }
14
+ end
15
+ end
16
+
17
+
18
+
@@ -0,0 +1,3 @@
1
+ RSpec.describe BoaVista::VERSION do
2
+ specify { expect(BoaVista::VERSION).to eq '0.0.2' }
3
+ end
@@ -0,0 +1,16 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'rspec'
5
+ require 'rspec/its'
6
+
7
+ require 'boa_vista'
8
+
9
+ RSpec.configure do |c|
10
+ c.disable_monkey_patching!
11
+
12
+ BoaVista.configure do |config|
13
+ config.code = 'CODE'
14
+ config.password = 'PASSWORD'
15
+ end
16
+ end