valvat 0.8.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +2 -1
  5. data/.travis.yml +30 -16
  6. data/CHANGES.md +45 -2
  7. data/Gemfile +2 -3
  8. data/README.md +96 -46
  9. data/certs/yolk.pem +24 -20
  10. data/gemfiles/activemodel-3-2 +3 -4
  11. data/gemfiles/activemodel-4 +3 -4
  12. data/gemfiles/activemodel-5 +4 -5
  13. data/gemfiles/activemodel-6 +7 -0
  14. data/gemfiles/before-ruby21/activemodel-3-2 +3 -4
  15. data/gemfiles/before-ruby21/activemodel-4 +3 -4
  16. data/gemfiles/before-ruby21/standalone +3 -4
  17. data/gemfiles/standalone +3 -5
  18. data/lib/active_model/validations/valvat_validator.rb +20 -5
  19. data/lib/valvat.rb +3 -1
  20. data/lib/valvat/checksum/gb.rb +30 -13
  21. data/lib/valvat/checksum/ie.rb +1 -1
  22. data/lib/valvat/checksum/nl.rb +5 -0
  23. data/lib/valvat/checksum/si.rb +2 -2
  24. data/lib/valvat/error.rb +28 -0
  25. data/lib/valvat/local.rb +2 -1
  26. data/lib/valvat/locales/en.yml +1 -1
  27. data/lib/valvat/locales/fr.yml +17 -17
  28. data/lib/valvat/locales/pt.yml +28 -28
  29. data/lib/valvat/lookup.rb +11 -43
  30. data/lib/valvat/lookup/fault.rb +30 -0
  31. data/lib/valvat/lookup/request.rb +33 -12
  32. data/lib/valvat/lookup/response.rb +36 -0
  33. data/lib/valvat/utils.rb +11 -3
  34. data/lib/valvat/version.rb +1 -1
  35. data/spec/active_model/validations/valvat_validator_spec.rb +92 -66
  36. data/spec/valvat/checksum/at_spec.rb +2 -2
  37. data/spec/valvat/checksum/be_spec.rb +2 -2
  38. data/spec/valvat/checksum/bg_spec.rb +2 -2
  39. data/spec/valvat/checksum/cy_spec.rb +2 -2
  40. data/spec/valvat/checksum/de_spec.rb +2 -2
  41. data/spec/valvat/checksum/dk_spec.rb +2 -2
  42. data/spec/valvat/checksum/ee_spec.rb +2 -2
  43. data/spec/valvat/checksum/es_spec.rb +2 -2
  44. data/spec/valvat/checksum/fi_spec.rb +2 -2
  45. data/spec/valvat/checksum/fr_spec.rb +2 -2
  46. data/spec/valvat/checksum/gb_spec.rb +5 -3
  47. data/spec/valvat/checksum/gr_spec.rb +2 -2
  48. data/spec/valvat/checksum/hr_spec.rb +2 -2
  49. data/spec/valvat/checksum/hu_spec.rb +2 -2
  50. data/spec/valvat/checksum/ie_spec.rb +8 -2
  51. data/spec/valvat/checksum/it_spec.rb +4 -4
  52. data/spec/valvat/checksum/lt_spec.rb +2 -2
  53. data/spec/valvat/checksum/lu_spec.rb +2 -2
  54. data/spec/valvat/checksum/mt_spec.rb +2 -2
  55. data/spec/valvat/checksum/nl_spec.rb +4 -4
  56. data/spec/valvat/checksum/pl_spec.rb +3 -3
  57. data/spec/valvat/checksum/pt_spec.rb +2 -2
  58. data/spec/valvat/checksum/ro_spec.rb +2 -2
  59. data/spec/valvat/checksum/se_spec.rb +3 -3
  60. data/spec/valvat/checksum/si_spec.rb +7 -7
  61. data/spec/valvat/checksum_spec.rb +2 -2
  62. data/spec/valvat/lockup/fault_spec.rb +32 -0
  63. data/spec/valvat/lockup/request_spec.rb +15 -0
  64. data/spec/valvat/lockup/response_spec.rb +27 -0
  65. data/spec/valvat/lookup_spec.rb +168 -35
  66. data/spec/valvat/syntax_spec.rb +29 -29
  67. data/spec/valvat/utils_spec.rb +28 -8
  68. data/spec/valvat_spec.rb +18 -18
  69. data/valvat.gemspec +1 -0
  70. metadata +52 -25
  71. metadata.gz.sig +0 -0
  72. data/lib/valvat/lookup/request_with_id.rb +0 -31
@@ -8,7 +8,7 @@ end
8
8
 
9
9
  describe Valvat::Checksum do
10
10
  describe "#validate" do
11
- it "returns true on vat number with unknown checksum algorithm" do
11
+ it "returns true on VAT number with unknown checksum algorithm" do
12
12
  expect(Valvat::Checksum.validate("CZ699001237")).to eql(true)
13
13
  end
14
14
 
@@ -17,7 +17,7 @@ describe Valvat::Checksum do
17
17
  end
18
18
 
19
19
  VALID_VAT_NUMBERS.each do |valid_vat|
20
- it "returns true on valid vat number #{valid_vat}" do
20
+ it "returns true on valid VAT number #{valid_vat}" do
21
21
  expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
22
22
  end
23
23
  end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Valvat::Lookup::Fault do
4
+ it "returns {valid: false} on fault 'INVALID_INPUT'" do
5
+ expect(Valvat::Lookup::Fault.new({
6
+ fault: {faultstring: "INVALID_INPUT"}
7
+ }).to_hash).to eql({valid: false})
8
+ end
9
+
10
+ {
11
+ "SERVICE_UNAVAILABLE" => Valvat::ServiceUnavailable,
12
+ "MS_UNAVAILABLE" => Valvat::MemberStateUnavailable,
13
+ "INVALID_REQUESTER_INFO" => Valvat::InvalidRequester,
14
+ "TIMEOUT" => Valvat::Timeout,
15
+ "VAT_BLOCKED" => Valvat::BlockedError,
16
+ "IP_BLOCKED" => Valvat::BlockedError,
17
+ "GLOBAL_MAX_CONCURRENT_REQ" => Valvat::RateLimitError,
18
+ "GLOBAL_MAX_CONCURRENT_REQ_TIME" => Valvat::RateLimitError,
19
+ "MS_MAX_CONCURRENT_REQ" => Valvat::RateLimitError,
20
+ "MS_MAX_CONCURRENT_REQ_TIME" => Valvat::RateLimitError,
21
+ "ANYTHING ELSE" => Valvat::UnknownViesError,
22
+ "REALLY ANYTHING" => Valvat::UnknownViesError
23
+ }.each do |fault, error|
24
+ it "returns error on fault '#{fault}'" do
25
+ expect(Valvat::Lookup::Fault.new({
26
+ fault: {faultstring: fault}
27
+ }).to_hash).to eql({
28
+ error: error.new(fault)
29
+ })
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Valvat::Lookup::Request do
4
+ it "returns Response on success" do
5
+ response = Valvat::Lookup::Request.new("IE6388047V", {}).perform
6
+ expect(response).to be_a(Valvat::Lookup::Response)
7
+ expect(response.to_hash[:name]).to eql("GOOGLE IRELAND LIMITED")
8
+ end
9
+
10
+ it "returns Fault on failure" do
11
+ response = Valvat::Lookup::Request.new("XC123123", {}).perform
12
+ expect(response).to be_a(Valvat::Lookup::Fault)
13
+ expect(response.to_hash).to eql({valid: false})
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Valvat::Lookup::Response do
4
+ it "removes @xmlns from :check_vat_response hash" do
5
+ expect(Valvat::Lookup::Response.new({
6
+ check_vat_response: {:a => 1, :b => 2, :@xmlns => true}
7
+ }).to_hash).to eql({a: 1, b: 2})
8
+ end
9
+
10
+ it "removes 'trader_'-Prefixes :check_vat_response hash" do
11
+ expect(Valvat::Lookup::Response.new({
12
+ check_vat_response: {:a => 1, :trader_b => 2}
13
+ }).to_hash).to eql({a: 1, b: 2})
14
+ end
15
+
16
+ it "accepts hash keyed as :check_vat_approx_response" do
17
+ expect(Valvat::Lookup::Response.new({
18
+ check_vat_approx_response: {:a => 1, :b => 2}
19
+ }).to_hash).to eql({a: 1, b: 2})
20
+ end
21
+
22
+ it "allows direct access to hash via []" do
23
+ expect(Valvat::Lookup::Response.new({
24
+ check_vat_response: {:a => 123, :b => 2}
25
+ })[:a]).to eql(123)
26
+ end
27
+ end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Valvat::Lookup do
4
4
  describe "#validate" do
5
- context "existing vat number" do
5
+ context "existing VAT number" do
6
6
 
7
7
  it "returns true" do
8
8
  result = Valvat::Lookup.validate("IE6388047V")
@@ -25,7 +25,7 @@ describe Valvat::Lookup do
25
25
  end
26
26
  end
27
27
 
28
- context "not existing vat number" do
28
+ context "not existing VAT number" do
29
29
  it "returns false" do
30
30
  result = Valvat::Lookup.validate("IE6388048V")
31
31
 
@@ -46,23 +46,24 @@ describe Valvat::Lookup do
46
46
 
47
47
  context "with details" do
48
48
  it "returns hash of details instead of true" do
49
- result = Valvat::Lookup.validate("IE6388047V", :detail => true)
49
+ result = Valvat::Lookup.validate("IE6388047V", detail: true)
50
50
 
51
51
  if result
52
52
  expect(result.delete(:request_date)).to be_kind_of(Date)
53
53
  expect(result).to eql({
54
- :country_code=>"IE",
55
- :vat_number=>"6388047V",
56
- :name=>"GOOGLE IRELAND LIMITED",
57
- :address=>"3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4"
54
+ country_code: "IE",
55
+ vat_number: "6388047V",
56
+ name: "GOOGLE IRELAND LIMITED",
57
+ address: "3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4",
58
+ valid: true
58
59
  })
59
60
  else
60
61
  puts "Skipping IE vies lookup spec; result = #{result.inspect}"
61
62
  end
62
63
  end
63
64
 
64
- it "still returns false on not existing vat number" do
65
- result = Valvat::Lookup.validate("LU21416128", :detail => true)
65
+ it "still returns false on not existing VAT number" do
66
+ result = Valvat::Lookup.validate("LU21416128", detail: true)
66
67
 
67
68
  unless result.nil?
68
69
  expect(result).to eql(false)
@@ -74,52 +75,184 @@ describe Valvat::Lookup do
74
75
 
75
76
  context "with request identifier" do
76
77
  it "returns hash of details instead of true" do
77
- response = Valvat::Lookup.validate("IE6388047V", :requester_vat => "IE6388047V")
78
+ response = Valvat::Lookup.validate("IE6388047V", requester: "IE6388047V")
78
79
 
79
80
  if response
80
81
  expect(response[:request_identifier].size).to eql(16)
81
82
  request_identifier = response[:request_identifier]
82
83
  expect(response.delete(:request_date)).to be_kind_of(Date)
83
84
  expect(response).to eql({
84
- :country_code=>"IE",
85
- :vat_number=>"6388047V",
86
- :name => "GOOGLE IRELAND LIMITED",
87
- :company_type=>nil,
88
- :address => "3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4",
89
- :request_identifier=> request_identifier
85
+ country_code: "IE",
86
+ vat_number: "6388047V",
87
+ name: "GOOGLE IRELAND LIMITED",
88
+ company_type:nil,
89
+ address: "3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4",
90
+ request_identifier: request_identifier,
91
+ valid: true
90
92
  })
91
93
  else
92
94
  puts "Skipping IE vies lookup spec"
93
95
  end
94
96
  end
97
+
98
+ it "supports old :requester_vat option for backwards stability" do
99
+ expect(
100
+ Valvat::Lookup.new("IE6388047V", requester_vat: "LU21416127").instance_variable_get(:@options)[:requester]
101
+ ).to eql("LU21416127")
102
+
103
+ expect(
104
+ Valvat::Lookup.new("IE6388047V", requester: "LU21416128").instance_variable_get(:@options)[:requester]
105
+ ).to eql("LU21416128")
106
+ end
107
+ end
108
+ end
109
+
110
+ describe "#validate with VIES test enviroment" do
111
+
112
+ let(:options) { {savon: {wsdl: "https://ec.europa.eu/taxation_customs/vies/checkVatTestService.wsdl"}, skip_local_validation: true} }
113
+
114
+ context "Valid request with Valid VAT Number" do
115
+ subject{ Valvat::Lookup.validate("DE100", options) }
116
+
117
+ it "returns true" do
118
+ expect(subject).to eql(true)
119
+ end
120
+ end
121
+
122
+ context "Valid request with an Invalid VAT Number" do
123
+ subject{ Valvat::Lookup.validate("DE200", options) }
124
+
125
+ it "returns false" do
126
+ expect(subject).to eql(false)
127
+ end
128
+ end
129
+
130
+ context "Error : INVALID_INPUT" do
131
+ subject{ Valvat::Lookup.validate("DE201", options) }
132
+
133
+ it "returns false" do
134
+ expect(subject).to eql(false)
135
+ end
136
+ end
137
+
138
+ context "Error : INVALID_REQUESTER_INFO" do
139
+ subject{ Valvat::Lookup.validate("DE202", options) }
140
+
141
+ it "raises Valvat::InvalidRequester" do
142
+ expect{ subject }.to raise_error(Valvat::InvalidRequester)
143
+ end
144
+ end
145
+
146
+ context "Error : SERVICE_UNAVAILABLE" do
147
+ subject{ Valvat::Lookup.validate("DE300", options) }
148
+
149
+ it "returns nil" do
150
+ expect(subject).to eql(nil)
151
+ end
152
+
153
+ it "raises error with raise_error: true" do
154
+ expect{
155
+ Valvat::Lookup.validate("DE300", options.merge(raise_error: true)
156
+ ) }.to raise_error(Valvat::ServiceUnavailable)
157
+ end
158
+ end
159
+
160
+ context "Error : MS_UNAVAILABLE" do
161
+ subject{ Valvat::Lookup.validate("DE301", options) }
162
+
163
+ it "returns nil" do
164
+ expect(subject).to eql(nil)
165
+ end
166
+
167
+ it "raises error with raise_error: true" do
168
+ expect{
169
+ Valvat::Lookup.validate("DE301", options.merge(raise_error: true)
170
+ ) }.to raise_error(Valvat::MemberStateUnavailable)
171
+ end
95
172
  end
96
173
 
97
- context "error on request" do
98
- before do
99
- @request = double("request")
100
- allow(Valvat::Lookup::Request).to receive_messages(:new => @request)
101
- allow(@request).to receive(:perform).and_raise(ArgumentError.new)
174
+ context "Error : TIMEOUT" do
175
+ subject{ Valvat::Lookup.validate("DE302", options) }
176
+
177
+ it "raises error" do
178
+ expect{ subject }.to raise_error(Valvat::Timeout)
179
+ end
180
+
181
+ it "returns nil with raise_error set to false" do
182
+ expect(Valvat::Lookup.validate("DE302", options.merge(raise_error: false))).to eql(nil)
183
+ end
184
+ end
185
+
186
+ context "Error : VAT_BLOCKED" do
187
+ subject{ Valvat::Lookup.validate("DE400", options) }
188
+
189
+ it "raises error" do
190
+ expect{ subject }.to raise_error(Valvat::BlockedError, /VAT_BLOCKED/)
102
191
  end
103
192
 
104
- it "should return nil" do
105
- expect(Valvat::Lookup.validate("LU21416127")).to eql(nil)
193
+ it "returns nil with raise_error set to false" do
194
+ expect(Valvat::Lookup.validate("DE400", options.merge(raise_error: false))).to eql(nil)
106
195
  end
196
+ end
197
+
198
+ context "Error : IP_BLOCKED" do
199
+ subject{ Valvat::Lookup.validate("DE401", options) }
107
200
 
108
- it "should raise error with raise_error option" do
109
- expect {Valvat::Lookup.validate("LU21416127", :raise_error => true)}.to raise_error(ArgumentError)
201
+ it "raises error" do
202
+ expect{ subject }.to raise_error(Valvat::BlockedError, /IP_BLOCKED/)
203
+ end
204
+
205
+ it "returns nil with raise_error set to false" do
206
+ expect(Valvat::Lookup.validate("DE401", options.merge(raise_error: false))).to eql(nil)
110
207
  end
111
208
  end
112
209
 
113
- # TODO : Reactivate with coorect "down" response
114
- # context "country web service down" do
115
- # before do
116
- # json = "{\"error_message\": \"Member State service unavailable.\", \"error_code\": 1, \"error\": true}"
117
- # FakeWeb.register_uri(:get, "http://isvat.appspot.com/DE/259597697/", :body => json)
118
- # end
210
+ context "Error : GLOBAL_MAX_CONCURRENT_REQ" do
211
+ subject{ Valvat::Lookup.validate("DE500", options) }
212
+
213
+ it "raises error" do
214
+ expect{ subject }.to raise_error(Valvat::RateLimitError, /GLOBAL_MAX_CONCURRENT_REQ/)
215
+ end
216
+
217
+ it "returns nil with raise_error set to false" do
218
+ expect(Valvat::Lookup.validate("DE500", options.merge(raise_error: false))).to eql(nil)
219
+ end
220
+ end
119
221
 
120
- # it "returns nil" do
121
- # Valvat::Lookup.validate("DE259597697").should eql(nil)
122
- # end
123
- # end
222
+ context "Error : GLOBAL_MAX_CONCURRENT_REQ_TIME" do
223
+ subject{ Valvat::Lookup.validate("DE501", options) }
224
+
225
+ it "raises error" do
226
+ expect{ subject }.to raise_error(Valvat::RateLimitError, /GLOBAL_MAX_CONCURRENT_REQ_TIME/)
227
+ end
228
+
229
+ it "returns nil with raise_error set to false" do
230
+ expect(Valvat::Lookup.validate("DE501", options.merge(raise_error: false))).to eql(nil)
231
+ end
232
+ end
233
+
234
+ context "Error : MS_MAX_CONCURRENT_REQ" do
235
+ subject{ Valvat::Lookup.validate("DE600", options) }
236
+
237
+ it "raises error" do
238
+ expect{ subject }.to raise_error(Valvat::RateLimitError, /MS_MAX_CONCURRENT_REQ/)
239
+ end
240
+
241
+ it "returns nil with raise_error set to false" do
242
+ expect(Valvat::Lookup.validate("DE600", options.merge(raise_error: false))).to eql(nil)
243
+ end
244
+ end
245
+
246
+ context "Error : MS_MAX_CONCURRENT_REQ_TIME" do
247
+ subject{ Valvat::Lookup.validate("DE601", options) }
248
+
249
+ it "raises error" do
250
+ expect{ subject }.to raise_error(Valvat::RateLimitError, /MS_MAX_CONCURRENT_REQ_TIME/)
251
+ end
252
+
253
+ it "returns nil with raise_error set to false" do
254
+ expect(Valvat::Lookup.validate("DE601", options.merge(raise_error: false))).to eql(nil)
255
+ end
256
+ end
124
257
  end
125
258
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Valvat::Syntax do
4
4
  describe "#validate" do
5
- it "validates a DE vat number" do
5
+ it "validates a DE VAT number" do
6
6
  expect(subject.validate("DE345889003")).to eql(true)
7
7
 
8
8
  expect(subject.validate("DE34588900")).to eql(false)
@@ -10,7 +10,7 @@ describe Valvat::Syntax do
10
10
  expect(subject.validate("DE34588900C")).to eql(false)
11
11
  end
12
12
 
13
- it "validates a AT vat number" do
13
+ it "validates a AT VAT number" do
14
14
  expect(subject.validate("ATU03458890")).to eql(true)
15
15
 
16
16
  expect(subject.validate("ATU034588908")).to eql(false)
@@ -18,7 +18,7 @@ describe Valvat::Syntax do
18
18
  expect(subject.validate("ATU0345889Y")).to eql(false)
19
19
  end
20
20
 
21
- it "should validate BE vat number" do
21
+ it "should validate BE VAT number" do
22
22
  expect(subject.validate("BE0817331995")).to eql(true)
23
23
 
24
24
  expect(subject.validate("BE081733199")).to eql(false)
@@ -27,7 +27,7 @@ describe Valvat::Syntax do
27
27
  expect(subject.validate("BE1817331999")).to eql(false)
28
28
  end
29
29
 
30
- it "validates a BG vat number" do
30
+ it "validates a BG VAT number" do
31
31
  expect(subject.validate("BG468134789")).to eql(true)
32
32
  expect(subject.validate("BG4681347897")).to eql(true)
33
33
 
@@ -37,7 +37,7 @@ describe Valvat::Syntax do
37
37
  expect(subject.validate("BG46813478")).to eql(false)
38
38
  end
39
39
 
40
- it "validates a CY vat number" do
40
+ it "validates a CY VAT number" do
41
41
  expect(subject.validate("CY36579347A")).to eql(true)
42
42
  expect(subject.validate("CY36579347C")).to eql(true)
43
43
 
@@ -47,7 +47,7 @@ describe Valvat::Syntax do
47
47
  expect(subject.validate("CY365793G")).to eql(false)
48
48
  end
49
49
 
50
- it "validates a DK vat number" do
50
+ it "validates a DK VAT number" do
51
51
  expect(subject.validate("DK67893463")).to eql(true)
52
52
 
53
53
  expect(subject.validate("DK678934637")).to eql(false)
@@ -55,7 +55,7 @@ describe Valvat::Syntax do
55
55
  expect(subject.validate("DK6789346H")).to eql(false)
56
56
  end
57
57
 
58
- it "validates a ES vat number" do
58
+ it "validates a ES VAT number" do
59
59
  expect(subject.validate("ESX67345987")).to eql(true)
60
60
  expect(subject.validate("ESA6734598B")).to eql(true)
61
61
  expect(subject.validate("ES56734598C")).to eql(true)
@@ -65,14 +65,14 @@ describe Valvat::Syntax do
65
65
  expect(subject.validate("ESX673459890")).to eql(false)
66
66
  end
67
67
 
68
- it "validates a EE vat number" do
68
+ it "validates a EE VAT number" do
69
69
  expect(subject.validate("EE100207415")).to eql(true)
70
70
  expect(subject.validate("EE1002074150")).to eql(false)
71
71
  expect(subject.validate("EE10020741")).to eql(false)
72
72
  expect(subject.validate("EE100207415K")).to eql(false)
73
73
  end
74
74
 
75
- it "validates a FI vat number" do
75
+ it "validates a FI VAT number" do
76
76
  expect(subject.validate("FI67845638")).to eql(true)
77
77
 
78
78
  expect(subject.validate("FI678456389")).to eql(false)
@@ -80,7 +80,7 @@ describe Valvat::Syntax do
80
80
  expect(subject.validate("FI6784563K")).to eql(false)
81
81
  end
82
82
 
83
- it "validates a FR vat number" do
83
+ it "validates a FR VAT number" do
84
84
  expect(subject.validate("FR99123543267")).to eql(true)
85
85
  expect(subject.validate("FRBB123543267")).to eql(true)
86
86
  expect(subject.validate("FR9B123543267")).to eql(true)
@@ -92,7 +92,7 @@ describe Valvat::Syntax do
92
92
  expect(subject.validate("FRB9123543")).to eql(false)
93
93
  end
94
94
 
95
- it "validates a EL vat number" do
95
+ it "validates a EL VAT number" do
96
96
  expect(subject.validate("EL678456345")).to eql(true)
97
97
 
98
98
  expect(subject.validate("EL67845634")).to eql(false)
@@ -100,7 +100,7 @@ describe Valvat::Syntax do
100
100
  expect(subject.validate("EL67845634P")).to eql(false)
101
101
  end
102
102
 
103
- it "validates a HU vat number" do
103
+ it "validates a HU VAT number" do
104
104
  expect(subject.validate("HU67894595")).to eql(true)
105
105
 
106
106
  expect(subject.validate("HU6789459")).to eql(false)
@@ -108,7 +108,7 @@ describe Valvat::Syntax do
108
108
  expect(subject.validate("HU6789459J")).to eql(false)
109
109
  end
110
110
 
111
- it "validates a HR vat number" do
111
+ it "validates a HR VAT number" do
112
112
  expect(subject.validate("HR12345678912")).to eql(true)
113
113
 
114
114
  expect(subject.validate("HR6789459")).to eql(false)
@@ -116,7 +116,7 @@ describe Valvat::Syntax do
116
116
  expect(subject.validate("HR6789459J")).to eql(false)
117
117
  end
118
118
 
119
- it "validates a IE vat number" do
119
+ it "validates a IE VAT number" do
120
120
  expect(subject.validate("IE1B12345J")).to eql(true)
121
121
  expect(subject.validate("IE1234567B")).to eql(true)
122
122
  expect(subject.validate("IE1234567XX")).to eql(true)
@@ -128,7 +128,7 @@ describe Valvat::Syntax do
128
128
  expect(subject.validate("IE1X34567XX")).to eql(false)
129
129
  end
130
130
 
131
- it "validates a IT vat number" do
131
+ it "validates a IT VAT number" do
132
132
  expect(subject.validate("IT45875359285")).to eql(true)
133
133
 
134
134
  expect(subject.validate("IT458753592859")).to eql(false)
@@ -136,7 +136,7 @@ describe Valvat::Syntax do
136
136
  expect(subject.validate("IT4587535928")).to eql(false)
137
137
  end
138
138
 
139
- it "validates a LV vat number" do
139
+ it "validates a LV VAT number" do
140
140
  expect(subject.validate("LV85678368906")).to eql(true)
141
141
 
142
142
  expect(subject.validate("LV8567836890")).to eql(false)
@@ -144,7 +144,7 @@ describe Valvat::Syntax do
144
144
  expect(subject.validate("LV8567836890S")).to eql(false)
145
145
  end
146
146
 
147
- it "validates a LT vat number" do
147
+ it "validates a LT VAT number" do
148
148
  expect(subject.validate("LT213179412")).to eql(true)
149
149
  expect(subject.validate("LT290061371314")).to eql(true)
150
150
 
@@ -158,7 +158,7 @@ describe Valvat::Syntax do
158
158
  expect(subject.validate("LT290061371314H")).to eql(false)
159
159
  end
160
160
 
161
- it "validates a LU vat number" do
161
+ it "validates a LU VAT number" do
162
162
  expect(subject.validate("LU45679456")).to eql(true)
163
163
 
164
164
  expect(subject.validate("LU4567945")).to eql(false)
@@ -166,7 +166,7 @@ describe Valvat::Syntax do
166
166
  expect(subject.validate("LU4567945J")).to eql(false)
167
167
  end
168
168
 
169
- it "validates a MT vat number" do
169
+ it "validates a MT VAT number" do
170
170
  expect(subject.validate("MT64569367")).to eql(true)
171
171
 
172
172
  expect(subject.validate("MT6456936")).to eql(false)
@@ -174,7 +174,7 @@ describe Valvat::Syntax do
174
174
  expect(subject.validate("MT6456936L")).to eql(false)
175
175
  end
176
176
 
177
- it "validates a NL vat number" do
177
+ it "validates a NL VAT number" do
178
178
  expect(subject.validate("NL673739491B77")).to eql(true)
179
179
 
180
180
  expect(subject.validate("NL673739491977")).to eql(false)
@@ -184,7 +184,7 @@ describe Valvat::Syntax do
184
184
  expect(subject.validate("NL6737394917B7")).to eql(false)
185
185
  end
186
186
 
187
- it "validates a PL vat number" do
187
+ it "validates a PL VAT number" do
188
188
  expect(subject.validate("PL6784567284")).to eql(true)
189
189
 
190
190
  expect(subject.validate("PL678456728")).to eql(false)
@@ -192,14 +192,14 @@ describe Valvat::Syntax do
192
192
  expect(subject.validate("PL678456728K")).to eql(false)
193
193
  end
194
194
 
195
- it "validates a PT vat number" do
195
+ it "validates a PT VAT number" do
196
196
  expect(subject.validate("PT346296476")).to eql(true)
197
197
 
198
198
  expect(subject.validate("PT34629647")).to eql(false)
199
199
  expect(subject.validate("PT3462964769")).to eql(false)
200
200
  end
201
201
 
202
- it "validates a GB vat number" do
202
+ it "validates a GB VAT number" do
203
203
  expect(subject.validate("GB123456789")).to eql(true)
204
204
  expect(subject.validate("GB123456789012")).to eql(true)
205
205
  expect(subject.validate("GBGD123")).to eql(true)
@@ -216,7 +216,7 @@ describe Valvat::Syntax do
216
216
  expect(subject.validate("GBGD12")).to eql(false)
217
217
  end
218
218
 
219
- it "validates a RO vat number" do
219
+ it "validates a RO VAT number" do
220
220
  expect(subject.validate("RO1234567890")).to eql(true)
221
221
  expect(subject.validate("RO123456789")).to eql(true)
222
222
  expect(subject.validate("RO12345678")).to eql(true)
@@ -240,21 +240,21 @@ describe Valvat::Syntax do
240
240
  expect(subject.validate("RO12345678901")).to eql(false)
241
241
  end
242
242
 
243
- it "validates a SK vat number" do
243
+ it "validates a SK VAT number" do
244
244
  expect(subject.validate("SK5683075682")).to eql(true)
245
245
 
246
246
  expect(subject.validate("SK56830756821")).to eql(false)
247
247
  expect(subject.validate("SK568307568")).to eql(false)
248
248
  end
249
249
 
250
- it "validates a SI vat number" do
250
+ it "validates a SI VAT number" do
251
251
  expect(subject.validate("SI74357893")).to eql(true)
252
252
 
253
253
  expect(subject.validate("SI743578931")).to eql(false)
254
254
  expect(subject.validate("SI7435789")).to eql(false)
255
255
  end
256
256
 
257
- it "validates a SE vat number" do
257
+ it "validates a SE VAT number" do
258
258
  expect(subject.validate("SE567396352701")).to eql(true)
259
259
 
260
260
  expect(subject.validate("SE56739635201")).to eql(false)
@@ -263,7 +263,7 @@ describe Valvat::Syntax do
263
263
  expect(subject.validate("SE567396352711")).to eql(false)
264
264
  end
265
265
 
266
- it "validates a CZ vat number" do
266
+ it "validates a CZ VAT number" do
267
267
  expect(subject.validate("CZ56389267")).to eql(true)
268
268
  expect(subject.validate("CZ563892670")).to eql(true)
269
269
  expect(subject.validate("CZ5638926790")).to eql(true)
@@ -272,7 +272,7 @@ describe Valvat::Syntax do
272
272
  expect(subject.validate("CZ56389268901")).to eql(false)
273
273
  end
274
274
 
275
- it "returns false on blank/non-sense vat number" do
275
+ it "returns false on blank/non-sense VAT number" do
276
276
  expect(subject.validate("")).to eql(false)
277
277
  expect(subject.validate(" ")).to eql(false)
278
278
  expect(subject.validate("DE")).to eql(false)