br_documents 0.0.10 → 0.0.11
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 +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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 805f4830ab28ec221eefcdc51b00fdfddf9bc3af
|
4
|
+
data.tar.gz: 239d97d975b9dbc6c41f2520e1db31e6d8fde10b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 174bca0588609bb33086a8a53d86c00d2ceee75a01e704acde8e6baf656f73f9297255cb928b424327edc3619eb23e309796be5fe6bdc07692b7c4fab5c7e319
|
7
|
+
data.tar.gz: 0f4f93da74605754556aac786771804ec641d03ee6120d993c6cbcc054574b3a22fcfea5971840b6f8cdcf518cc0a9cd9fed0a8a6ba4efbf39fdcdb96818651c
|
data/Rakefile
CHANGED
data/lib/br_documents/ie/ap.rb
CHANGED
data/lib/br_documents/ie/mg.rb
CHANGED
data/lib/br_documents/ie/mt.rb
CHANGED
@@ -4,7 +4,7 @@ module BrDocuments
|
|
4
4
|
module IE
|
5
5
|
class MT < Pattern1
|
6
6
|
def initialize(number)
|
7
|
-
|
7
|
+
generate_zeros(number) { |zeros| number.insert(0, zeros) }
|
8
8
|
|
9
9
|
super
|
10
10
|
@mask = /^\d{4}\.?\d{3}\.?\d{3}\-?\d{1}$/
|
@@ -12,10 +12,10 @@ module BrDocuments
|
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
|
-
def
|
15
|
+
def generate_zeros(number)
|
16
16
|
just_numbers = number.gsub(/[\.\/-]/, "")
|
17
17
|
zeros = ("0" * 11).slice(just_numbers.length, 11)
|
18
|
-
yield "#{zeros}
|
18
|
+
yield "#{zeros}" if block_given?
|
19
19
|
end
|
20
20
|
|
21
21
|
def format_ie(number)
|
@@ -19,8 +19,23 @@ module BrDocuments
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def valid_digital_check?
|
22
|
-
|
23
|
-
|
22
|
+
calculated_check_digit = generate_digital_check(only_numbers, @weight).to_s
|
23
|
+
check_digit_valid = check_digit.eql? calculated_check_digit
|
24
|
+
remove_mask_of_number if check_digit_valid
|
25
|
+
|
26
|
+
check_digit_valid
|
27
|
+
end
|
28
|
+
|
29
|
+
def check_digit
|
30
|
+
only_numbers[-1]
|
31
|
+
end
|
32
|
+
|
33
|
+
def remove_mask_of_number
|
34
|
+
@number.replace only_numbers
|
35
|
+
end
|
36
|
+
|
37
|
+
def only_numbers
|
38
|
+
@number.gsub(/[\.\/-]/, "")
|
24
39
|
end
|
25
40
|
end
|
26
41
|
end
|
data/lib/br_documents/ie/pe.rb
CHANGED
@@ -5,7 +5,7 @@ module BrDocuments
|
|
5
5
|
module IE
|
6
6
|
class PE
|
7
7
|
def initialize(number)
|
8
|
-
if number.gsub(
|
8
|
+
if number.gsub(/[\.\/-]/, "").length <= 9
|
9
9
|
@validator = PE9.new(number)
|
10
10
|
else
|
11
11
|
@validator = PE14.new(number)
|
@@ -24,7 +24,7 @@ module BrDocuments
|
|
24
24
|
class PE14 < Pattern1
|
25
25
|
def initialize(number)
|
26
26
|
super
|
27
|
-
@mask = /^(\d{2}\.\d{1}\.\d{3}\.\d{7})$|^(\d{14})$/
|
27
|
+
@mask = /^(\d{2}\.\d{1}\.\d{3}\.\d{7}\-\d{1})$|^(\d{14})$/
|
28
28
|
@weight = [5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2]
|
29
29
|
end
|
30
30
|
|
data/lib/br_documents/ie/rn.rb
CHANGED
@@ -20,17 +20,17 @@ module BrDocuments
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def valid_old_format
|
23
|
-
regex = /^(\d{2}\.\d{3}\.\d{3}\-\d{1}
|
23
|
+
regex = /^(\d{2}\.\d{3}\.\d{3}\-\d{1})$|^(\d{9})$/
|
24
24
|
regex.match(@number).present?
|
25
25
|
end
|
26
26
|
|
27
27
|
def valid_new_format
|
28
|
-
regex = /^(\d{2}\.\d{1}\.\d{3}\.\d{3}\-\d{1}
|
28
|
+
regex = /^(\d{2}\.\d{1}\.\d{3}\.\d{3}\-\d{1})$|^(\d{10})$/
|
29
29
|
regex.match(@number).present?
|
30
30
|
end
|
31
31
|
|
32
32
|
def valid_digital_check?
|
33
|
-
@number.gsub!(
|
33
|
+
@number.gsub!(/[\.\/-]/, "")
|
34
34
|
|
35
35
|
weight = []
|
36
36
|
@number.length.downto(2).each {|w| weight << w }
|
data/lib/br_documents/ie/ro.rb
CHANGED
@@ -35,16 +35,19 @@ module BrDocuments
|
|
35
35
|
|
36
36
|
def valid_old_digital_check
|
37
37
|
weight = [3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
38
|
-
|
38
|
+
remove_mask!
|
39
39
|
@number[-1].eql? generate_digital_check(@number[-6, 6], weight).to_s
|
40
40
|
end
|
41
41
|
|
42
42
|
def valid_new_digital_check
|
43
43
|
weight = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
44
|
-
|
44
|
+
remove_mask!
|
45
45
|
@number[-1].eql? generate_digital_check(@number, weight).to_s
|
46
46
|
end
|
47
47
|
|
48
|
+
def remove_mask!
|
49
|
+
@number.gsub!(/[\.\/-]/, "")
|
50
|
+
end
|
48
51
|
end
|
49
52
|
end
|
50
53
|
end
|
data/lib/br_documents/version.rb
CHANGED
data/spec/ie/ac_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::AC do
|
4
|
+
RSpec.describe BrDocuments::IE::AC do
|
4
5
|
describe "#formatted" do
|
5
6
|
it "returns a formatted ie" do
|
6
|
-
ie =
|
7
|
+
ie = described_class.new("1234567890123")
|
7
8
|
expect(ie.formatted).to eq "12.345.678/901-23"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,30 +12,32 @@ describe BrDocuments::IE::AC do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
14
|
["01.448.52/88.91-50", "01.278.704/5555-7", "01.AB7.904/028-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 length different to 13" do
|
20
21
|
["1234567890", "123456789012"].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
|
["0135184641523", "0172567054082"].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
|
["0182235562573", "0104754560901"].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", "01.047.545/609-01"
|
39
42
|
end
|
40
43
|
end
|
data/spec/ie/al_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::AL 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 "123456789"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,23 +12,25 @@ describe BrDocuments::IE::AL do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with length different to 9" do
|
13
14
|
["1234567", "122345678901"].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
|
["245320152", "240046248"].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
|
["247975494", "248466313"].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", "248466313"
|
32
35
|
end
|
33
36
|
end
|
data/spec/ie/am_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::AM 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.345.678-9"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,30 +12,32 @@ describe BrDocuments::IE::AM do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
14
|
["8.535.410-60", "884.67.826-1", "13.BA9.093-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", "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
|
["500085276", "886770232"].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
|
["425721221", "310636396"].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.063.639-6"
|
39
42
|
end
|
40
43
|
end
|
data/spec/ie/ap_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::AP do
|
4
|
+
RSpec.describe BrDocuments::IE::AP 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 "123456789"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,23 +12,25 @@ describe BrDocuments::IE::AP do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with length different to 9" do
|
13
14
|
["1234567", "123456789012"].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
|
["030123456", "030182454"].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
|
["030123459", "030183458", "030213452"].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", "030213452"
|
32
35
|
end
|
33
36
|
end
|
data/spec/ie/ba_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
|
-
describe BrDocuments::IE::BA do
|
4
|
+
RSpec.describe BrDocuments::IE::BA do
|
4
5
|
describe "#formatted" do
|
5
6
|
context "when having 8 digits" do
|
6
7
|
it "returns a formatted ie" do
|
7
|
-
ie =
|
8
|
+
ie = described_class.new("12345678")
|
8
9
|
expect(ie.formatted).to eq "123456-78"
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
13
|
context "when having 9 digits" do
|
13
14
|
it "returns a formatted ie" do
|
14
|
-
ie =
|
15
|
+
ie = described_class.new("123456789")
|
15
16
|
expect(ie.formatted).to eq "1234567-89"
|
16
17
|
end
|
17
18
|
end
|
@@ -20,14 +21,14 @@ describe BrDocuments::IE::BA do
|
|
20
21
|
describe "#valid?" do
|
21
22
|
it "is invalid with malformed number" do
|
22
23
|
["82.060.187.373", "528843171-72", "AD402552219"].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 8 or 9" do
|
29
30
|
["1234567", "1234567890"].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
|
@@ -35,14 +36,14 @@ describe BrDocuments::IE::BA do
|
|
35
36
|
context "when having 8 digits" do
|
36
37
|
it "is invalid with invalid check number" do
|
37
38
|
["12345682", "61934523", "39034325"].each do |number|
|
38
|
-
ie =
|
39
|
+
ie = described_class.new(number)
|
39
40
|
expect(ie).to_not be_valid
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
43
44
|
it "is valid with valid number" do
|
44
45
|
["12345663", "61234557"].each do |number|
|
45
|
-
ie =
|
46
|
+
ie = described_class.new(number)
|
46
47
|
expect(ie).to be_valid
|
47
48
|
end
|
48
49
|
end
|
@@ -50,14 +51,16 @@ describe BrDocuments::IE::BA do
|
|
50
51
|
|
51
52
|
context "when having 9 digits" do
|
52
53
|
it "is invalid with invalid check number" do
|
53
|
-
ie =
|
54
|
+
ie = described_class.new("100052398")
|
54
55
|
expect(ie).to_not be_valid
|
55
56
|
end
|
56
57
|
|
57
58
|
it "is valid with valid number" do
|
58
|
-
ie =
|
59
|
+
ie = described_class.new("100000306")
|
59
60
|
expect(ie).to be_valid
|
60
61
|
end
|
61
62
|
end
|
63
|
+
|
64
|
+
include_examples "for to remove all masks", "1000003-06"
|
62
65
|
end
|
63
66
|
end
|
data/spec/ie/ce_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::CE 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", "CE"
|
14
|
+
|
15
|
+
include_examples "for to remove all masks", "12345678-9"
|
13
16
|
end
|
data/spec/ie/df_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::DF do
|
4
5
|
describe "#formatted" do
|
5
6
|
it "returns a formatted ie" do
|
6
|
-
ie =
|
7
|
+
ie = described_class.new("1234567890123")
|
7
8
|
expect(ie.formatted).to eq "12345678901-23"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,30 +12,32 @@ describe BrDocuments::IE::DF do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
14
|
["070648022871-3", "07.064.802.287-13", "0AB49871799-12"].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 13" do
|
20
21
|
["1234567890", "123456789012345"].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
|
["0733002219945", "0733002219943"].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
|
["0746069399231", "0784748156211"].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", "07847481562-11"
|
39
42
|
end
|
40
43
|
end
|
data/spec/ie/es_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::ES 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", "ES"
|
14
|
+
|
15
|
+
include_examples "for to remove all masks", "12345678-9"
|
13
16
|
end
|
data/spec/ie/go_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::GO 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.345.678-9"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,30 +12,32 @@ describe BrDocuments::IE::GO do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
14
|
["01.390415.9", "280541-600", "1C78150A5"].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", "122345678901"].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
|
["903473566", "493184742"].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
|
["155432214", "916876470"].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", "91.687.647-0"
|
39
42
|
end
|
40
43
|
end
|
data/spec/ie/ma_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::MA 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", "MA"
|
14
|
+
|
15
|
+
include_examples "for to remove all masks", "12345678-9"
|
13
16
|
end
|
data/spec/ie/mg_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::MG do
|
4
|
+
RSpec.describe BrDocuments::IE::MG do
|
4
5
|
describe "#formatted" do
|
5
6
|
it "returns a formatted ie" do
|
6
|
-
ie =
|
7
|
+
ie = described_class.new("1234567890123")
|
7
8
|
expect(ie.formatted).to eq "123.456.789/0123"
|
8
9
|
end
|
9
10
|
end
|
@@ -11,30 +12,32 @@ describe BrDocuments::IE::MG do
|
|
11
12
|
describe "#valid?" do
|
12
13
|
it "is invalid with malformed number" do
|
13
14
|
["36.311.266.571-75", "4.168.836.973-423", "560.139.778.87-BA"].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 13" do
|
20
21
|
["123456789", "1234567890123"].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
|
["4193434759812", "9427301981832"].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
|
["4193434759899", "9427301981820"].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", "942.730.198.18-20"
|
39
42
|
end
|
40
43
|
end
|
data/spec/ie/ms_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::MS 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", "MS"
|
14
|
+
|
15
|
+
include_examples "for to remove all masks", "12345678-9"
|
13
16
|
end
|