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.
data/spec/ie/sp_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::SP do
4
5
  describe "#formatted" do
5
6
  context "when having 12 digits" do
6
7
  it "returns a formatted ie" do
7
- ie = BrDocuments::IE::SP.new("110042490114")
8
+ ie = described_class.new("110042490114")
8
9
  expect(ie.formatted).to eq "110.042.490.114"
9
10
  end
10
11
  end
11
12
 
12
13
  context "when having 13 digits" do
13
14
  it "returns a formatted ie" do
14
- ie = BrDocuments::IE::SP.new("P011004243002")
15
+ ie = described_class.new("P011004243002")
15
16
  expect(ie.formatted).to eq "P-01100424.3/002"
16
17
  end
17
18
  end
@@ -20,23 +21,25 @@ describe BrDocuments::IE::SP do
20
21
  describe "#valid?" do
21
22
  it "is invalid with malformed number" do
22
23
  ["36.9107.395114", "527.08212.8110"].each do |number|
23
- ie = BrDocuments::IE::SP.new(number)
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 invalid check number" do
29
30
  ["110042490113", "110.042.491.114", "P-01100424.4/002"].each do |number|
30
- ie = BrDocuments::IE::SP.new(number)
31
+ ie = described_class.new(number)
31
32
  expect(ie).to_not be_valid
32
33
  end
33
34
  end
34
35
 
35
36
  it "is valid with valid number" do
36
37
  ["110042490114", "110.042.490.114", "P-01100424.3/002"].each do |number|
37
- ie = BrDocuments::IE::SP.new(number)
38
+ ie = described_class.new(number)
38
39
  expect(ie).to be_valid
39
40
  end
40
41
  end
42
+
43
+ include_examples "for to remove all masks", "P-01100424.3/002"
41
44
  end
42
45
  end
data/spec/ie/to_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::TO do
4
5
  describe "#formatted" do
5
6
  context "when having 9 digits" do
6
- subject { BrDocuments::IE::TO.new("123456789") }
7
+ subject { described_class.new("123456789") }
7
8
 
8
9
  it "returns a formatted ie" do
9
10
  expect(subject.formatted).to eq "12.345678-9"
@@ -11,7 +12,7 @@ describe BrDocuments::IE::TO do
11
12
  end
12
13
 
13
14
  context "when having 11 digits" do
14
- subject { BrDocuments::IE::TO.new("12345678901") }
15
+ subject { described_class.new("12345678901") }
15
16
 
16
17
  it "returns a formatted ie" do
17
18
  expect(subject.formatted).to eq "12.34.567890-1"
@@ -22,14 +23,14 @@ describe BrDocuments::IE::TO do
22
23
  describe "#valid?" do
23
24
  it "is invalid with malformed number" do
24
25
  ["2.903.593.362-3", "29.02.79268-45", "29.02.5AB420-5"].each do |number|
25
- ie = BrDocuments::IE::TO.new(number)
26
+ ie = described_class.new(number)
26
27
  expect(ie).to_not be_valid
27
28
  end
28
29
  end
29
30
 
30
31
  it "is invalid with length different of 9 or 11" do
31
32
  ["12345678", "1234567890", "123456789012"].each do |number|
32
- ie = BrDocuments::IE::TO.new(number)
33
+ ie = described_class.new(number)
33
34
  expect(ie).to_not be_valid
34
35
  end
35
36
  end
@@ -37,28 +38,28 @@ describe BrDocuments::IE::TO do
37
38
  context "when having 9 digits" do
38
39
  it "is invalid with invalid check number" do
39
40
  ["290227835", "294083153"].each do |number|
40
- ie = BrDocuments::IE::TO.new(number)
41
+ ie = described_class.new(number)
41
42
  expect(ie).to_not be_valid
42
43
  end
43
44
  end
44
45
 
45
46
  it "is invalid with correct check number but invalid mask" do
46
47
  ["29-022783-6", "29.408315.4"].each do |number|
47
- ie = BrDocuments::IE::TO.new(number)
48
+ ie = described_class.new(number)
48
49
  expect(ie).to_not be_valid
49
50
  end
50
51
  end
51
52
 
52
53
  it "is valid with valid number" do
53
54
  ["290227836", "294083154"].each do |number|
54
- ie = BrDocuments::IE::TO.new(number)
55
+ ie = described_class.new(number)
55
56
  expect(ie).to be_valid
56
57
  end
57
58
  end
58
59
 
59
60
  it "is valid with valid masked number" do
60
61
  ["29.022783-6", "29.408315-4"].each do |number|
61
- ie = BrDocuments::IE::TO.new(number)
62
+ ie = described_class.new(number)
62
63
  expect(ie).to be_valid
63
64
  end
64
65
  end
@@ -67,31 +68,33 @@ describe BrDocuments::IE::TO do
67
68
  context "when having 11 digits" do
68
69
  it "is invalid with invalid check number" do
69
70
  ["29023864406", "29023864409"].each do |number|
70
- ie = BrDocuments::IE::TO.new(number)
71
+ ie = described_class.new(number)
71
72
  expect(ie).to_not be_valid
72
73
  end
73
74
  end
74
75
 
75
76
  it "is invalid with correct check number but invalid mask" do
76
77
  ["29-99.200143-6", "29.99.231741.7"].each do |number|
77
- ie = BrDocuments::IE::TO.new(number)
78
+ ie = described_class.new(number)
78
79
  expect(ie).to_not be_valid
79
80
  end
80
81
  end
81
82
 
82
83
  it "is valid with valid number" do
83
84
  ["29992001436", "29992317417"].each do |number|
84
- ie = BrDocuments::IE::TO.new(number)
85
+ ie = described_class.new(number)
85
86
  expect(ie).to be_valid
86
87
  end
87
88
  end
88
89
 
89
90
  it "is valid with valid masked number" do
90
91
  ["29.99.200143-6", "29.99.231741-7"].each do |number|
91
- ie = BrDocuments::IE::TO.new(number)
92
+ ie = described_class.new(number)
92
93
  expect(ie).to be_valid
93
94
  end
94
95
  end
95
96
  end
97
+
98
+ include_examples "for to remove all masks", "29.99.231741-7"
96
99
  end
97
100
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: br_documents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - ASSEINFO - Sistemas de Informação
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-03 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -209,6 +209,7 @@ files:
209
209
  - spec/ie/sc_spec.rb
210
210
  - spec/ie/se_spec.rb
211
211
  - spec/ie/shared_examples_for_pattern1.rb
212
+ - spec/ie/shared_examples_for_to_remove_all_masks.rb
212
213
  - spec/ie/sp_spec.rb
213
214
  - spec/ie/to_spec.rb
214
215
  - spec/ie_validator_spec.rb
@@ -234,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
235
  version: '0'
235
236
  requirements: []
236
237
  rubyforge_project:
237
- rubygems_version: 2.4.2
238
+ rubygems_version: 2.4.5
238
239
  signing_key:
239
240
  specification_version: 4
240
241
  summary: Validates brazilian documents like CPF, CNPJ and IE. It can be used with
@@ -271,6 +272,7 @@ test_files:
271
272
  - spec/ie/sc_spec.rb
272
273
  - spec/ie/se_spec.rb
273
274
  - spec/ie/shared_examples_for_pattern1.rb
275
+ - spec/ie/shared_examples_for_to_remove_all_masks.rb
274
276
  - spec/ie/sp_spec.rb
275
277
  - spec/ie/to_spec.rb
276
278
  - spec/ie_validator_spec.rb