br_documents 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +5 -0
- data/lib/br_documents/ie/ap.rb +0 -1
- data/lib/br_documents/ie/mg.rb +1 -1
- data/lib/br_documents/ie/mt.rb +3 -3
- data/lib/br_documents/ie/pattern1.rb +17 -2
- data/lib/br_documents/ie/pattern2.rb +1 -1
- data/lib/br_documents/ie/pe.rb +2 -2
- data/lib/br_documents/ie/rn.rb +3 -3
- data/lib/br_documents/ie/ro.rb +5 -2
- data/lib/br_documents/version.rb +1 -1
- data/spec/ie/ac_spec.rb +9 -6
- data/spec/ie/al_spec.rb +7 -4
- data/spec/ie/am_spec.rb +8 -5
- data/spec/ie/ap_spec.rb +8 -5
- data/spec/ie/ba_spec.rb +12 -9
- data/spec/ie/ce_spec.rb +4 -1
- data/spec/ie/df_spec.rb +8 -5
- data/spec/ie/es_spec.rb +4 -1
- data/spec/ie/go_spec.rb +8 -5
- data/spec/ie/ma_spec.rb +4 -1
- data/spec/ie/mg_spec.rb +9 -6
- data/spec/ie/ms_spec.rb +4 -1
- data/spec/ie/mt_spec.rb +10 -7
- data/spec/ie/pa_spec.rb +8 -5
- data/spec/ie/pb_spec.rb +4 -1
- data/spec/ie/pe_spec.rb +11 -8
- data/spec/ie/pi_spec.rb +4 -1
- data/spec/ie/pr_spec.rb +7 -4
- data/spec/ie/rj_spec.rb +8 -5
- data/spec/ie/rn_spec.rb +11 -8
- data/spec/ie/ro_spec.rb +11 -8
- data/spec/ie/rr_spec.rb +8 -5
- data/spec/ie/rs_spec.rb +8 -5
- data/spec/ie/sc_spec.rb +8 -5
- data/spec/ie/se_spec.rb +4 -1
- data/spec/ie/shared_examples_for_pattern1.rb +5 -5
- data/spec/ie/shared_examples_for_to_remove_all_masks.rb +17 -0
- data/spec/ie/sp_spec.rb +8 -5
- data/spec/ie/to_spec.rb +15 -12
- metadata +5 -3
data/spec/ie/mt_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
2
3
|
|
3
|
-
describe BrDocuments::IE::MT do
|
4
|
+
RSpec.describe BrDocuments::IE::MT do
|
4
5
|
describe "#formatted" do
|
5
6
|
it "returns a formatted ie" do
|
6
|
-
ie =
|
7
|
+
ie = described_class.new("12345678901")
|
7
8
|
expect(ie.formatted).to eq "1234567890-1"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,31 +12,33 @@ describe BrDocuments::IE::MT do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
14
|
["82.060.187.373", "528843171-72", "AD402552219"].each do |number|
|
14
|
-
ie =
|
15
|
+
ie = described_class.new(number)
|
15
16
|
expect(ie).to_not be_valid
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
20
|
context "when the number is greater than 11" do
|
20
|
-
subject {
|
21
|
+
subject { described_class.new("123456789012") }
|
21
22
|
|
22
|
-
it "is invalid
|
23
|
+
it "is invalid" do
|
23
24
|
expect(subject).to_not be_valid
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
28
|
it "is invalid with invalid check number" do
|
28
29
|
["00404609123", "83646580222"].each do |number|
|
29
|
-
ie =
|
30
|
+
ie = described_class.new(number)
|
30
31
|
expect(ie).to_not be_valid
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
35
|
it "is valid with valid number" do
|
35
36
|
["0013000001-9", "82060187373", "132631946", "13.263.194-6"].each do |number|
|
36
|
-
ie =
|
37
|
+
ie = described_class.new(number)
|
37
38
|
expect(ie).to be_valid
|
38
39
|
end
|
39
40
|
end
|
41
|
+
|
42
|
+
include_examples "for to remove all masks", "0013000001-9"
|
40
43
|
end
|
41
44
|
end
|
data/spec/ie/pa_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
2
3
|
|
3
4
|
describe BrDocuments::IE::PA do
|
4
5
|
describe "#formatted" do
|
5
6
|
it "returns a formatted ie" do
|
6
|
-
ie =
|
7
|
+
ie = described_class.new("123456789")
|
7
8
|
expect(ie.formatted).to eq "12-345678-9"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,30 +12,32 @@ describe BrDocuments::IE::PA do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
14
|
["15.361.802-7", "15-48556-93", "15-4AB752-7"].each do |number|
|
14
|
-
ie =
|
15
|
+
ie = described_class.new(number)
|
15
16
|
expect(ie).to_not be_valid
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
20
|
it "is invalid with length different to 9" do
|
20
21
|
["1234567", "12345678901"].each do |number|
|
21
|
-
ie =
|
22
|
+
ie = described_class.new(number)
|
22
23
|
expect(ie).to_not be_valid
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
it "is invalid with invalid check number" do
|
27
28
|
["152653852", "157252799"].each do |number|
|
28
|
-
ie =
|
29
|
+
ie = described_class.new(number)
|
29
30
|
expect(ie).to_not be_valid
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
34
|
it "is valid with valid number" do
|
34
35
|
["159636841", "158667794"].each do |number|
|
35
|
-
ie =
|
36
|
+
ie = described_class.new(number)
|
36
37
|
expect(ie).to be_valid
|
37
38
|
end
|
38
39
|
end
|
40
|
+
|
41
|
+
include_examples "for to remove all masks", "15-866779-4"
|
39
42
|
end
|
40
43
|
end
|
data/spec/ie/pb_spec.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require_relative "shared_examples_for_pattern1"
|
3
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
3
4
|
|
4
5
|
describe BrDocuments::IE::PB do
|
5
6
|
describe "#formatted" do
|
6
7
|
it "returns a formatted ie" do
|
7
|
-
ie =
|
8
|
+
ie = described_class.new("123456789")
|
8
9
|
expect(ie.formatted).to eq "12345678-9"
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
13
|
it_behaves_like "a pattern1", "PB"
|
14
|
+
|
15
|
+
include_examples "for to remove all masks", "12345678-9"
|
13
16
|
end
|
data/spec/ie/pe_spec.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
2
3
|
|
3
4
|
describe BrDocuments::IE::PE do
|
4
5
|
describe "#formatted" do
|
5
6
|
context "when having 9 digits" do
|
6
7
|
it "returns a formatted ie" do
|
7
|
-
ie =
|
8
|
+
ie = described_class.new("123456789")
|
8
9
|
expect(ie.formatted).to eq "1234567-89"
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
13
|
context "when having 14 digits" do
|
13
14
|
it "returns a formatted ie" do
|
14
|
-
ie =
|
15
|
+
ie = described_class.new("18100100000049")
|
15
16
|
expect(ie.formatted).to eq "18.1.001.0000004-9"
|
16
17
|
end
|
17
18
|
end
|
@@ -20,40 +21,42 @@ describe BrDocuments::IE::PE do
|
|
20
21
|
describe "#valid?" do
|
21
22
|
it "is invalid with malformed number" do
|
22
23
|
["15711188-1", "3.661.165-41", "3AB8287-00", "18.1.001.000000-49"].each do |number|
|
23
|
-
ie =
|
24
|
+
ie = described_class.new(number)
|
24
25
|
expect(ie).to_not be_valid
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
it "is invalid with length different to 9 or 14" do
|
29
30
|
["1234567", "12345678901", "0123456789012345"].each do |number|
|
30
|
-
ie =
|
31
|
+
ie = described_class.new(number)
|
31
32
|
expect(ie).to_not be_valid
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
36
|
context "when having 9 digits" do
|
36
37
|
it "is invalid with invalid check number" do
|
37
|
-
ie =
|
38
|
+
ie = described_class.new("838872602")
|
38
39
|
expect(ie).to_not be_valid
|
39
40
|
end
|
40
41
|
|
41
42
|
it "is valid with valid number" do
|
42
|
-
ie =
|
43
|
+
ie = described_class.new("418873607")
|
43
44
|
expect(ie).to be_valid
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
48
|
context "when having 14 digits" do
|
48
49
|
it "is invalid with invalid check number" do
|
49
|
-
ie =
|
50
|
+
ie = described_class.new("18100100000048")
|
50
51
|
expect(ie).to_not be_valid
|
51
52
|
end
|
52
53
|
|
53
54
|
it "is valid with valid number" do
|
54
|
-
ie =
|
55
|
+
ie = described_class.new("18100100000049")
|
55
56
|
expect(ie).to be_valid
|
56
57
|
end
|
57
58
|
end
|
59
|
+
|
60
|
+
include_examples "for to remove all masks", "18.1.001.0000004-9"
|
58
61
|
end
|
59
62
|
end
|
data/spec/ie/pi_spec.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require_relative "shared_examples_for_pattern1"
|
3
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
3
4
|
|
4
5
|
describe BrDocuments::IE::PI do
|
5
6
|
describe "#formatted" do
|
6
7
|
it "returns a formatted ie" do
|
7
|
-
ie =
|
8
|
+
ie = described_class.new("123456789")
|
8
9
|
expect(ie.formatted).to eq "123456789"
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
13
|
it_behaves_like "a pattern1", "PI"
|
14
|
+
|
15
|
+
include_examples "for to remove all masks", "12345678-9"
|
13
16
|
end
|
data/spec/ie/pr_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
2
3
|
|
3
4
|
describe BrDocuments::IE::PR do
|
4
5
|
describe "#formatted" do
|
5
6
|
it "returns a formatted ie" do
|
6
|
-
ie =
|
7
|
+
ie = described_class.new("1234567890")
|
7
8
|
expect(ie.formatted).to eq "12345678-90"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,23 +12,25 @@ describe BrDocuments::IE::PR do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
14
|
["1016323-850", "10163238.50"].each do |number|
|
14
|
-
ie =
|
15
|
+
ie = described_class.new(number)
|
15
16
|
expect(ie).to_not be_valid
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
20
|
it "is invalid with invalid check number" do
|
20
21
|
["10163238-51", "10163238-40"].each do |number|
|
21
|
-
ie =
|
22
|
+
ie = described_class.new(number)
|
22
23
|
expect(ie).to_not be_valid
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
it "is valid with valid number" do
|
27
28
|
["1016323850", "10163238-50"].each do |number|
|
28
|
-
ie =
|
29
|
+
ie = described_class.new(number)
|
29
30
|
expect(ie).to be_valid
|
30
31
|
end
|
31
32
|
end
|
33
|
+
|
34
|
+
include_examples "for to remove all masks", "10163238-50"
|
32
35
|
end
|
33
36
|
end
|
data/spec/ie/rj_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
2
3
|
|
3
4
|
describe BrDocuments::IE::RJ do
|
4
5
|
describe "#formatted" do
|
5
6
|
it "returns a formatted ie" do
|
6
|
-
ie =
|
7
|
+
ie = described_class.new("12345678")
|
7
8
|
expect(ie.formatted).to eq "12.345.67-8"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,30 +12,32 @@ describe BrDocuments::IE::RJ do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
14
|
["00.55.55.25", "34.09.25-08", "0A220C18"].each do |number|
|
14
|
-
ie =
|
15
|
+
ie = described_class.new(number)
|
15
16
|
expect(ie).to_not be_valid
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
20
|
it "is invalid with length different to 8" do
|
20
21
|
["1234567890", "12345"].each do |number|
|
21
|
-
ie =
|
22
|
+
ie = described_class.new(number)
|
22
23
|
expect(ie).to_not be_valid
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
it "is invalid with invalid check number" do
|
27
28
|
["99228676", "48388923"].each do |number|
|
28
|
-
ie =
|
29
|
+
ie = described_class.new(number)
|
29
30
|
expect(ie).to_not be_valid
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
34
|
it "is valid with valid number" do
|
34
35
|
["80172010", "31.864.95-0", "85.994.964"].each do |number|
|
35
|
-
ie =
|
36
|
+
ie = described_class.new(number)
|
36
37
|
expect(ie).to be_valid
|
37
38
|
end
|
38
39
|
end
|
40
|
+
|
41
|
+
include_examples "for to remove all masks", "31.864.95-0"
|
39
42
|
end
|
40
43
|
end
|
data/spec/ie/rn_spec.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
2
3
|
|
3
4
|
describe BrDocuments::IE::RN do
|
4
5
|
describe "#formatted" do
|
5
6
|
context "when having 9 digits" do
|
6
7
|
it "returns a formatted ie" do
|
7
|
-
ie =
|
8
|
+
ie = described_class.new("123456789")
|
8
9
|
expect(ie.formatted).to eq "12.345.678-9"
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
13
|
context "when having 10 digits" do
|
13
14
|
it "returns a formatted ie" do
|
14
|
-
ie =
|
15
|
+
ie = described_class.new("1234567890")
|
15
16
|
expect(ie.formatted).to eq "12.3.456.789-0"
|
16
17
|
end
|
17
18
|
end
|
@@ -20,40 +21,42 @@ describe BrDocuments::IE::RN do
|
|
20
21
|
describe "#valid?" do
|
21
22
|
it "is invalid with malformed number" do
|
22
23
|
["9.012.207-95", "617.964.80-7", "25.9AB.924-6"].each do |number|
|
23
|
-
ie =
|
24
|
+
ie = described_class.new(number)
|
24
25
|
expect(ie).to_not be_valid
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
it "is invalid with length different to 9 or 10" do
|
29
30
|
["12345678", "12345678901"].each do |number|
|
30
|
-
ie =
|
31
|
+
ie = described_class.new(number)
|
31
32
|
expect(ie).to_not be_valid
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
36
|
context "when having 9 digits" do
|
36
37
|
it "is invalid with invalid check number" do
|
37
|
-
ie =
|
38
|
+
ie = described_class.new("794050643")
|
38
39
|
expect(ie).to_not be_valid
|
39
40
|
end
|
40
41
|
|
41
42
|
it "is valid with valid number" do
|
42
|
-
ie =
|
43
|
+
ie = described_class.new("200400401")
|
43
44
|
expect(ie).to be_valid
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
48
|
context "when having 10 digits" do
|
48
49
|
it "is invalid with invalid check number" do
|
49
|
-
ie =
|
50
|
+
ie = described_class.new("1153296142")
|
50
51
|
expect(ie).to_not be_valid
|
51
52
|
end
|
52
53
|
|
53
54
|
it "is valid with valid number" do
|
54
|
-
ie =
|
55
|
+
ie = described_class.new("2000400400")
|
55
56
|
expect(ie).to be_valid
|
56
57
|
end
|
57
58
|
end
|
59
|
+
|
60
|
+
include_examples "for to remove all masks", "20.0.040.040-0"
|
58
61
|
end
|
59
62
|
end
|
data/spec/ie/ro_spec.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
2
3
|
|
3
4
|
describe BrDocuments::IE::RO do
|
4
5
|
describe "#formatted" do
|
5
6
|
context "when having 9 digits" do
|
6
7
|
it "returns a formatted ie" do
|
7
|
-
ie =
|
8
|
+
ie = described_class.new("123456789")
|
8
9
|
expect(ie.formatted).to eq "123.45678-9"
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
13
|
context "when having 14 digits" do
|
13
14
|
it "returns a formatted ie" do
|
14
|
-
ie =
|
15
|
+
ie = described_class.new("12345678901234")
|
15
16
|
expect(ie.formatted).to eq "1234567890123-4"
|
16
17
|
end
|
17
18
|
end
|
@@ -20,40 +21,42 @@ describe BrDocuments::IE::RO do
|
|
20
21
|
describe "#valid?" do
|
21
22
|
it "is invalid with malformed number" do
|
22
23
|
["20.049.788-6", "2.004.978-86", "937.03AB1-6"].each do |number|
|
23
|
-
ie =
|
24
|
+
ie = described_class.new(number)
|
24
25
|
expect(ie).to_not be_valid
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
it "is invalid with length different to 9 or 14" do
|
29
30
|
["1234567", "123456789012", "12345678901234567"].each do |number|
|
30
|
-
ie =
|
31
|
+
ie = described_class.new(number)
|
31
32
|
expect(ie).to_not be_valid
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
36
|
context "when having 9 digits" do
|
36
37
|
it "is invalid with invalid check number" do
|
37
|
-
ie =
|
38
|
+
ie = described_class.new("134725252")
|
38
39
|
expect(ie).to_not be_valid
|
39
40
|
end
|
40
41
|
|
41
42
|
it "is valid with valid number" do
|
42
|
-
ie =
|
43
|
+
ie = described_class.new("101625213")
|
43
44
|
expect(ie).to be_valid
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
48
|
context "when having 14 digits" do
|
48
49
|
it "is invalid with invalid check number" do
|
49
|
-
ie =
|
50
|
+
ie = described_class.new("02539835229263")
|
50
51
|
expect(ie).to_not be_valid
|
51
52
|
end
|
52
53
|
|
53
54
|
it "is valid with valid number" do
|
54
|
-
ie =
|
55
|
+
ie = described_class.new("00000000625213")
|
55
56
|
expect(ie).to be_valid
|
56
57
|
end
|
57
58
|
end
|
59
|
+
|
60
|
+
include_examples "for to remove all masks", "0000000062521-3"
|
58
61
|
end
|
59
62
|
end
|
data/spec/ie/rr_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
2
3
|
|
3
4
|
describe BrDocuments::IE::RR do
|
4
5
|
describe "#formatted" do
|
5
6
|
it "returns a formatted ie" do
|
6
|
-
ie =
|
7
|
+
ie = described_class.new("123456789")
|
7
8
|
expect(ie.formatted).to eq "12345678-9"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,30 +12,32 @@ describe BrDocuments::IE::RR do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
14
|
["24.410.109-5", "2456128-32", "24AB0559-6"].each do |number|
|
14
|
-
ie =
|
15
|
+
ie = described_class.new(number)
|
15
16
|
expect(ie).to_not be_valid
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
20
|
it "is invalid with length different to 9" do
|
20
21
|
["1234567", "123456789"].each do |number|
|
21
|
-
ie =
|
22
|
+
ie = described_class.new(number)
|
22
23
|
expect(ie).to_not be_valid
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
it "is invalid with invalid check number" do
|
27
28
|
["242131962", "247318099"].each do |number|
|
28
|
-
ie =
|
29
|
+
ie = described_class.new(number)
|
29
30
|
expect(ie).to_not be_valid
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
34
|
it "is valid with valid number" do
|
34
35
|
["241432573", "240886456"].each do |number|
|
35
|
-
ie =
|
36
|
+
ie = described_class.new(number)
|
36
37
|
expect(ie).to be_valid
|
37
38
|
end
|
38
39
|
end
|
40
|
+
|
41
|
+
include_examples "for to remove all masks", "24088645-6"
|
39
42
|
end
|
40
43
|
end
|
data/spec/ie/rs_spec.rb
CHANGED
@@ -1,38 +1,41 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
2
3
|
|
3
4
|
describe BrDocuments::IE::RS do
|
4
5
|
describe "#formatted" do
|
5
6
|
it "returns a formatted ie" do
|
6
|
-
ie =
|
7
|
+
ie = described_class.new("1234567890")
|
7
8
|
expect(ie.formatted).to eq "123/4567890"
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
|
-
ie =
|
14
|
+
ie = described_class.new("17/70169293")
|
14
15
|
expect(ie).to_not be_valid
|
15
16
|
end
|
16
17
|
|
17
18
|
it "is invalid with length different to 10" do
|
18
19
|
["123456789", "12345678901"].each do |number|
|
19
|
-
ie =
|
20
|
+
ie = described_class.new(number)
|
20
21
|
expect(ie).to_not be_valid
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
25
|
it "is invalid with invalid check number" do
|
25
26
|
["1770169292", "034/0112114"].each do |number|
|
26
|
-
ie =
|
27
|
+
ie = described_class.new(number)
|
27
28
|
expect(ie).to_not be_valid
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
32
|
it "is valid with valid number" do
|
32
33
|
["1770169293", "034/0112115"].each do |number|
|
33
|
-
ie =
|
34
|
+
ie = described_class.new(number)
|
34
35
|
expect(ie).to be_valid
|
35
36
|
end
|
36
37
|
end
|
38
|
+
|
39
|
+
include_examples "for to remove all masks", "034/0112115"
|
37
40
|
end
|
38
41
|
end
|
data/spec/ie/sc_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
2
3
|
|
3
4
|
describe BrDocuments::IE::SC do
|
4
5
|
describe "#formatted" do
|
5
6
|
it "returns a formatted ie" do
|
6
|
-
ie =
|
7
|
+
ie = described_class.new("123456789")
|
7
8
|
expect(ie.formatted).to eq "123.456.789"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,30 +12,32 @@ describe BrDocuments::IE::SC do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
14
|
["253.66.7852", "25.4062.407", "A12345678"].each do |number|
|
14
|
-
ie =
|
15
|
+
ie = described_class.new(number)
|
15
16
|
expect(ie).to_not be_valid
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
20
|
it "is invalid with length different to 9" do
|
20
21
|
["1234567890", "12345678"].each do |number|
|
21
|
-
ie =
|
22
|
+
ie = described_class.new(number)
|
22
23
|
expect(ie).to_not be_valid
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
it "is invalid with invalid check number" do
|
27
28
|
["253667853", "254.062.408"].each do |number|
|
28
|
-
ie =
|
29
|
+
ie = described_class.new(number)
|
29
30
|
expect(ie).to_not be_valid
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
34
|
it "is valid with valid number" do
|
34
35
|
["253667852", "254.062.407"].each do |number|
|
35
|
-
ie =
|
36
|
+
ie = described_class.new(number)
|
36
37
|
expect(ie).to be_valid
|
37
38
|
end
|
38
39
|
end
|
40
|
+
|
41
|
+
include_examples "for to remove all masks", "254.062.407"
|
39
42
|
end
|
40
43
|
end
|
data/spec/ie/se_spec.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require_relative "shared_examples_for_pattern1"
|
3
|
+
require_relative "shared_examples_for_to_remove_all_masks"
|
3
4
|
|
4
5
|
describe BrDocuments::IE::SE do
|
5
6
|
describe "#formatted" do
|
6
7
|
it "returns a formatted ie" do
|
7
|
-
ie =
|
8
|
+
ie = described_class.new("123456789")
|
8
9
|
expect(ie.formatted).to eq "12345678-9"
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
13
|
it_behaves_like "a pattern1", "SE"
|
14
|
+
|
15
|
+
include_examples "for to remove all masks", "12345678-9"
|
13
16
|
end
|
@@ -1,31 +1,31 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
shared_examples "a pattern1" do |uf|
|
4
|
-
describe "#valid?" do
|
4
|
+
describe BrDocuments::IE::Factory, "#valid?" do
|
5
5
|
it "is invalid with malformed number" do
|
6
6
|
["1922212-21", "72.219.398-0", "63BA9943-8"].each do |number|
|
7
|
-
ie =
|
7
|
+
ie = described_class.create(uf, number)
|
8
8
|
expect(ie).to_not be_valid
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
it "is invalid with length different to 9" do
|
13
13
|
["1234567", "12345678901"].each do |number|
|
14
|
-
ie =
|
14
|
+
ie = described_class.create(uf, number)
|
15
15
|
expect(ie).to_not be_valid
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
it "is invalid with invalid check number" do
|
20
20
|
["226905727", "662637732"].each do |number|
|
21
|
-
ie =
|
21
|
+
ie = described_class.create(uf, number)
|
22
22
|
expect(ie).to_not be_valid
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
it "is valid with valid number" do
|
27
27
|
["732766940", "665822081"].each do |number|
|
28
|
-
ie =
|
28
|
+
ie = described_class.create(uf, number)
|
29
29
|
expect(ie).to be_valid
|
30
30
|
end
|
31
31
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
shared_examples "for to remove all masks" do |valid_number_with_mask|
|
4
|
+
describe "#valid?" do
|
5
|
+
|
6
|
+
context "when the number is valid" do
|
7
|
+
subject { described_class.new(valid_number_with_mask) }
|
8
|
+
|
9
|
+
it "removes the mask" do
|
10
|
+
expect(subject).to be_valid
|
11
|
+
|
12
|
+
only_numbers = valid_number_with_mask.gsub(/[\.\/-]/, "")
|
13
|
+
expect(valid_number_with_mask).to eq only_numbers
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|