valvat 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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).should eql(true)
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).should eql(false)
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).should eql(true)
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).should eql(false)
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).should eql(true)
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).should eql(false)
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).should eql(true)
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).should eql(false)
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).should eql(true)
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).should eql(false)
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).should eql(true)
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).should eql(false)
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).should eql(true)
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).should eql(false)
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).should eql(true)
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).should eql(false)
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).should eql(true)
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).should eql(false)
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").should eql(false)
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").should eql(false)
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).should eql(true)
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).should eql(false)
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).should eql(true)
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).should eql(false)
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).should eql(true)
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).should eql(false)
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").should eql(false)
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).should be_true
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).should be_false
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).should be_true
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).should eql(true)
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).should eql(false)
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").should eql(false)
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).should eql(true)
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).should eql(false)
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").should eql(false)
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").should eql(false)
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").should eql(true)
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").should eql(false)
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).should eql(true)
21
+ expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
22
22
  end
23
23
  end
24
24
  end
@@ -8,7 +8,7 @@ describe Valvat::Lookup do
8
8
  result = Valvat::Lookup.validate("LU21416127")
9
9
 
10
10
  unless result.nil?
11
- result.should eql(true)
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.should eql(true)
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.should eql(false)
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").should eql(false)
45
- Valvat::Lookup.validate("").should eql(false)
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).should be_kind_of(Date)
55
- result.should eql({
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).should be_kind_of(Date)
69
- result.should eql({
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.should eql(false)
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.should eql(16)
96
+ expect(response[:request_identifier].size).to eql(16)
97
97
  request_identifier = response[:request_identifier]
98
- response.delete(:request_date).should be_kind_of(Date)
99
- response.should eql({
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.stub(:new => @request)
117
- @request.stub(:perform).and_raise(ArgumentError.new)
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").should eql(nil)
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
- lambda {Valvat::Lookup.validate("LU21416127", :raise_error => true)}.should raise_error(ArgumentError)
125
+ expect {Valvat::Lookup.validate("LU21416127", :raise_error => true)}.to raise_error(ArgumentError)
126
126
  end
127
127
  end
128
128
 
@@ -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").should eql(true)
6
+ expect(subject.validate("DE345889003")).to eql(true)
7
7
 
8
- subject.validate("DE34588900").should eql(false)
9
- subject.validate("DE3458890090").should eql(false)
10
- subject.validate("DE34588900C").should eql(false)
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").should eql(true)
14
+ expect(subject.validate("ATU03458890")).to eql(true)
15
15
 
16
- subject.validate("ATU034588908").should eql(false)
17
- subject.validate("ATU0345908").should eql(false)
18
- subject.validate("ATU0345889Y").should eql(false)
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").should eql(true)
22
+ expect(subject.validate("BE0817331995")).to eql(true)
23
23
 
24
- subject.validate("BE081733199").should eql(false)
25
- subject.validate("BE08173319944").should eql(false)
26
- subject.validate("BE081733199H").should eql(false)
27
- subject.validate("BE1817331999").should eql(false)
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").should eql(true)
32
- subject.validate("BG4681347897").should eql(true)
31
+ expect(subject.validate("BG468134789")).to eql(true)
32
+ expect(subject.validate("BG4681347897")).to eql(true)
33
33
 
34
- subject.validate("BG46813478979").should eql(false)
35
- subject.validate("BG4681347897C").should eql(false)
36
- subject.validate("BG46813478G").should eql(false)
37
- subject.validate("BG46813478").should eql(false)
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").should eql(true)
42
- subject.validate("CY36579347C").should eql(true)
41
+ expect(subject.validate("CY36579347A")).to eql(true)
42
+ expect(subject.validate("CY36579347C")).to eql(true)
43
43
 
44
- subject.validate("CY36579347").should eql(false)
45
- subject.validate("CY365793478").should eql(false)
46
- subject.validate("CY365793478A").should eql(false)
47
- subject.validate("CY365793G").should eql(false)
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").should eql(true)
51
+ expect(subject.validate("DK67893463")).to eql(true)
52
52
 
53
- subject.validate("DK678934637").should eql(false)
54
- subject.validate("DK6789346").should eql(false)
55
- subject.validate("DK6789346H").should eql(false)
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").should eql(true)
60
- subject.validate("ESA6734598B").should eql(true)
61
- subject.validate("ES56734598C").should eql(true)
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").should eql(false)
64
- subject.validate("ESX6734598").should eql(false)
65
- subject.validate("ESX673459890").should eql(false)
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").should eql(true)
70
- subject.validate("EE6786784560").should eql(false)
71
- subject.validate("EE67867845").should eql(false)
72
- subject.validate("EE67867845K").should eql(false)
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").should eql(true)
76
+ expect(subject.validate("FI67845638")).to eql(true)
77
77
 
78
- subject.validate("FI678456389").should eql(false)
79
- subject.validate("FI6784563").should eql(false)
80
- subject.validate("FI6784563K").should eql(false)
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").should eql(true)
85
- subject.validate("FRBB123543267").should eql(true)
86
- subject.validate("FR9B123543267").should eql(true)
87
- subject.validate("FRB9123543267").should eql(true)
88
-
89
- subject.validate("FR99123543267B").should eql(false)
90
- subject.validate("FRBB12354326").should eql(false)
91
- subject.validate("FR9B123543F67").should eql(false)
92
- subject.validate("FRB9123543").should eql(false)
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").should eql(true)
96
+ expect(subject.validate("EL678456345")).to eql(true)
97
97
 
98
- subject.validate("EL67845634").should eql(false)
99
- subject.validate("EL6784563459").should eql(false)
100
- subject.validate("EL67845634P").should eql(false)
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").should eql(true)
104
+ expect(subject.validate("HU67894595")).to eql(true)
105
105
 
106
- subject.validate("HU6789459").should eql(false)
107
- subject.validate("HU67894595L").should eql(false)
108
- subject.validate("HU6789459J").should eql(false)
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").should eql(true)
112
+ expect(subject.validate("HR12345678912")).to eql(true)
113
113
 
114
- subject.validate("HR6789459").should eql(false)
115
- subject.validate("HR67894595L").should eql(false)
116
- subject.validate("HR6789459J").should eql(false)
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").should eql(true)
121
- subject.validate("IE1234567B").should eql(true)
122
- subject.validate("IE1234567XX").should eql(true)
123
-
124
- subject.validate("IE1B123459").should eql(false)
125
- subject.validate("IE19123450").should eql(false)
126
- subject.validate("IEA9123450").should eql(false)
127
- subject.validate("IE1B12345XX").should eql(false)
128
- subject.validate("IE1X34567XX").should eql(false)
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").should eql(true)
132
+ expect(subject.validate("IT45875359285")).to eql(true)
133
133
 
134
- subject.validate("IT458753592859").should eql(false)
135
- subject.validate("IT4587535928G").should eql(false)
136
- subject.validate("IT4587535928").should eql(false)
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").should eql(true)
140
+ expect(subject.validate("LV85678368906")).to eql(true)
141
141
 
142
- subject.validate("LV8567836890").should eql(false)
143
- subject.validate("LV856783689066").should eql(false)
144
- subject.validate("LV8567836890S").should eql(false)
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").should eql(true)
149
- subject.validate("LT678678987956").should eql(true)
150
-
151
- subject.validate("LT67867898").should eql(false)
152
- subject.validate("LT6786789870").should eql(false)
153
- subject.validate("LT678678987K").should eql(false)
154
- subject.validate("LT67867898709").should eql(false)
155
- subject.validate("LT6786789870C").should eql(false)
156
- subject.validate("LT67867898795H").should eql(false)
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").should eql(true)
160
+ expect(subject.validate("LU45679456")).to eql(true)
161
161
 
162
- subject.validate("LU4567945").should eql(false)
163
- subject.validate("LU456794560").should eql(false)
164
- subject.validate("LU4567945J").should eql(false)
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").should eql(true)
168
+ expect(subject.validate("MT64569367")).to eql(true)
169
169
 
170
- subject.validate("MT6456936").should eql(false)
171
- subject.validate("MT645693679").should eql(false)
172
- subject.validate("MT6456936L").should eql(false)
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").should eql(true)
176
+ expect(subject.validate("NL673739491B77")).to eql(true)
177
177
 
178
- subject.validate("NL673739491977").should eql(false)
179
- subject.validate("NL673739491A77").should eql(false)
180
- subject.validate("NL673739491B771").should eql(false)
181
- subject.validate("NL673739491B7").should eql(false)
182
- subject.validate("NL6737394917B7").should eql(false)
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").should eql(true)
186
+ expect(subject.validate("PL6784567284")).to eql(true)
187
187
 
188
- subject.validate("PL678456728").should eql(false)
189
- subject.validate("PL67845672849").should eql(false)
190
- subject.validate("PL678456728K").should eql(false)
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").should eql(true)
194
+ expect(subject.validate("PT346296476")).to eql(true)
195
195
 
196
- subject.validate("PT34629647").should eql(false)
197
- subject.validate("PT3462964769").should eql(false)
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").should eql(true)
202
- subject.validate("GB123456789012").should eql(true)
203
- subject.validate("GBGD123").should eql(true)
204
- subject.validate("GBHA123").should eql(true)
205
-
206
- subject.validate("GB12345678").should eql(false)
207
- subject.validate("GB1234567890").should eql(false)
208
- subject.validate("GB12345678901").should eql(false)
209
- subject.validate("GB1234567890123").should eql(false)
210
- subject.validate("GBAB123").should eql(false)
211
- subject.validate("GBAA123").should eql(false)
212
- subject.validate("GBHH123").should eql(false)
213
- subject.validate("GBGD1234").should eql(false)
214
- subject.validate("GBGD12").should eql(false)
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").should eql(true)
219
- subject.validate("RO123456789").should eql(true)
220
- subject.validate("RO12345678").should eql(true)
221
- subject.validate("RO1234567").should eql(true)
222
- subject.validate("RO123456").should eql(true)
223
- subject.validate("RO12345").should eql(true)
224
- subject.validate("RO1234").should eql(true)
225
- subject.validate("RO123").should eql(true)
226
- subject.validate("RO12").should eql(true)
227
-
228
- subject.validate("RO1").should eql(false)
229
- subject.validate("RO0234567890").should eql(false)
230
- subject.validate("RO023456789").should eql(false)
231
- subject.validate("RO02345678").should eql(false)
232
- subject.validate("RO0234567").should eql(false)
233
- subject.validate("RO023456").should eql(false)
234
- subject.validate("RO02345").should eql(false)
235
- subject.validate("RO0234").should eql(false)
236
- subject.validate("RO023").should eql(false)
237
- subject.validate("RO02").should eql(false)
238
- subject.validate("RO12345678901").should eql(false)
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").should eql(true)
242
+ expect(subject.validate("SK5683075682")).to eql(true)
243
243
 
244
- subject.validate("SK56830756821").should eql(false)
245
- subject.validate("SK568307568").should eql(false)
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").should eql(true)
249
+ expect(subject.validate("SI74357893")).to eql(true)
250
250
 
251
- subject.validate("SI743578931").should eql(false)
252
- subject.validate("SI7435789").should eql(false)
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").should eql(true)
256
+ expect(subject.validate("SE567396352701")).to eql(true)
257
257
 
258
- subject.validate("SE56739635201").should eql(false)
259
- subject.validate("SE5673963527701").should eql(false)
260
- subject.validate("SE567396352702").should eql(false)
261
- subject.validate("SE567396352711").should eql(false)
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").should eql(true)
266
- subject.validate("CZ563892670").should eql(true)
267
- subject.validate("CZ5638926790").should eql(true)
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").should eql(false)
270
- subject.validate("CZ56389268901").should eql(false)
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("").should eql(false)
275
- subject.validate(" ").should eql(false)
276
- subject.validate("DE").should eql(false)
277
- subject.validate("atu123xyz").should eql(false)
278
- subject.validate("xxxxxxxxxx").should eql(false)
279
- subject.validate("BEFR").should eql(false)
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")).should eql(true)
284
- subject.validate(Valvat.new("DE34588900X")).should eql(false)
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