br_documents 0.0.2
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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/README.md +146 -0
- data/Rakefile +1 -0
- data/br_documents.gemspec +30 -0
- data/config/locales/pt-BR.yml +8 -0
- data/lib/br_documents.rb +4 -0
- data/lib/br_documents/cnpj_cpf/cnpj.rb +21 -0
- data/lib/br_documents/cnpj_cpf/cpf.rb +21 -0
- data/lib/br_documents/cnpj_cpf/document.rb +35 -0
- data/lib/br_documents/cnpj_validator.rb +8 -0
- data/lib/br_documents/commons/mod11.rb +20 -0
- data/lib/br_documents/cpf_validator.rb +8 -0
- data/lib/br_documents/ie/ac.rb +17 -0
- data/lib/br_documents/ie/al.rb +17 -0
- data/lib/br_documents/ie/am.rb +17 -0
- data/lib/br_documents/ie/ap.rb +52 -0
- data/lib/br_documents/ie/ba.rb +75 -0
- data/lib/br_documents/ie/base.rb +17 -0
- data/lib/br_documents/ie/ce.rb +12 -0
- data/lib/br_documents/ie/df.rb +17 -0
- data/lib/br_documents/ie/es.rb +12 -0
- data/lib/br_documents/ie/factory.rb +12 -0
- data/lib/br_documents/ie/go.rb +17 -0
- data/lib/br_documents/ie/ma.rb +12 -0
- data/lib/br_documents/ie/mg.rb +53 -0
- data/lib/br_documents/ie/ms.rb +12 -0
- data/lib/br_documents/ie/mt.rb +18 -0
- data/lib/br_documents/ie/pa.rb +17 -0
- data/lib/br_documents/ie/pattern1.rb +26 -0
- data/lib/br_documents/ie/pattern2.rb +30 -0
- data/lib/br_documents/ie/pb.rb +12 -0
- data/lib/br_documents/ie/pe.rb +51 -0
- data/lib/br_documents/ie/pi.rb +12 -0
- data/lib/br_documents/ie/pr.rb +19 -0
- data/lib/br_documents/ie/rj.rb +18 -0
- data/lib/br_documents/ie/rn.rb +47 -0
- data/lib/br_documents/ie/ro.rb +49 -0
- data/lib/br_documents/ie/rr.rb +23 -0
- data/lib/br_documents/ie/rs.rb +18 -0
- data/lib/br_documents/ie/sc.rb +17 -0
- data/lib/br_documents/ie/se.rb +12 -0
- data/lib/br_documents/ie/sp.rb +55 -0
- data/lib/br_documents/ie/to.rb +18 -0
- data/lib/br_documents/ie_validator.rb +50 -0
- data/lib/br_documents/version.rb +3 -0
- data/spec/cnpj_cpf/cnpj_spec.rb +45 -0
- data/spec/cnpj_cpf/cpf_spec.rb +45 -0
- data/spec/cnpj_validator_spec.rb +36 -0
- data/spec/cpf_validator_spec.rb +36 -0
- data/spec/ie/ac_spec.rb +40 -0
- data/spec/ie/al_spec.rb +33 -0
- data/spec/ie/am_spec.rb +40 -0
- data/spec/ie/ap_spec.rb +33 -0
- data/spec/ie/ba_spec.rb +63 -0
- data/spec/ie/ce_spec.rb +13 -0
- data/spec/ie/df_spec.rb +40 -0
- data/spec/ie/es_spec.rb +13 -0
- data/spec/ie/factory_spec.rb +203 -0
- data/spec/ie/go_spec.rb +40 -0
- data/spec/ie/ma_spec.rb +13 -0
- data/spec/ie/mg_spec.rb +40 -0
- data/spec/ie/ms_spec.rb +13 -0
- data/spec/ie/mt_spec.rb +40 -0
- data/spec/ie/pa_spec.rb +40 -0
- data/spec/ie/pb_spec.rb +13 -0
- data/spec/ie/pe_spec.rb +59 -0
- data/spec/ie/pi_spec.rb +13 -0
- data/spec/ie/pr_spec.rb +33 -0
- data/spec/ie/rj_spec.rb +40 -0
- data/spec/ie/rn_spec.rb +59 -0
- data/spec/ie/ro_spec.rb +59 -0
- data/spec/ie/rr_spec.rb +40 -0
- data/spec/ie/rs_spec.rb +38 -0
- data/spec/ie/sc_spec.rb +40 -0
- data/spec/ie/se_spec.rb +13 -0
- data/spec/ie/shared_examples_for_pattern1.rb +33 -0
- data/spec/ie/sp_spec.rb +42 -0
- data/spec/ie/to_spec.rb +40 -0
- data/spec/ie_validator_spec.rb +65 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/utilities.rb +3 -0
- metadata +248 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CpfValidator do
|
4
|
+
before(:each) do
|
5
|
+
@validator = CpfValidator.new(attributes: "cpf")
|
6
|
+
@mock = double("model")
|
7
|
+
@mock.stub(:errors).and_return([])
|
8
|
+
@mock.errors.stub(:messages).and_return({})
|
9
|
+
@mock.errors.stub(:add) do | attribute, error |
|
10
|
+
@mock.errors.messages[attribute] = [error]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
subject { @validator }
|
15
|
+
|
16
|
+
context "when Cpf is valid" do
|
17
|
+
it "doesn't add errors in model" do
|
18
|
+
subject.validate_each(@mock, "cpf", "01233254120")
|
19
|
+
expect(@mock.errors.messages).to be_empty
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when Cpf is blank" do
|
24
|
+
it "doesn't add errors in model" do
|
25
|
+
subject.validate_each(@mock, "cpf", "")
|
26
|
+
expect(@mock.errors.messages).to be_empty
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when Cpf is invalid" do
|
31
|
+
it "adds errors in model" do
|
32
|
+
subject.validate_each(@mock, "cpf", "01233254121")
|
33
|
+
expect(@mock.errors.messages).to_not be_empty
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/ie/ac_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDocuments::IE::AC do
|
4
|
+
describe "#formatted" do
|
5
|
+
it "returns a formatted ie" do
|
6
|
+
ie = BrDocuments::IE::AC.new("1234567890123")
|
7
|
+
expect(ie.formatted).to eq "12.345.678/901-23"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#valid?" do
|
12
|
+
it "is invalid with malformed number" do
|
13
|
+
["01.448.52/88.91-50", "01.278.704/5555-7", "01.AB7.904/028-50"].each do |number|
|
14
|
+
ie = BrDocuments::IE::AC.new(number)
|
15
|
+
expect(ie).to_not be_valid
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is invalid with length different to 13" do
|
20
|
+
["1234567890", "123456789012"].each do |number|
|
21
|
+
ie = BrDocuments::IE::AC.new(number)
|
22
|
+
expect(ie).to_not be_valid
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "is invalid with invalid check number" do
|
27
|
+
["0135184641523", "0172567054082"].each do |number|
|
28
|
+
ie = BrDocuments::IE::AC.new(number)
|
29
|
+
expect(ie).to_not be_valid
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "is valid with valid number" do
|
34
|
+
["0182235562573", "0104754560901"].each do |number|
|
35
|
+
ie = BrDocuments::IE::AC.new(number)
|
36
|
+
expect(ie).to be_valid
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/ie/al_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDocuments::IE::AL do
|
4
|
+
describe "#formatted" do
|
5
|
+
it "returns a formatted ie" do
|
6
|
+
ie = BrDocuments::IE::AL.new("123456789")
|
7
|
+
expect(ie.formatted).to eq "123456789"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#valid?" do
|
12
|
+
it "is invalid with length different to 9" do
|
13
|
+
["1234567", "122345678901"].each do |number|
|
14
|
+
ie = BrDocuments::IE::AL.new(number)
|
15
|
+
expect(ie).to_not be_valid
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is invalid with invalid check number" do
|
20
|
+
["245320152", "240046248"].each do |number|
|
21
|
+
ie = BrDocuments::IE::AL.new(number)
|
22
|
+
expect(ie).to_not be_valid
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "is valid with valid number" do
|
27
|
+
["247975494", "248466313"].each do |number|
|
28
|
+
ie = BrDocuments::IE::AL.new(number)
|
29
|
+
expect(ie).to be_valid
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/ie/am_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDocuments::IE::AM do
|
4
|
+
describe "#formatted" do
|
5
|
+
it "returns a formatted ie" do
|
6
|
+
ie = BrDocuments::IE::AM.new("123456789")
|
7
|
+
expect(ie.formatted).to eq "12.345.678-9"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#valid?" do
|
12
|
+
it "is invalid with malformed number" do
|
13
|
+
["8.535.410-60", "884.67.826-1", "13.BA9.093-6"].each do |number|
|
14
|
+
ie = BrDocuments::IE::AM.new(number)
|
15
|
+
expect(ie).to_not be_valid
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is invalid with length different to 9" do
|
20
|
+
["1234567", "12345678901"].each do |number|
|
21
|
+
ie = BrDocuments::IE::AM.new(number)
|
22
|
+
expect(ie).to_not be_valid
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "is invalid with invalid check number" do
|
27
|
+
["500085276", "886770232"].each do |number|
|
28
|
+
ie = BrDocuments::IE::AM.new(number)
|
29
|
+
expect(ie).to_not be_valid
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "is valid with valid number" do
|
34
|
+
["425721221", "310636396"].each do |number|
|
35
|
+
ie = BrDocuments::IE::AM.new(number)
|
36
|
+
expect(ie).to be_valid
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/ie/ap_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDocuments::IE::AP do
|
4
|
+
describe "#formatted" do
|
5
|
+
it "returns a formatted ie" do
|
6
|
+
ie = BrDocuments::IE::AP.new("123456789")
|
7
|
+
expect(ie.formatted).to eq "123456789"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#valid?" do
|
12
|
+
it "is invalid with length different to 9" do
|
13
|
+
["1234567", "123456789012"].each do |number|
|
14
|
+
ie = BrDocuments::IE::AP.new(number)
|
15
|
+
expect(ie).to_not be_valid
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is invalid with invalid check number" do
|
20
|
+
["030123456", "030182454"].each do |number|
|
21
|
+
ie = BrDocuments::IE::AP.new(number)
|
22
|
+
expect(ie).to_not be_valid
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "is valid with valid number" do
|
27
|
+
["030123459", "030183458", "030213452"].each do |number|
|
28
|
+
ie = BrDocuments::IE::AP.new(number)
|
29
|
+
expect(ie).to be_valid
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/ie/ba_spec.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDocuments::IE::BA do
|
4
|
+
describe "#formatted" do
|
5
|
+
context "when having 8 digits" do
|
6
|
+
it "returns a formatted ie" do
|
7
|
+
ie = BrDocuments::IE::BA.new("12345678")
|
8
|
+
expect(ie.formatted).to eq "123456-78"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "when having 9 digits" do
|
13
|
+
it "returns a formatted ie" do
|
14
|
+
ie = BrDocuments::IE::BA.new("123456789")
|
15
|
+
expect(ie.formatted).to eq "1234567-89"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#valid?" do
|
21
|
+
it "is invalid with malformed number" do
|
22
|
+
["82.060.187.373", "528843171-72", "AD402552219"].each do |number|
|
23
|
+
ie = BrDocuments::IE::BA.new(number)
|
24
|
+
expect(ie).to_not be_valid
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "is invalid with length different to 8 or 9" do
|
29
|
+
["1234567", "1234567890"].each do |number|
|
30
|
+
ie = BrDocuments::IE::BA.new(number)
|
31
|
+
expect(ie).to_not be_valid
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when having 8 digits" do
|
36
|
+
it "is invalid with invalid check number" do
|
37
|
+
["12345682", "61934523", "39034325"].each do |number|
|
38
|
+
ie = BrDocuments::IE::BA.new(number)
|
39
|
+
expect(ie).to_not be_valid
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "is valid with valid number" do
|
44
|
+
["12345663", "61234557"].each do |number|
|
45
|
+
ie = BrDocuments::IE::BA.new(number)
|
46
|
+
expect(ie).to be_valid
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when having 9 digits" do
|
52
|
+
it "is invalid with invalid check number" do
|
53
|
+
ie = BrDocuments::IE::BA.new("100052398")
|
54
|
+
expect(ie).to_not be_valid
|
55
|
+
end
|
56
|
+
|
57
|
+
it "is valid with valid number" do
|
58
|
+
ie = BrDocuments::IE::BA.new("100000306")
|
59
|
+
expect(ie).to be_valid
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/spec/ie/ce_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_pattern1"
|
3
|
+
|
4
|
+
describe BrDocuments::IE::CE do
|
5
|
+
describe "#formatted" do
|
6
|
+
it "returns a formatted ie" do
|
7
|
+
ie = BrDocuments::IE::CE.new("123456789")
|
8
|
+
expect(ie.formatted).to eq "12345678-9"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it_behaves_like "a pattern1", "CE"
|
13
|
+
end
|
data/spec/ie/df_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDocuments::IE::DF do
|
4
|
+
describe "#formatted" do
|
5
|
+
it "returns a formatted ie" do
|
6
|
+
ie = BrDocuments::IE::DF.new("1234567890123")
|
7
|
+
expect(ie.formatted).to eq "12345678901-23"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#valid?" do
|
12
|
+
it "is invalid with malformed number" do
|
13
|
+
["070648022871-3", "07.064.802.287-13", "0AB49871799-12"].each do |number|
|
14
|
+
ie = BrDocuments::IE::DF.new(number)
|
15
|
+
expect(ie).to_not be_valid
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is invalid with length different to 13" do
|
20
|
+
["1234567890", "123456789012345"].each do |number|
|
21
|
+
ie = BrDocuments::IE::DF.new(number)
|
22
|
+
expect(ie).to_not be_valid
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "is invalid with invalid check number" do
|
27
|
+
["0733002219945", "0733002219943"].each do |number|
|
28
|
+
ie = BrDocuments::IE::DF.new(number)
|
29
|
+
expect(ie).to_not be_valid
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "is valid with valid number" do
|
34
|
+
["0746069399231", "0784748156211"].each do |number|
|
35
|
+
ie = BrDocuments::IE::DF.new(number)
|
36
|
+
expect(ie).to be_valid
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/ie/es_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_pattern1"
|
3
|
+
|
4
|
+
describe BrDocuments::IE::ES do
|
5
|
+
describe "#formatted" do
|
6
|
+
it "returns a formatted ie" do
|
7
|
+
ie = BrDocuments::IE::ES.new("123456789")
|
8
|
+
expect(ie.formatted).to eq "123456789"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it_behaves_like "a pattern1", "ES"
|
13
|
+
end
|
@@ -0,0 +1,203 @@
|
|
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
|