br_documents 0.1.3 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/config.yml +40 -0
- data/.rubocop.yml +73 -0
- data/.tool-versions +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +79 -42
- data/README.md +33 -0
- data/Rakefile +4 -4
- data/br_documents.gemspec +26 -19
- data/lib/br_documents/cnpj_cpf/cnpj.rb +2 -2
- data/lib/br_documents/cnpj_cpf/cpf.rb +2 -2
- data/lib/br_documents/cnpj_cpf/document.rb +9 -9
- data/lib/br_documents/cnpj_validator.rb +4 -4
- data/lib/br_documents/commons/mod11.rb +1 -2
- data/lib/br_documents/commons/mod14.rb +1 -2
- data/lib/br_documents/cpf_validator.rb +4 -4
- data/lib/br_documents/{gtin/gtin.rb → gtin.rb} +3 -3
- data/lib/br_documents/gtin_validator.rb +6 -6
- data/lib/br_documents/ie/ac.rb +3 -2
- data/lib/br_documents/ie/al.rb +2 -1
- data/lib/br_documents/ie/am.rb +3 -2
- data/lib/br_documents/ie/ap.rb +20 -16
- data/lib/br_documents/ie/ba.rb +28 -25
- data/lib/br_documents/ie/base.rb +1 -1
- data/lib/br_documents/ie/ce.rb +3 -2
- data/lib/br_documents/ie/df.rb +3 -2
- data/lib/br_documents/ie/es.rb +2 -1
- data/lib/br_documents/ie/factory.rb +3 -3
- data/lib/br_documents/ie/go.rb +3 -2
- data/lib/br_documents/ie/ma.rb +2 -1
- data/lib/br_documents/ie/mg.rb +14 -17
- data/lib/br_documents/ie/ms.rb +2 -1
- data/lib/br_documents/ie/mt.rb +6 -5
- data/lib/br_documents/ie/pa.rb +3 -2
- data/lib/br_documents/ie/pattern1.rb +10 -7
- data/lib/br_documents/ie/pattern2.rb +9 -8
- data/lib/br_documents/ie/pb.rb +3 -2
- data/lib/br_documents/ie/pe.rb +10 -10
- data/lib/br_documents/ie/pi.rb +2 -1
- data/lib/br_documents/ie/pr.rb +3 -2
- data/lib/br_documents/ie/rj.rb +3 -2
- data/lib/br_documents/ie/rn.rb +19 -16
- data/lib/br_documents/ie/ro.rb +16 -13
- data/lib/br_documents/ie/rr.rb +4 -3
- data/lib/br_documents/ie/rs.rb +3 -2
- data/lib/br_documents/ie/sc.rb +3 -2
- data/lib/br_documents/ie/se.rb +3 -2
- data/lib/br_documents/ie/sp.rb +17 -14
- data/lib/br_documents/ie/to.rb +6 -5
- data/lib/br_documents/ie_validator.rb +7 -7
- data/lib/br_documents/suframa.rb +46 -0
- data/lib/br_documents/suframa_validator.rb +8 -0
- data/lib/br_documents/version.rb +1 -1
- data/lib/br_documents.rb +3 -3
- data/spec/br_documents/cnpj_cpf/cnpj_spec.rb +59 -0
- data/spec/br_documents/cnpj_cpf/cpf_spec.rb +59 -0
- data/spec/br_documents/cnpj_validator_spec.rb +36 -0
- data/spec/br_documents/cpf_validator_spec.rb +36 -0
- data/spec/{gtin → br_documents}/gtin_spec.rb +4 -4
- data/spec/{gtin_validator_spec.rb → br_documents/gtin_validator_spec.rb} +14 -14
- data/spec/br_documents/ie/ac_spec.rb +43 -0
- data/spec/br_documents/ie/al_spec.rb +36 -0
- data/spec/br_documents/ie/am_spec.rb +43 -0
- data/spec/br_documents/ie/ap_spec.rb +36 -0
- data/spec/br_documents/ie/ba_spec.rb +69 -0
- data/spec/br_documents/ie/ce_spec.rb +16 -0
- data/spec/br_documents/ie/df_spec.rb +43 -0
- data/spec/br_documents/ie/es_spec.rb +16 -0
- data/spec/br_documents/ie/factory_spec.rb +202 -0
- data/spec/br_documents/ie/go_spec.rb +43 -0
- data/spec/br_documents/ie/ma_spec.rb +16 -0
- data/spec/br_documents/ie/mg_spec.rb +43 -0
- data/spec/br_documents/ie/ms_spec.rb +16 -0
- data/spec/br_documents/ie/mt_spec.rb +49 -0
- data/spec/br_documents/ie/pa_spec.rb +43 -0
- data/spec/br_documents/ie/pb_spec.rb +16 -0
- data/spec/br_documents/ie/pe_spec.rb +62 -0
- data/spec/br_documents/ie/pi_spec.rb +16 -0
- data/spec/br_documents/ie/pr_spec.rb +36 -0
- data/spec/br_documents/ie/rj_spec.rb +43 -0
- data/spec/br_documents/ie/rn_spec.rb +62 -0
- data/spec/br_documents/ie/ro_spec.rb +62 -0
- data/spec/br_documents/ie/rr_spec.rb +43 -0
- data/spec/br_documents/ie/rs_spec.rb +41 -0
- data/spec/br_documents/ie/sc_spec.rb +43 -0
- data/spec/br_documents/ie/se_spec.rb +16 -0
- data/spec/br_documents/ie/shared_examples_for_pattern1.rb +33 -0
- data/spec/br_documents/ie/shared_examples_for_to_remove_all_masks.rb +16 -0
- data/spec/br_documents/ie/sp_spec.rb +45 -0
- data/spec/br_documents/ie/to_spec.rb +100 -0
- data/spec/{ie_validator_spec.rb → br_documents/ie_validator_spec.rb} +12 -9
- data/spec/br_documents/suframa_spec.rb +73 -0
- data/spec/br_documents/suframa_validator_spec.rb +36 -0
- data/spec/spec_helper.rb +6 -6
- data/spec/support/utilities.rb +2 -2
- metadata +177 -99
- data/.circleci/config.yml +0 -42
- data/spec/cnpj_cpf/cnpj_spec.rb +0 -59
- data/spec/cnpj_cpf/cpf_spec.rb +0 -59
- data/spec/cnpj_validator_spec.rb +0 -36
- data/spec/cpf_validator_spec.rb +0 -36
- data/spec/ie/ac_spec.rb +0 -43
- data/spec/ie/al_spec.rb +0 -36
- data/spec/ie/am_spec.rb +0 -43
- data/spec/ie/ap_spec.rb +0 -36
- data/spec/ie/ba_spec.rb +0 -69
- data/spec/ie/ce_spec.rb +0 -16
- data/spec/ie/df_spec.rb +0 -43
- data/spec/ie/es_spec.rb +0 -16
- data/spec/ie/factory_spec.rb +0 -203
- data/spec/ie/go_spec.rb +0 -43
- data/spec/ie/ma_spec.rb +0 -16
- data/spec/ie/mg_spec.rb +0 -43
- data/spec/ie/ms_spec.rb +0 -16
- data/spec/ie/mt_spec.rb +0 -44
- data/spec/ie/pa_spec.rb +0 -43
- data/spec/ie/pb_spec.rb +0 -16
- data/spec/ie/pe_spec.rb +0 -62
- data/spec/ie/pi_spec.rb +0 -16
- data/spec/ie/pr_spec.rb +0 -36
- data/spec/ie/rj_spec.rb +0 -43
- data/spec/ie/rn_spec.rb +0 -62
- data/spec/ie/ro_spec.rb +0 -62
- data/spec/ie/rr_spec.rb +0 -43
- data/spec/ie/rs_spec.rb +0 -41
- data/spec/ie/sc_spec.rb +0 -43
- data/spec/ie/se_spec.rb +0 -16
- data/spec/ie/shared_examples_for_pattern1.rb +0 -33
- data/spec/ie/shared_examples_for_to_remove_all_masks.rb +0 -17
- data/spec/ie/sp_spec.rb +0 -45
- data/spec/ie/to_spec.rb +0 -100
data/spec/ie/factory_spec.rb
DELETED
@@ -1,203 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe BrDocuments::IE::Factory do
|
4
|
-
describe ".create" do
|
5
|
-
context "when uf is AC" do
|
6
|
-
it "returns an instance of BrDocuments::IE::AC" do
|
7
|
-
ie = BrDocuments::IE::Factory.create("AC", "123456789")
|
8
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::AC
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context "when uf is AL" do
|
13
|
-
it "returns an instance of BrDocuments::IE::AL" do
|
14
|
-
ie = BrDocuments::IE::Factory.create("AL", "123456789")
|
15
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::AL
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context "when uf is AP" do
|
20
|
-
it "returns an instance of BrDocuments::IE::AP" do
|
21
|
-
ie = BrDocuments::IE::Factory.create("AP", "123456789")
|
22
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::AP
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when uf is AM" do
|
27
|
-
it "returns an instance of BrDocuments::IE::AM" do
|
28
|
-
ie = BrDocuments::IE::Factory.create("AM", "123456789")
|
29
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::AM
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context "when uf is BA" do
|
34
|
-
it "returns an instance of BrDocuments::IE::BA" do
|
35
|
-
ie = BrDocuments::IE::Factory.create("BA", "123456789")
|
36
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::BA
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "when uf is CE" do
|
41
|
-
it "returns an instance of BrDocuments::IE::CE" do
|
42
|
-
ie = BrDocuments::IE::Factory.create("CE", "123456789")
|
43
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::CE
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context "when uf is DF" do
|
48
|
-
it "returns an instance of BrDocuments::IE::DF" do
|
49
|
-
ie = BrDocuments::IE::Factory.create("DF", "123456789")
|
50
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::DF
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "when uf is ES" do
|
55
|
-
it "returns an instance of BrDocuments::IE::ES" do
|
56
|
-
ie = BrDocuments::IE::Factory.create("ES", "123456789")
|
57
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::ES
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "when uf is GO" do
|
62
|
-
it "returns an instance of BrDocuments::IE::GO" do
|
63
|
-
ie = BrDocuments::IE::Factory.create("GO", "123456789")
|
64
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::GO
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "when uf is MA" do
|
69
|
-
it "returns an instance of BrDocuments::IE::MA" do
|
70
|
-
ie = BrDocuments::IE::Factory.create("MA", "123456789")
|
71
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::MA
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "when uf is MG" do
|
76
|
-
it "returns an instance of BrDocuments::IE::MG" do
|
77
|
-
ie = BrDocuments::IE::Factory.create("MG", "123456789")
|
78
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::MG
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context "when uf is MS" do
|
83
|
-
it "returns an instance of BrDocuments::IE::MS" do
|
84
|
-
ie = BrDocuments::IE::Factory.create("MS", "123456789")
|
85
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::MS
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "when uf is MT" do
|
90
|
-
it "returns an instance of BrDocuments::IE::MT" do
|
91
|
-
ie = BrDocuments::IE::Factory.create("MT", "123456789")
|
92
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::MT
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context "when uf is PA" do
|
97
|
-
it "returns an instance of BrDocuments::IE::PA" do
|
98
|
-
ie = BrDocuments::IE::Factory.create("PA", "123456789")
|
99
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::PA
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
context "when uf is PB" do
|
104
|
-
it "returns an instance of BrDocuments::IE::PB" do
|
105
|
-
ie = BrDocuments::IE::Factory.create("PB", "123456789")
|
106
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::PB
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context "when uf is PR" do
|
111
|
-
it "returns an instance of BrDocuments::IE::PR" do
|
112
|
-
ie = BrDocuments::IE::Factory.create("PR", "123456789")
|
113
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::PR
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context "when uf is PE" do
|
118
|
-
it "returns an instance of BrDocuments::IE::PE" do
|
119
|
-
ie = BrDocuments::IE::Factory.create("PE", "123456789")
|
120
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::PE
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context "when uf is PI" do
|
125
|
-
it "returns an instance of BrDocuments::IE::PI" do
|
126
|
-
ie = BrDocuments::IE::Factory.create("PI", "123456789")
|
127
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::PI
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
context "when uf is RJ" do
|
132
|
-
it "returns an instance of BrDocuments::IE::RJ" do
|
133
|
-
ie = BrDocuments::IE::Factory.create("RJ", "123456789")
|
134
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::RJ
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context "when uf is returns" do
|
139
|
-
it "returns an instance of BrDocuments::IE::RN" do
|
140
|
-
ie = BrDocuments::IE::Factory.create("RN", "123456789")
|
141
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::RN
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context "when uf is RS" do
|
146
|
-
it "returns an instance of BrDocuments::IE::RS" do
|
147
|
-
ie = BrDocuments::IE::Factory.create("RS", "123456789")
|
148
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::RS
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
context "when uf is RO" do
|
153
|
-
it "returns an instance of BrDocuments::IE::RO" do
|
154
|
-
ie = BrDocuments::IE::Factory.create("RO", "123456789")
|
155
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::RO
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
context "when uf is RR" do
|
160
|
-
it "returns an instance of BrDocuments::IE::RR" do
|
161
|
-
ie = BrDocuments::IE::Factory.create("RR", "123456789")
|
162
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::RR
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
context "when uf is SC" do
|
167
|
-
it "returns an instance of BrDocuments::IE::SC" do
|
168
|
-
ie = BrDocuments::IE::Factory.create("SC", "123456789")
|
169
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::SC
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
context "when uf is SP" do
|
174
|
-
it "returns an instance of BrDocuments::IE::SP" do
|
175
|
-
ie = BrDocuments::IE::Factory.create("SP", "123456789")
|
176
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::SP
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
context "when uf is SE" do
|
181
|
-
it "returns an instance of BrDocuments::IE::SE" do
|
182
|
-
ie = BrDocuments::IE::Factory.create("SE", "123456789")
|
183
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::SE
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
context "when uf is TO" do
|
188
|
-
it "returns an instance of BrDocuments::IE::TO" do
|
189
|
-
ie = BrDocuments::IE::Factory.create("TO", "123456789")
|
190
|
-
expect(ie).to be_an_instance_of BrDocuments::IE::TO
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
|
195
|
-
context "when uf is invalid" do
|
196
|
-
it "is returns an error" do
|
197
|
-
expect{
|
198
|
-
BrDocuments::IE::Factory.create("", "")
|
199
|
-
}.to raise_error(ArgumentError, t("validator.ie.uf.invalid"))
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
data/spec/ie/go_spec.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
3
|
-
|
4
|
-
describe BrDocuments::IE::GO do
|
5
|
-
describe "#formatted" do
|
6
|
-
it "returns a formatted ie" do
|
7
|
-
ie = described_class.new("123456789")
|
8
|
-
expect(ie.formatted).to eq "12.345.678-9"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#valid?" do
|
13
|
-
it "is invalid with malformed number" do
|
14
|
-
["01.390415.9", "280541-600", "1C78150A5"].each do |number|
|
15
|
-
ie = described_class.new(number)
|
16
|
-
expect(ie).to_not be_valid
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "is invalid with length different to 9" do
|
21
|
-
["1234567", "122345678901"].each do |number|
|
22
|
-
ie = described_class.new(number)
|
23
|
-
expect(ie).to_not be_valid
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "is invalid with invalid check number" do
|
28
|
-
["903473566", "493184742"].each do |number|
|
29
|
-
ie = described_class.new(number)
|
30
|
-
expect(ie).to_not be_valid
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "is valid with valid number" do
|
35
|
-
["155432214", "916876470"].each do |number|
|
36
|
-
ie = described_class.new(number)
|
37
|
-
expect(ie).to be_valid
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
include_examples "for to remove all masks", "91.687.647-0"
|
42
|
-
end
|
43
|
-
end
|
data/spec/ie/ma_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_pattern1"
|
3
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
4
|
-
|
5
|
-
describe BrDocuments::IE::MA do
|
6
|
-
describe "#formatted" do
|
7
|
-
it "returns a formatted ie" do
|
8
|
-
ie = described_class.new("123456789")
|
9
|
-
expect(ie.formatted).to eq "123456789"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it_behaves_like "a pattern1", "MA"
|
14
|
-
|
15
|
-
include_examples "for to remove all masks", "12345678-9"
|
16
|
-
end
|
data/spec/ie/mg_spec.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
3
|
-
|
4
|
-
RSpec.describe BrDocuments::IE::MG do
|
5
|
-
describe "#formatted" do
|
6
|
-
it "returns a formatted ie" do
|
7
|
-
ie = described_class.new("1234567890123")
|
8
|
-
expect(ie.formatted).to eq "123.456.789/0123"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#valid?" do
|
13
|
-
it "is invalid with malformed number" do
|
14
|
-
["36.311.266.571-75", "4.168.836.973-423", "560.139.778.87-BA"].each do |number|
|
15
|
-
ie = described_class.new(number)
|
16
|
-
expect(ie).to_not be_valid
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "is invalid with length different to 13" do
|
21
|
-
["123456789", "1234567890123"].each do |number|
|
22
|
-
ie = described_class.new(number)
|
23
|
-
expect(ie).to_not be_valid
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "is invalid with invalid check number" do
|
28
|
-
["4193434759812", "9427301981832"].each do |number|
|
29
|
-
ie = described_class.new(number)
|
30
|
-
expect(ie).to_not be_valid
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "is valid with valid number" do
|
35
|
-
["4193434759899", "9427301981820"].each do |number|
|
36
|
-
ie = described_class.new(number)
|
37
|
-
expect(ie).to be_valid
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
include_examples "for to remove all masks", "942.730.198.18-20"
|
42
|
-
end
|
43
|
-
end
|
data/spec/ie/ms_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_pattern1"
|
3
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
4
|
-
|
5
|
-
describe BrDocuments::IE::MS do
|
6
|
-
describe "#formatted" do
|
7
|
-
it "returns a formatted ie" do
|
8
|
-
ie = described_class.new("123456789")
|
9
|
-
expect(ie.formatted).to eq "123456789"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it_behaves_like "a pattern1", "MS"
|
14
|
-
|
15
|
-
include_examples "for to remove all masks", "12345678-9"
|
16
|
-
end
|
data/spec/ie/mt_spec.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
3
|
-
|
4
|
-
RSpec.describe BrDocuments::IE::MT do
|
5
|
-
describe "#formatted" do
|
6
|
-
it "returns a formatted ie" do
|
7
|
-
ie = described_class.new("12345678901")
|
8
|
-
expect(ie.formatted).to eq "1234567890-1"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#valid?" do
|
13
|
-
it "is invalid with malformed number" do
|
14
|
-
["82.060.187.373", "528843171-72", "AD402552219"].each do |number|
|
15
|
-
ie = described_class.new(number)
|
16
|
-
expect(ie).to_not be_valid
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "when the number is greater than 11" do
|
21
|
-
subject { described_class.new("123456789012") }
|
22
|
-
|
23
|
-
it "is invalid" do
|
24
|
-
expect(subject).to_not be_valid
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
it "is invalid with invalid check number" do
|
29
|
-
["00404609123", "83646580222"].each do |number|
|
30
|
-
ie = described_class.new(number)
|
31
|
-
expect(ie).to_not be_valid
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it "is valid with valid number" do
|
36
|
-
["0013000001-9", "82060187373", "132631946", "13.263.194-6"].each do |number|
|
37
|
-
ie = described_class.new(number)
|
38
|
-
expect(ie).to be_valid
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
include_examples "for to remove all masks", "0013000001-9"
|
43
|
-
end
|
44
|
-
end
|
data/spec/ie/pa_spec.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
3
|
-
|
4
|
-
describe BrDocuments::IE::PA do
|
5
|
-
describe "#formatted" do
|
6
|
-
it "returns a formatted ie" do
|
7
|
-
ie = described_class.new("123456789")
|
8
|
-
expect(ie.formatted).to eq "12-345678-9"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#valid?" do
|
13
|
-
it "is invalid with malformed number" do
|
14
|
-
["15.361.802-7", "15-48556-93", "15-4AB752-7"].each do |number|
|
15
|
-
ie = described_class.new(number)
|
16
|
-
expect(ie).to_not be_valid
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "is invalid with length different to 9" do
|
21
|
-
["1234567", "12345678901"].each do |number|
|
22
|
-
ie = described_class.new(number)
|
23
|
-
expect(ie).to_not be_valid
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "is invalid with invalid check number" do
|
28
|
-
["152653852", "157252799"].each do |number|
|
29
|
-
ie = described_class.new(number)
|
30
|
-
expect(ie).to_not be_valid
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "is valid with valid number" do
|
35
|
-
["159636841", "158667794"].each do |number|
|
36
|
-
ie = described_class.new(number)
|
37
|
-
expect(ie).to be_valid
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
include_examples "for to remove all masks", "15-866779-4"
|
42
|
-
end
|
43
|
-
end
|
data/spec/ie/pb_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_pattern1"
|
3
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
4
|
-
|
5
|
-
describe BrDocuments::IE::PB do
|
6
|
-
describe "#formatted" do
|
7
|
-
it "returns a formatted ie" do
|
8
|
-
ie = described_class.new("123456789")
|
9
|
-
expect(ie.formatted).to eq "12345678-9"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it_behaves_like "a pattern1", "PB"
|
14
|
-
|
15
|
-
include_examples "for to remove all masks", "12345678-9"
|
16
|
-
end
|
data/spec/ie/pe_spec.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
3
|
-
|
4
|
-
describe BrDocuments::IE::PE do
|
5
|
-
describe "#formatted" do
|
6
|
-
context "when having 9 digits" do
|
7
|
-
it "returns a formatted ie" do
|
8
|
-
ie = described_class.new("123456789")
|
9
|
-
expect(ie.formatted).to eq "1234567-89"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context "when having 14 digits" do
|
14
|
-
it "returns a formatted ie" do
|
15
|
-
ie = described_class.new("18100100000049")
|
16
|
-
expect(ie.formatted).to eq "18.1.001.0000004-9"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#valid?" do
|
22
|
-
it "is invalid with malformed number" do
|
23
|
-
["15711188-1", "3.661.165-41", "3AB8287-00", "18.1.001.000000-49"].each do |number|
|
24
|
-
ie = described_class.new(number)
|
25
|
-
expect(ie).to_not be_valid
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "is invalid with length different to 9 or 14" do
|
30
|
-
["1234567", "12345678901", "0123456789012345"].each do |number|
|
31
|
-
ie = described_class.new(number)
|
32
|
-
expect(ie).to_not be_valid
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "when having 9 digits" do
|
37
|
-
it "is invalid with invalid check number" do
|
38
|
-
ie = described_class.new("838872602")
|
39
|
-
expect(ie).to_not be_valid
|
40
|
-
end
|
41
|
-
|
42
|
-
it "is valid with valid number" do
|
43
|
-
ie = described_class.new("418873607")
|
44
|
-
expect(ie).to be_valid
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "when having 14 digits" do
|
49
|
-
it "is invalid with invalid check number" do
|
50
|
-
ie = described_class.new("18100100000048")
|
51
|
-
expect(ie).to_not be_valid
|
52
|
-
end
|
53
|
-
|
54
|
-
it "is valid with valid number" do
|
55
|
-
ie = described_class.new("18100100000049")
|
56
|
-
expect(ie).to be_valid
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
include_examples "for to remove all masks", "18.1.001.0000004-9"
|
61
|
-
end
|
62
|
-
end
|
data/spec/ie/pi_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_pattern1"
|
3
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
4
|
-
|
5
|
-
describe BrDocuments::IE::PI do
|
6
|
-
describe "#formatted" do
|
7
|
-
it "returns a formatted ie" do
|
8
|
-
ie = described_class.new("123456789")
|
9
|
-
expect(ie.formatted).to eq "123456789"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it_behaves_like "a pattern1", "PI"
|
14
|
-
|
15
|
-
include_examples "for to remove all masks", "12345678-9"
|
16
|
-
end
|
data/spec/ie/pr_spec.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
3
|
-
|
4
|
-
describe BrDocuments::IE::PR do
|
5
|
-
describe "#formatted" do
|
6
|
-
it "returns a formatted ie" do
|
7
|
-
ie = described_class.new("1234567890")
|
8
|
-
expect(ie.formatted).to eq "12345678-90"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#valid?" do
|
13
|
-
it "is invalid with malformed number" do
|
14
|
-
["1016323-850", "10163238.50"].each do |number|
|
15
|
-
ie = described_class.new(number)
|
16
|
-
expect(ie).to_not be_valid
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "is invalid with invalid check number" do
|
21
|
-
["10163238-51", "10163238-40"].each do |number|
|
22
|
-
ie = described_class.new(number)
|
23
|
-
expect(ie).to_not be_valid
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "is valid with valid number" do
|
28
|
-
["1016323850", "10163238-50"].each do |number|
|
29
|
-
ie = described_class.new(number)
|
30
|
-
expect(ie).to be_valid
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
include_examples "for to remove all masks", "10163238-50"
|
35
|
-
end
|
36
|
-
end
|
data/spec/ie/rj_spec.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
3
|
-
|
4
|
-
describe BrDocuments::IE::RJ do
|
5
|
-
describe "#formatted" do
|
6
|
-
it "returns a formatted ie" do
|
7
|
-
ie = described_class.new("12345678")
|
8
|
-
expect(ie.formatted).to eq "12.345.67-8"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#valid?" do
|
13
|
-
it "is invalid with malformed number" do
|
14
|
-
["00.55.55.25", "34.09.25-08", "0A220C18"].each do |number|
|
15
|
-
ie = described_class.new(number)
|
16
|
-
expect(ie).to_not be_valid
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "is invalid with length different to 8" do
|
21
|
-
["1234567890", "12345"].each do |number|
|
22
|
-
ie = described_class.new(number)
|
23
|
-
expect(ie).to_not be_valid
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "is invalid with invalid check number" do
|
28
|
-
["99228676", "48388923"].each do |number|
|
29
|
-
ie = described_class.new(number)
|
30
|
-
expect(ie).to_not be_valid
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "is valid with valid number" do
|
35
|
-
["80172010", "31.864.95-0", "85.994.964"].each do |number|
|
36
|
-
ie = described_class.new(number)
|
37
|
-
expect(ie).to be_valid
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
include_examples "for to remove all masks", "31.864.95-0"
|
42
|
-
end
|
43
|
-
end
|
data/spec/ie/rn_spec.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "shared_examples_for_to_remove_all_masks"
|
3
|
-
|
4
|
-
describe BrDocuments::IE::RN do
|
5
|
-
describe "#formatted" do
|
6
|
-
context "when having 9 digits" do
|
7
|
-
it "returns a formatted ie" do
|
8
|
-
ie = described_class.new("123456789")
|
9
|
-
expect(ie.formatted).to eq "12.345.678-9"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context "when having 10 digits" do
|
14
|
-
it "returns a formatted ie" do
|
15
|
-
ie = described_class.new("1234567890")
|
16
|
-
expect(ie.formatted).to eq "12.3.456.789-0"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#valid?" do
|
22
|
-
it "is invalid with malformed number" do
|
23
|
-
["9.012.207-95", "617.964.80-7", "25.9AB.924-6"].each do |number|
|
24
|
-
ie = described_class.new(number)
|
25
|
-
expect(ie).to_not be_valid
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "is invalid with length different to 9 or 10" do
|
30
|
-
["12345678", "12345678901"].each do |number|
|
31
|
-
ie = described_class.new(number)
|
32
|
-
expect(ie).to_not be_valid
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "when having 9 digits" do
|
37
|
-
it "is invalid with invalid check number" do
|
38
|
-
ie = described_class.new("794050643")
|
39
|
-
expect(ie).to_not be_valid
|
40
|
-
end
|
41
|
-
|
42
|
-
it "is valid with valid number" do
|
43
|
-
ie = described_class.new("200400401")
|
44
|
-
expect(ie).to be_valid
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "when having 10 digits" do
|
49
|
-
it "is invalid with invalid check number" do
|
50
|
-
ie = described_class.new("1153296142")
|
51
|
-
expect(ie).to_not be_valid
|
52
|
-
end
|
53
|
-
|
54
|
-
it "is valid with valid number" do
|
55
|
-
ie = described_class.new("2000400400")
|
56
|
-
expect(ie).to be_valid
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
include_examples "for to remove all masks", "20.0.040.040-0"
|
61
|
-
end
|
62
|
-
end
|