valvat 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +2 -2
- data/CHANGES.md +9 -1
- data/README.md +3 -2
- data/gemfiles/activemodel-3-2 +1 -1
- data/gemfiles/activemodel-4 +1 -1
- data/gemfiles/standalone +1 -1
- data/lib/valvat/locales/da.yml +34 -0
- data/lib/valvat/locales/es.yml +34 -0
- data/lib/valvat/locales/fr.yml +33 -0
- data/lib/valvat/version.rb +1 -1
- data/spec/active_model/validations/valvat_validator_spec.rb +43 -43
- data/spec/spec_helper.rb +0 -1
- data/spec/valvat/checksum/at_spec.rb +2 -2
- data/spec/valvat/checksum/be_spec.rb +2 -2
- data/spec/valvat/checksum/bg_spec.rb +2 -2
- data/spec/valvat/checksum/de_spec.rb +2 -2
- data/spec/valvat/checksum/dk_spec.rb +2 -2
- data/spec/valvat/checksum/es_spec.rb +2 -2
- data/spec/valvat/checksum/fi_spec.rb +2 -2
- data/spec/valvat/checksum/gr_spec.rb +2 -2
- data/spec/valvat/checksum/ie_spec.rb +2 -2
- data/spec/valvat/checksum/it_spec.rb +4 -4
- data/spec/valvat/checksum/lu_spec.rb +2 -2
- data/spec/valvat/checksum/nl_spec.rb +2 -2
- data/spec/valvat/checksum/pl_spec.rb +3 -3
- data/spec/valvat/checksum/pt_spec.rb +3 -3
- data/spec/valvat/checksum/se_spec.rb +3 -3
- data/spec/valvat/checksum/si_spec.rb +4 -4
- data/spec/valvat/checksum_spec.rb +3 -3
- data/spec/valvat/lookup_spec.rb +17 -17
- data/spec/valvat/syntax_spec.rb +170 -170
- data/spec/valvat/utils_spec.rb +24 -24
- data/spec/valvat_spec.rb +87 -87
- data/valvat.gemspec +3 -3
- metadata +10 -7
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::BE do
|
4
4
|
%w(BE0123456749 BE0136695962 BE0817331995).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::BG do
|
4
4
|
%w(BG123456786 BG926067143 BG926067770 BG0101011739 BG0121013021 BG5041019992 BG1521687837 BG1431889037).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-4]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::DE do
|
4
4
|
%w(DE280857971 DE281381706 DE283108332 DE813622378 DE813628528 DE814178359 DE811907980).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::DK do
|
4
4
|
%w(DK13585628 DK61126228).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::ES do
|
4
4
|
%w(ESA13585625 ESB83871236 ESE54507058 ES25139013J ESQ1518001A ESQ5018001G ESX4942978W ESX7676464F ESB10317980).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-6]}#{valid_vat[-2]}#{valid_vat[-5]}#{valid_vat[-4]}#{valid_vat[-3]}#{valid_vat[-1]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::FI do
|
4
4
|
%w(FI13669598 FI20584306 FI01080233).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-3]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::GR do
|
4
4
|
%w(EL123456783 EL094543092 EL998219694).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::IE do
|
4
4
|
%w(IE8473625E IE0123459N IE9B12345N).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-2]}#{valid_vat[-3]}#{valid_vat[-1]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,21 +3,21 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::IT do
|
4
4
|
%w(IT12345670785 IT01897810162 IT00197200132 IT02762750210).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
it "returns false on invalid special case vat IT12345671783" do
|
17
|
-
Valvat::Checksum.validate("IT12345671783").
|
17
|
+
expect(Valvat::Checksum.validate("IT12345671783")).to eql(false)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "returns false on invalid special case vat IT00000000133" do
|
21
|
-
Valvat::Checksum.validate("IT00000000133").
|
21
|
+
expect(Valvat::Checksum.validate("IT00000000133")).to eql(false)
|
22
22
|
end
|
23
23
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::LU do
|
4
4
|
%w(LU13669580 LU25361352 LU23124018 LU17560609).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-2]}#{valid_vat[-3]}#{valid_vat[-1]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::NL do
|
4
4
|
%w(NL123456782B12 NL802549391B01 NL808661863B01 NL820893559B01).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-5]}#{valid_vat[-2]}#{valid_vat[-3]}#{valid_vat[-4]}#{valid_vat[-1]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,17 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::PL do
|
4
4
|
%w(PL8567346215 PL5260211587 PL9720575348 PL5272650022).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-3]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
it "returns false on special case invalid vat PL8566445330" do
|
17
|
-
Valvat::Checksum.validate("PL8566445330").
|
17
|
+
expect(Valvat::Checksum.validate("PL8566445330")).to eql(false)
|
18
18
|
end
|
19
19
|
end
|
@@ -6,13 +6,13 @@ describe Valvat::Checksum::PT do
|
|
6
6
|
|
7
7
|
%w(PT136695973 PT501413197 PT503037753 PT500243590 PT500100144 PT502921838).each do |valid_vat|
|
8
8
|
it "returns true on valid vat #{valid_vat}" do
|
9
|
-
subject.validate(valid_vat).
|
9
|
+
expect(subject.validate(valid_vat)).to eql(true)
|
10
10
|
end
|
11
11
|
|
12
12
|
invalid_vat = "#{valid_vat[0..-5]}#{valid_vat[-1]}#{valid_vat[-4]}#{valid_vat[-2]}#{valid_vat[-3]}"
|
13
13
|
|
14
14
|
it "returns false on invalid vat #{invalid_vat}" do
|
15
|
-
subject.validate(invalid_vat).
|
15
|
+
expect(subject.validate(invalid_vat)).to eql(false)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -25,7 +25,7 @@ describe Valvat::Checksum::PT do
|
|
25
25
|
# http://www.nif.pt/nif-das-empresas/
|
26
26
|
%w(PT148166644 PT111623448 PT204874866 PT292261314 PT579104222 PT628910002 PT812627318 PT943935784).each do |number|
|
27
27
|
it "returns true on a valid number - #{number}" do
|
28
|
-
subject.validate(number).
|
28
|
+
expect(subject.validate(number)).to eql(true)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -3,17 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::SE do
|
4
4
|
%w(SE136695975501 SE556464687401 SE502052817901 SE556555952201 SE556084097601).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-3]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
it "returns false on special case invalid vat SE556464687400" do
|
17
|
-
Valvat::Checksum.validate("SE556464687400").
|
17
|
+
expect(Valvat::Checksum.validate("SE556464687400")).to eql(false)
|
18
18
|
end
|
19
19
|
end
|
@@ -3,21 +3,21 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Checksum::SI do
|
4
4
|
%w(SI59082437 SI51049406 SI86154575 SI47431857 SI22511822 SI22511880).each do |valid_vat|
|
5
5
|
it "returns true on valid vat #{valid_vat}" do
|
6
|
-
Valvat::Checksum.validate(valid_vat).
|
6
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
invalid_vat = "#{valid_vat[0..-5]}#{valid_vat[-1]}#{valid_vat[-4]}#{valid_vat[-3]}#{valid_vat[-2]}"
|
10
10
|
|
11
11
|
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
-
Valvat::Checksum.validate(invalid_vat).
|
12
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
it "returns false on special case invalid vat SI11111107" do
|
17
|
-
Valvat::Checksum.validate("SI11111107").
|
17
|
+
expect(Valvat::Checksum.validate("SI11111107")).to eql(false)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "returns false on special case invalid vat SI01111108" do
|
21
|
-
Valvat::Checksum.validate("SI01111108").
|
21
|
+
expect(Valvat::Checksum.validate("SI01111108")).to eql(false)
|
22
22
|
end
|
23
23
|
end
|
@@ -9,16 +9,16 @@ end
|
|
9
9
|
describe Valvat::Checksum do
|
10
10
|
describe "#validate" do
|
11
11
|
it "returns true on vat number with unknown checksum algorithm" do
|
12
|
-
Valvat::Checksum.validate("FR99123543267").
|
12
|
+
expect(Valvat::Checksum.validate("FR99123543267")).to eql(true)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "returns false on corrupt number (e.g checks syntax)" do
|
16
|
-
Valvat::Checksum.validate("FI1234567891").
|
16
|
+
expect(Valvat::Checksum.validate("FI1234567891")).to eql(false)
|
17
17
|
end
|
18
18
|
|
19
19
|
VALID_VAT_NUMBERS.each do |valid_vat|
|
20
20
|
it "returns true on valid vat number #{valid_vat}" do
|
21
|
-
Valvat::Checksum.validate(valid_vat).
|
21
|
+
expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/spec/valvat/lookup_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Valvat::Lookup do
|
|
8
8
|
result = Valvat::Lookup.validate("LU21416127")
|
9
9
|
|
10
10
|
unless result.nil?
|
11
|
-
result.
|
11
|
+
expect(result).to eql(true)
|
12
12
|
else
|
13
13
|
puts "Skipping LU vies lookup spec"
|
14
14
|
end
|
@@ -18,7 +18,7 @@ describe Valvat::Lookup do
|
|
18
18
|
result = Valvat::Lookup.validate(Valvat.new("LU21416127"))
|
19
19
|
|
20
20
|
unless result.nil?
|
21
|
-
result.
|
21
|
+
expect(result).to eql(true)
|
22
22
|
else
|
23
23
|
puts "Skipping LU vies lookup spec"
|
24
24
|
end
|
@@ -30,7 +30,7 @@ describe Valvat::Lookup do
|
|
30
30
|
result = Valvat::Lookup.validate("LU21416128")
|
31
31
|
|
32
32
|
unless result.nil?
|
33
|
-
result.
|
33
|
+
expect(result).to eql(false)
|
34
34
|
else
|
35
35
|
puts "Skipping LU vies lookup spec"
|
36
36
|
end
|
@@ -41,8 +41,8 @@ describe Valvat::Lookup do
|
|
41
41
|
without_any_web_requests!
|
42
42
|
|
43
43
|
it "returns false" do
|
44
|
-
Valvat::Lookup.validate("AE259597697").
|
45
|
-
Valvat::Lookup.validate("").
|
44
|
+
expect(Valvat::Lookup.validate("AE259597697")).to eql(false)
|
45
|
+
expect(Valvat::Lookup.validate("")).to eql(false)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -51,8 +51,8 @@ describe Valvat::Lookup do
|
|
51
51
|
result = Valvat::Lookup.validate("IE6388047V", :detail => true)
|
52
52
|
|
53
53
|
if result
|
54
|
-
result.delete(:request_date).
|
55
|
-
result.
|
54
|
+
expect(result.delete(:request_date)).to be_kind_of(Date)
|
55
|
+
expect(result).to eql({
|
56
56
|
:country_code=>"IE",
|
57
57
|
:vat_number=>"6388047V",
|
58
58
|
:name=>"GOOGLE IRELAND LIMITED",
|
@@ -65,8 +65,8 @@ describe Valvat::Lookup do
|
|
65
65
|
result = Valvat::Lookup.validate("LU21416127", :detail => true)
|
66
66
|
|
67
67
|
if result
|
68
|
-
result.delete(:request_date).
|
69
|
-
result.
|
68
|
+
expect(result.delete(:request_date)).to be_kind_of(Date)
|
69
|
+
expect(result).to eql({
|
70
70
|
:country_code=>"LU",
|
71
71
|
:vat_number=>"21416127",
|
72
72
|
:name=>"EBAY EUROPE S.A R.L.",
|
@@ -81,7 +81,7 @@ describe Valvat::Lookup do
|
|
81
81
|
result = Valvat::Lookup.validate("LU21416128", :detail => true)
|
82
82
|
|
83
83
|
unless result.nil?
|
84
|
-
result.
|
84
|
+
expect(result).to eql(false)
|
85
85
|
else
|
86
86
|
puts "Skipping LU vies lookup spec"
|
87
87
|
end
|
@@ -93,10 +93,10 @@ describe Valvat::Lookup do
|
|
93
93
|
response = Valvat::Lookup.validate("LU21416127", :requester_vat => "IE6388047V")
|
94
94
|
|
95
95
|
if response
|
96
|
-
response[:request_identifier].size.
|
96
|
+
expect(response[:request_identifier].size).to eql(16)
|
97
97
|
request_identifier = response[:request_identifier]
|
98
|
-
response.delete(:request_date).
|
99
|
-
response.
|
98
|
+
expect(response.delete(:request_date)).to be_kind_of(Date)
|
99
|
+
expect(response).to eql({
|
100
100
|
:country_code=>"LU",
|
101
101
|
:vat_number=>"21416127",
|
102
102
|
:name => "EBAY EUROPE S.A R.L.",
|
@@ -113,16 +113,16 @@ describe Valvat::Lookup do
|
|
113
113
|
context "error on request" do
|
114
114
|
before do
|
115
115
|
@request = double("request")
|
116
|
-
Valvat::Lookup::Request.
|
117
|
-
@request.
|
116
|
+
allow(Valvat::Lookup::Request).to receive_messages(:new => @request)
|
117
|
+
allow(@request).to receive(:perform).and_raise(ArgumentError.new)
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should return nil" do
|
121
|
-
Valvat::Lookup.validate("LU21416127").
|
121
|
+
expect(Valvat::Lookup.validate("LU21416127")).to eql(nil)
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should raise error with raise_error option" do
|
125
|
-
|
125
|
+
expect {Valvat::Lookup.validate("LU21416127", :raise_error => true)}.to raise_error(ArgumentError)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
data/spec/valvat/syntax_spec.rb
CHANGED
@@ -3,285 +3,285 @@ require 'spec_helper'
|
|
3
3
|
describe Valvat::Syntax do
|
4
4
|
describe "#validate" do
|
5
5
|
it "validates a DE vat number" do
|
6
|
-
subject.validate("DE345889003").
|
6
|
+
expect(subject.validate("DE345889003")).to eql(true)
|
7
7
|
|
8
|
-
subject.validate("DE34588900").
|
9
|
-
subject.validate("DE3458890090").
|
10
|
-
subject.validate("DE34588900C").
|
8
|
+
expect(subject.validate("DE34588900")).to eql(false)
|
9
|
+
expect(subject.validate("DE3458890090")).to eql(false)
|
10
|
+
expect(subject.validate("DE34588900C")).to eql(false)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "validates a AT vat number" do
|
14
|
-
subject.validate("ATU03458890").
|
14
|
+
expect(subject.validate("ATU03458890")).to eql(true)
|
15
15
|
|
16
|
-
subject.validate("ATU034588908").
|
17
|
-
subject.validate("ATU0345908").
|
18
|
-
subject.validate("ATU0345889Y").
|
16
|
+
expect(subject.validate("ATU034588908")).to eql(false)
|
17
|
+
expect(subject.validate("ATU0345908")).to eql(false)
|
18
|
+
expect(subject.validate("ATU0345889Y")).to eql(false)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should validate BE vat number" do
|
22
|
-
subject.validate("BE0817331995").
|
22
|
+
expect(subject.validate("BE0817331995")).to eql(true)
|
23
23
|
|
24
|
-
subject.validate("BE081733199").
|
25
|
-
subject.validate("BE08173319944").
|
26
|
-
subject.validate("BE081733199H").
|
27
|
-
subject.validate("BE1817331999").
|
24
|
+
expect(subject.validate("BE081733199")).to eql(false)
|
25
|
+
expect(subject.validate("BE08173319944")).to eql(false)
|
26
|
+
expect(subject.validate("BE081733199H")).to eql(false)
|
27
|
+
expect(subject.validate("BE1817331999")).to eql(false)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "validates a BG vat number" do
|
31
|
-
subject.validate("BG468134789").
|
32
|
-
subject.validate("BG4681347897").
|
31
|
+
expect(subject.validate("BG468134789")).to eql(true)
|
32
|
+
expect(subject.validate("BG4681347897")).to eql(true)
|
33
33
|
|
34
|
-
subject.validate("BG46813478979").
|
35
|
-
subject.validate("BG4681347897C").
|
36
|
-
subject.validate("BG46813478G").
|
37
|
-
subject.validate("BG46813478").
|
34
|
+
expect(subject.validate("BG46813478979")).to eql(false)
|
35
|
+
expect(subject.validate("BG4681347897C")).to eql(false)
|
36
|
+
expect(subject.validate("BG46813478G")).to eql(false)
|
37
|
+
expect(subject.validate("BG46813478")).to eql(false)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "validates a CY vat number" do
|
41
|
-
subject.validate("CY36579347A").
|
42
|
-
subject.validate("CY36579347C").
|
41
|
+
expect(subject.validate("CY36579347A")).to eql(true)
|
42
|
+
expect(subject.validate("CY36579347C")).to eql(true)
|
43
43
|
|
44
|
-
subject.validate("CY36579347").
|
45
|
-
subject.validate("CY365793478").
|
46
|
-
subject.validate("CY365793478A").
|
47
|
-
subject.validate("CY365793G").
|
44
|
+
expect(subject.validate("CY36579347")).to eql(false)
|
45
|
+
expect(subject.validate("CY365793478")).to eql(false)
|
46
|
+
expect(subject.validate("CY365793478A")).to eql(false)
|
47
|
+
expect(subject.validate("CY365793G")).to eql(false)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "validates a DK vat number" do
|
51
|
-
subject.validate("DK67893463").
|
51
|
+
expect(subject.validate("DK67893463")).to eql(true)
|
52
52
|
|
53
|
-
subject.validate("DK678934637").
|
54
|
-
subject.validate("DK6789346").
|
55
|
-
subject.validate("DK6789346H").
|
53
|
+
expect(subject.validate("DK678934637")).to eql(false)
|
54
|
+
expect(subject.validate("DK6789346")).to eql(false)
|
55
|
+
expect(subject.validate("DK6789346H")).to eql(false)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "validates a ES vat number" do
|
59
|
-
subject.validate("ESX67345987").
|
60
|
-
subject.validate("ESA6734598B").
|
61
|
-
subject.validate("ES56734598C").
|
59
|
+
expect(subject.validate("ESX67345987")).to eql(true)
|
60
|
+
expect(subject.validate("ESA6734598B")).to eql(true)
|
61
|
+
expect(subject.validate("ES56734598C")).to eql(true)
|
62
62
|
|
63
|
-
subject.validate("ES167345987").
|
64
|
-
subject.validate("ESX6734598").
|
65
|
-
subject.validate("ESX673459890").
|
63
|
+
expect(subject.validate("ES167345987")).to eql(false)
|
64
|
+
expect(subject.validate("ESX6734598")).to eql(false)
|
65
|
+
expect(subject.validate("ESX673459890")).to eql(false)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "validates a EE vat number" do
|
69
|
-
subject.validate("EE678678456").
|
70
|
-
subject.validate("EE6786784560").
|
71
|
-
subject.validate("EE67867845").
|
72
|
-
subject.validate("EE67867845K").
|
69
|
+
expect(subject.validate("EE678678456")).to eql(true)
|
70
|
+
expect(subject.validate("EE6786784560")).to eql(false)
|
71
|
+
expect(subject.validate("EE67867845")).to eql(false)
|
72
|
+
expect(subject.validate("EE67867845K")).to eql(false)
|
73
73
|
end
|
74
74
|
|
75
75
|
it "validates a FI vat number" do
|
76
|
-
subject.validate("FI67845638").
|
76
|
+
expect(subject.validate("FI67845638")).to eql(true)
|
77
77
|
|
78
|
-
subject.validate("FI678456389").
|
79
|
-
subject.validate("FI6784563").
|
80
|
-
subject.validate("FI6784563K").
|
78
|
+
expect(subject.validate("FI678456389")).to eql(false)
|
79
|
+
expect(subject.validate("FI6784563")).to eql(false)
|
80
|
+
expect(subject.validate("FI6784563K")).to eql(false)
|
81
81
|
end
|
82
82
|
|
83
83
|
it "validates a FR vat number" do
|
84
|
-
subject.validate("FR99123543267").
|
85
|
-
subject.validate("FRBB123543267").
|
86
|
-
subject.validate("FR9B123543267").
|
87
|
-
subject.validate("FRB9123543267").
|
88
|
-
|
89
|
-
subject.validate("FR99123543267B").
|
90
|
-
subject.validate("FRBB12354326").
|
91
|
-
subject.validate("FR9B123543F67").
|
92
|
-
subject.validate("FRB9123543").
|
84
|
+
expect(subject.validate("FR99123543267")).to eql(true)
|
85
|
+
expect(subject.validate("FRBB123543267")).to eql(true)
|
86
|
+
expect(subject.validate("FR9B123543267")).to eql(true)
|
87
|
+
expect(subject.validate("FRB9123543267")).to eql(true)
|
88
|
+
|
89
|
+
expect(subject.validate("FR99123543267B")).to eql(false)
|
90
|
+
expect(subject.validate("FRBB12354326")).to eql(false)
|
91
|
+
expect(subject.validate("FR9B123543F67")).to eql(false)
|
92
|
+
expect(subject.validate("FRB9123543")).to eql(false)
|
93
93
|
end
|
94
94
|
|
95
95
|
it "validates a EL vat number" do
|
96
|
-
subject.validate("EL678456345").
|
96
|
+
expect(subject.validate("EL678456345")).to eql(true)
|
97
97
|
|
98
|
-
subject.validate("EL67845634").
|
99
|
-
subject.validate("EL6784563459").
|
100
|
-
subject.validate("EL67845634P").
|
98
|
+
expect(subject.validate("EL67845634")).to eql(false)
|
99
|
+
expect(subject.validate("EL6784563459")).to eql(false)
|
100
|
+
expect(subject.validate("EL67845634P")).to eql(false)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "validates a HU vat number" do
|
104
|
-
subject.validate("HU67894595").
|
104
|
+
expect(subject.validate("HU67894595")).to eql(true)
|
105
105
|
|
106
|
-
subject.validate("HU6789459").
|
107
|
-
subject.validate("HU67894595L").
|
108
|
-
subject.validate("HU6789459J").
|
106
|
+
expect(subject.validate("HU6789459")).to eql(false)
|
107
|
+
expect(subject.validate("HU67894595L")).to eql(false)
|
108
|
+
expect(subject.validate("HU6789459J")).to eql(false)
|
109
109
|
end
|
110
110
|
|
111
111
|
it "validates a HR vat number" do
|
112
|
-
subject.validate("HR12345678912").
|
112
|
+
expect(subject.validate("HR12345678912")).to eql(true)
|
113
113
|
|
114
|
-
subject.validate("HR6789459").
|
115
|
-
subject.validate("HR67894595L").
|
116
|
-
subject.validate("HR6789459J").
|
114
|
+
expect(subject.validate("HR6789459")).to eql(false)
|
115
|
+
expect(subject.validate("HR67894595L")).to eql(false)
|
116
|
+
expect(subject.validate("HR6789459J")).to eql(false)
|
117
117
|
end
|
118
118
|
|
119
119
|
it "validates a IE vat number" do
|
120
|
-
subject.validate("IE1B12345J").
|
121
|
-
subject.validate("IE1234567B").
|
122
|
-
subject.validate("IE1234567XX").
|
123
|
-
|
124
|
-
subject.validate("IE1B123459").
|
125
|
-
subject.validate("IE19123450").
|
126
|
-
subject.validate("IEA9123450").
|
127
|
-
subject.validate("IE1B12345XX").
|
128
|
-
subject.validate("IE1X34567XX").
|
120
|
+
expect(subject.validate("IE1B12345J")).to eql(true)
|
121
|
+
expect(subject.validate("IE1234567B")).to eql(true)
|
122
|
+
expect(subject.validate("IE1234567XX")).to eql(true)
|
123
|
+
|
124
|
+
expect(subject.validate("IE1B123459")).to eql(false)
|
125
|
+
expect(subject.validate("IE19123450")).to eql(false)
|
126
|
+
expect(subject.validate("IEA9123450")).to eql(false)
|
127
|
+
expect(subject.validate("IE1B12345XX")).to eql(false)
|
128
|
+
expect(subject.validate("IE1X34567XX")).to eql(false)
|
129
129
|
end
|
130
130
|
|
131
131
|
it "validates a IT vat number" do
|
132
|
-
subject.validate("IT45875359285").
|
132
|
+
expect(subject.validate("IT45875359285")).to eql(true)
|
133
133
|
|
134
|
-
subject.validate("IT458753592859").
|
135
|
-
subject.validate("IT4587535928G").
|
136
|
-
subject.validate("IT4587535928").
|
134
|
+
expect(subject.validate("IT458753592859")).to eql(false)
|
135
|
+
expect(subject.validate("IT4587535928G")).to eql(false)
|
136
|
+
expect(subject.validate("IT4587535928")).to eql(false)
|
137
137
|
end
|
138
138
|
|
139
139
|
it "validates a LV vat number" do
|
140
|
-
subject.validate("LV85678368906").
|
140
|
+
expect(subject.validate("LV85678368906")).to eql(true)
|
141
141
|
|
142
|
-
subject.validate("LV8567836890").
|
143
|
-
subject.validate("LV856783689066").
|
144
|
-
subject.validate("LV8567836890S").
|
142
|
+
expect(subject.validate("LV8567836890")).to eql(false)
|
143
|
+
expect(subject.validate("LV856783689066")).to eql(false)
|
144
|
+
expect(subject.validate("LV8567836890S")).to eql(false)
|
145
145
|
end
|
146
146
|
|
147
147
|
it "validates a LT vat number" do
|
148
|
-
subject.validate("LT678678987").
|
149
|
-
subject.validate("LT678678987956").
|
150
|
-
|
151
|
-
subject.validate("LT67867898").
|
152
|
-
subject.validate("LT6786789870").
|
153
|
-
subject.validate("LT678678987K").
|
154
|
-
subject.validate("LT67867898709").
|
155
|
-
subject.validate("LT6786789870C").
|
156
|
-
subject.validate("LT67867898795H").
|
148
|
+
expect(subject.validate("LT678678987")).to eql(true)
|
149
|
+
expect(subject.validate("LT678678987956")).to eql(true)
|
150
|
+
|
151
|
+
expect(subject.validate("LT67867898")).to eql(false)
|
152
|
+
expect(subject.validate("LT6786789870")).to eql(false)
|
153
|
+
expect(subject.validate("LT678678987K")).to eql(false)
|
154
|
+
expect(subject.validate("LT67867898709")).to eql(false)
|
155
|
+
expect(subject.validate("LT6786789870C")).to eql(false)
|
156
|
+
expect(subject.validate("LT67867898795H")).to eql(false)
|
157
157
|
end
|
158
158
|
|
159
159
|
it "validates a LU vat number" do
|
160
|
-
subject.validate("LU45679456").
|
160
|
+
expect(subject.validate("LU45679456")).to eql(true)
|
161
161
|
|
162
|
-
subject.validate("LU4567945").
|
163
|
-
subject.validate("LU456794560").
|
164
|
-
subject.validate("LU4567945J").
|
162
|
+
expect(subject.validate("LU4567945")).to eql(false)
|
163
|
+
expect(subject.validate("LU456794560")).to eql(false)
|
164
|
+
expect(subject.validate("LU4567945J")).to eql(false)
|
165
165
|
end
|
166
166
|
|
167
167
|
it "validates a MT vat number" do
|
168
|
-
subject.validate("MT64569367").
|
168
|
+
expect(subject.validate("MT64569367")).to eql(true)
|
169
169
|
|
170
|
-
subject.validate("MT6456936").
|
171
|
-
subject.validate("MT645693679").
|
172
|
-
subject.validate("MT6456936L").
|
170
|
+
expect(subject.validate("MT6456936")).to eql(false)
|
171
|
+
expect(subject.validate("MT645693679")).to eql(false)
|
172
|
+
expect(subject.validate("MT6456936L")).to eql(false)
|
173
173
|
end
|
174
174
|
|
175
175
|
it "validates a NL vat number" do
|
176
|
-
subject.validate("NL673739491B77").
|
176
|
+
expect(subject.validate("NL673739491B77")).to eql(true)
|
177
177
|
|
178
|
-
subject.validate("NL673739491977").
|
179
|
-
subject.validate("NL673739491A77").
|
180
|
-
subject.validate("NL673739491B771").
|
181
|
-
subject.validate("NL673739491B7").
|
182
|
-
subject.validate("NL6737394917B7").
|
178
|
+
expect(subject.validate("NL673739491977")).to eql(false)
|
179
|
+
expect(subject.validate("NL673739491A77")).to eql(false)
|
180
|
+
expect(subject.validate("NL673739491B771")).to eql(false)
|
181
|
+
expect(subject.validate("NL673739491B7")).to eql(false)
|
182
|
+
expect(subject.validate("NL6737394917B7")).to eql(false)
|
183
183
|
end
|
184
184
|
|
185
185
|
it "validates a PL vat number" do
|
186
|
-
subject.validate("PL6784567284").
|
186
|
+
expect(subject.validate("PL6784567284")).to eql(true)
|
187
187
|
|
188
|
-
subject.validate("PL678456728").
|
189
|
-
subject.validate("PL67845672849").
|
190
|
-
subject.validate("PL678456728K").
|
188
|
+
expect(subject.validate("PL678456728")).to eql(false)
|
189
|
+
expect(subject.validate("PL67845672849")).to eql(false)
|
190
|
+
expect(subject.validate("PL678456728K")).to eql(false)
|
191
191
|
end
|
192
192
|
|
193
193
|
it "validates a PT vat number" do
|
194
|
-
subject.validate("PT346296476").
|
194
|
+
expect(subject.validate("PT346296476")).to eql(true)
|
195
195
|
|
196
|
-
subject.validate("PT34629647").
|
197
|
-
subject.validate("PT3462964769").
|
196
|
+
expect(subject.validate("PT34629647")).to eql(false)
|
197
|
+
expect(subject.validate("PT3462964769")).to eql(false)
|
198
198
|
end
|
199
199
|
|
200
200
|
it "validates a GB vat number" do
|
201
|
-
subject.validate("GB123456789").
|
202
|
-
subject.validate("GB123456789012").
|
203
|
-
subject.validate("GBGD123").
|
204
|
-
subject.validate("GBHA123").
|
205
|
-
|
206
|
-
subject.validate("GB12345678").
|
207
|
-
subject.validate("GB1234567890").
|
208
|
-
subject.validate("GB12345678901").
|
209
|
-
subject.validate("GB1234567890123").
|
210
|
-
subject.validate("GBAB123").
|
211
|
-
subject.validate("GBAA123").
|
212
|
-
subject.validate("GBHH123").
|
213
|
-
subject.validate("GBGD1234").
|
214
|
-
subject.validate("GBGD12").
|
201
|
+
expect(subject.validate("GB123456789")).to eql(true)
|
202
|
+
expect(subject.validate("GB123456789012")).to eql(true)
|
203
|
+
expect(subject.validate("GBGD123")).to eql(true)
|
204
|
+
expect(subject.validate("GBHA123")).to eql(true)
|
205
|
+
|
206
|
+
expect(subject.validate("GB12345678")).to eql(false)
|
207
|
+
expect(subject.validate("GB1234567890")).to eql(false)
|
208
|
+
expect(subject.validate("GB12345678901")).to eql(false)
|
209
|
+
expect(subject.validate("GB1234567890123")).to eql(false)
|
210
|
+
expect(subject.validate("GBAB123")).to eql(false)
|
211
|
+
expect(subject.validate("GBAA123")).to eql(false)
|
212
|
+
expect(subject.validate("GBHH123")).to eql(false)
|
213
|
+
expect(subject.validate("GBGD1234")).to eql(false)
|
214
|
+
expect(subject.validate("GBGD12")).to eql(false)
|
215
215
|
end
|
216
216
|
|
217
217
|
it "validates a RO vat number" do
|
218
|
-
subject.validate("RO1234567890").
|
219
|
-
subject.validate("RO123456789").
|
220
|
-
subject.validate("RO12345678").
|
221
|
-
subject.validate("RO1234567").
|
222
|
-
subject.validate("RO123456").
|
223
|
-
subject.validate("RO12345").
|
224
|
-
subject.validate("RO1234").
|
225
|
-
subject.validate("RO123").
|
226
|
-
subject.validate("RO12").
|
227
|
-
|
228
|
-
subject.validate("RO1").
|
229
|
-
subject.validate("RO0234567890").
|
230
|
-
subject.validate("RO023456789").
|
231
|
-
subject.validate("RO02345678").
|
232
|
-
subject.validate("RO0234567").
|
233
|
-
subject.validate("RO023456").
|
234
|
-
subject.validate("RO02345").
|
235
|
-
subject.validate("RO0234").
|
236
|
-
subject.validate("RO023").
|
237
|
-
subject.validate("RO02").
|
238
|
-
subject.validate("RO12345678901").
|
218
|
+
expect(subject.validate("RO1234567890")).to eql(true)
|
219
|
+
expect(subject.validate("RO123456789")).to eql(true)
|
220
|
+
expect(subject.validate("RO12345678")).to eql(true)
|
221
|
+
expect(subject.validate("RO1234567")).to eql(true)
|
222
|
+
expect(subject.validate("RO123456")).to eql(true)
|
223
|
+
expect(subject.validate("RO12345")).to eql(true)
|
224
|
+
expect(subject.validate("RO1234")).to eql(true)
|
225
|
+
expect(subject.validate("RO123")).to eql(true)
|
226
|
+
expect(subject.validate("RO12")).to eql(true)
|
227
|
+
|
228
|
+
expect(subject.validate("RO1")).to eql(false)
|
229
|
+
expect(subject.validate("RO0234567890")).to eql(false)
|
230
|
+
expect(subject.validate("RO023456789")).to eql(false)
|
231
|
+
expect(subject.validate("RO02345678")).to eql(false)
|
232
|
+
expect(subject.validate("RO0234567")).to eql(false)
|
233
|
+
expect(subject.validate("RO023456")).to eql(false)
|
234
|
+
expect(subject.validate("RO02345")).to eql(false)
|
235
|
+
expect(subject.validate("RO0234")).to eql(false)
|
236
|
+
expect(subject.validate("RO023")).to eql(false)
|
237
|
+
expect(subject.validate("RO02")).to eql(false)
|
238
|
+
expect(subject.validate("RO12345678901")).to eql(false)
|
239
239
|
end
|
240
240
|
|
241
241
|
it "validates a SK vat number" do
|
242
|
-
subject.validate("SK5683075682").
|
242
|
+
expect(subject.validate("SK5683075682")).to eql(true)
|
243
243
|
|
244
|
-
subject.validate("SK56830756821").
|
245
|
-
subject.validate("SK568307568").
|
244
|
+
expect(subject.validate("SK56830756821")).to eql(false)
|
245
|
+
expect(subject.validate("SK568307568")).to eql(false)
|
246
246
|
end
|
247
247
|
|
248
248
|
it "validates a SI vat number" do
|
249
|
-
subject.validate("SI74357893").
|
249
|
+
expect(subject.validate("SI74357893")).to eql(true)
|
250
250
|
|
251
|
-
subject.validate("SI743578931").
|
252
|
-
subject.validate("SI7435789").
|
251
|
+
expect(subject.validate("SI743578931")).to eql(false)
|
252
|
+
expect(subject.validate("SI7435789")).to eql(false)
|
253
253
|
end
|
254
254
|
|
255
255
|
it "validates a SE vat number" do
|
256
|
-
subject.validate("SE567396352701").
|
256
|
+
expect(subject.validate("SE567396352701")).to eql(true)
|
257
257
|
|
258
|
-
subject.validate("SE56739635201").
|
259
|
-
subject.validate("SE5673963527701").
|
260
|
-
subject.validate("SE567396352702").
|
261
|
-
subject.validate("SE567396352711").
|
258
|
+
expect(subject.validate("SE56739635201")).to eql(false)
|
259
|
+
expect(subject.validate("SE5673963527701")).to eql(false)
|
260
|
+
expect(subject.validate("SE567396352702")).to eql(false)
|
261
|
+
expect(subject.validate("SE567396352711")).to eql(false)
|
262
262
|
end
|
263
263
|
|
264
264
|
it "validates a CZ vat number" do
|
265
|
-
subject.validate("CZ56389267").
|
266
|
-
subject.validate("CZ563892670").
|
267
|
-
subject.validate("CZ5638926790").
|
265
|
+
expect(subject.validate("CZ56389267")).to eql(true)
|
266
|
+
expect(subject.validate("CZ563892670")).to eql(true)
|
267
|
+
expect(subject.validate("CZ5638926790")).to eql(true)
|
268
268
|
|
269
|
-
subject.validate("CZ5638926").
|
270
|
-
subject.validate("CZ56389268901").
|
269
|
+
expect(subject.validate("CZ5638926")).to eql(false)
|
270
|
+
expect(subject.validate("CZ56389268901")).to eql(false)
|
271
271
|
end
|
272
272
|
|
273
273
|
it "returns false on blank/non-sense vat number" do
|
274
|
-
subject.validate("").
|
275
|
-
subject.validate(" ").
|
276
|
-
subject.validate("DE").
|
277
|
-
subject.validate("atu123xyz").
|
278
|
-
subject.validate("xxxxxxxxxx").
|
279
|
-
subject.validate("BEFR").
|
274
|
+
expect(subject.validate("")).to eql(false)
|
275
|
+
expect(subject.validate(" ")).to eql(false)
|
276
|
+
expect(subject.validate("DE")).to eql(false)
|
277
|
+
expect(subject.validate("atu123xyz")).to eql(false)
|
278
|
+
expect(subject.validate("xxxxxxxxxx")).to eql(false)
|
279
|
+
expect(subject.validate("BEFR")).to eql(false)
|
280
280
|
end
|
281
281
|
|
282
282
|
it "allows Valvat instance as input" do
|
283
|
-
subject.validate(Valvat.new("DE345889003")).
|
284
|
-
subject.validate(Valvat.new("DE34588900X")).
|
283
|
+
expect(subject.validate(Valvat.new("DE345889003"))).to eql(true)
|
284
|
+
expect(subject.validate(Valvat.new("DE34588900X"))).to eql(false)
|
285
285
|
end
|
286
286
|
end
|
287
287
|
end
|