valvat 0.9.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.github/workflows/ruby.yml +35 -0
  5. data/.gitignore +3 -1
  6. data/.rubocop.yml +15 -0
  7. data/CHANGES.md +36 -1
  8. data/Gemfile +4 -3
  9. data/Guardfile +6 -4
  10. data/README.md +99 -47
  11. data/Rakefile +3 -1
  12. data/certs/yolk.pem +21 -21
  13. data/gemfiles/activemodel-5 +4 -5
  14. data/gemfiles/activemodel-6 +7 -0
  15. data/gemfiles/standalone +3 -5
  16. data/lib/active_model/validations/valvat_validator.rb +70 -22
  17. data/lib/valvat.rb +7 -3
  18. data/lib/valvat/checksum.rb +24 -28
  19. data/lib/valvat/checksum/at.rb +3 -1
  20. data/lib/valvat/checksum/be.rb +3 -1
  21. data/lib/valvat/checksum/bg.rb +17 -17
  22. data/lib/valvat/checksum/cy.rb +2 -0
  23. data/lib/valvat/checksum/de.rb +5 -3
  24. data/lib/valvat/checksum/dk.rb +3 -1
  25. data/lib/valvat/checksum/ee.rb +2 -0
  26. data/lib/valvat/checksum/es.rb +14 -16
  27. data/lib/valvat/checksum/fi.rb +3 -1
  28. data/lib/valvat/checksum/fr.rb +4 -2
  29. data/lib/valvat/checksum/gb.rb +53 -21
  30. data/lib/valvat/checksum/gr.rb +4 -2
  31. data/lib/valvat/checksum/hr.rb +2 -0
  32. data/lib/valvat/checksum/hu.rb +2 -0
  33. data/lib/valvat/checksum/ie.rb +5 -6
  34. data/lib/valvat/checksum/it.rb +7 -5
  35. data/lib/valvat/checksum/lt.rb +2 -0
  36. data/lib/valvat/checksum/lu.rb +3 -1
  37. data/lib/valvat/checksum/mt.rb +2 -0
  38. data/lib/valvat/checksum/nl.rb +5 -3
  39. data/lib/valvat/checksum/pl.rb +3 -1
  40. data/lib/valvat/checksum/pt.rb +3 -1
  41. data/lib/valvat/checksum/ro.rb +2 -0
  42. data/lib/valvat/checksum/se.rb +5 -3
  43. data/lib/valvat/checksum/si.rb +4 -2
  44. data/lib/valvat/error.rb +31 -0
  45. data/lib/valvat/local.rb +8 -5
  46. data/lib/valvat/locales/de.yml +2 -1
  47. data/lib/valvat/locales/en.yml +2 -1
  48. data/lib/valvat/locales/es.yml +1 -0
  49. data/lib/valvat/locales/fr.yml +1 -0
  50. data/lib/valvat/locales/hu.yml +1 -0
  51. data/lib/valvat/locales/nl.yml +1 -0
  52. data/lib/valvat/locales/pl.yml +1 -0
  53. data/lib/valvat/locales/pt.yml +28 -28
  54. data/lib/valvat/lookup.rb +14 -45
  55. data/lib/valvat/lookup/fault.rb +31 -0
  56. data/lib/valvat/lookup/request.rb +37 -11
  57. data/lib/valvat/lookup/response.rb +37 -0
  58. data/lib/valvat/syntax.rb +31 -30
  59. data/lib/valvat/utils.rb +20 -9
  60. data/lib/valvat/version.rb +3 -1
  61. data/spec/active_model/validations/valvat_validator_spec.rb +132 -100
  62. data/spec/spec_helper.rb +8 -8
  63. data/spec/valvat/checksum/at_spec.rb +8 -6
  64. data/spec/valvat/checksum/be_spec.rb +8 -6
  65. data/spec/valvat/checksum/bg_spec.rb +9 -6
  66. data/spec/valvat/checksum/cy_spec.rb +5 -3
  67. data/spec/valvat/checksum/de_spec.rb +8 -6
  68. data/spec/valvat/checksum/dk_spec.rb +8 -6
  69. data/spec/valvat/checksum/ee_spec.rb +5 -3
  70. data/spec/valvat/checksum/es_spec.rb +9 -6
  71. data/spec/valvat/checksum/fi_spec.rb +8 -6
  72. data/spec/valvat/checksum/fr_spec.rb +8 -6
  73. data/spec/valvat/checksum/gb_spec.rb +9 -5
  74. data/spec/valvat/checksum/gr_spec.rb +8 -6
  75. data/spec/valvat/checksum/hr_spec.rb +5 -3
  76. data/spec/valvat/checksum/hu_spec.rb +5 -3
  77. data/spec/valvat/checksum/ie_spec.rb +13 -5
  78. data/spec/valvat/checksum/it_spec.rb +12 -10
  79. data/spec/valvat/checksum/lt_spec.rb +5 -3
  80. data/spec/valvat/checksum/lu_spec.rb +8 -6
  81. data/spec/valvat/checksum/mt_spec.rb +5 -3
  82. data/spec/valvat/checksum/nl_spec.rb +9 -7
  83. data/spec/valvat/checksum/pl_spec.rb +10 -8
  84. data/spec/valvat/checksum/pt_spec.rb +12 -13
  85. data/spec/valvat/checksum/ro_spec.rb +5 -3
  86. data/spec/valvat/checksum/se_spec.rb +10 -8
  87. data/spec/valvat/checksum/si_spec.rb +12 -10
  88. data/spec/valvat/checksum_spec.rb +25 -10
  89. data/spec/valvat/lookup/fault_spec.rb +34 -0
  90. data/spec/valvat/lookup/request_spec.rb +19 -0
  91. data/spec/valvat/lookup/response_spec.rb +29 -0
  92. data/spec/valvat/lookup_spec.rb +202 -84
  93. data/spec/valvat/syntax_spec.rb +59 -280
  94. data/spec/valvat/utils_spec.rb +76 -43
  95. data/spec/valvat_spec.rb +140 -152
  96. data/valvat.gemspec +18 -17
  97. metadata +61 -41
  98. metadata.gz.sig +0 -0
  99. data/.travis.yml +0 -33
  100. data/gemfiles/activemodel-3-2 +0 -8
  101. data/gemfiles/activemodel-4 +0 -8
  102. data/gemfiles/before-ruby21/activemodel-3-2 +0 -9
  103. data/gemfiles/before-ruby21/activemodel-4 +0 -9
  104. data/gemfiles/before-ruby21/standalone +0 -8
  105. data/lib/valvat/lookup/request_with_id.rb +0 -31
data/spec/spec_helper.rb CHANGED
@@ -1,22 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec'
2
4
  begin
3
5
  require 'active_model'
4
- rescue LoadError => err
5
- puts "Running specs without active_model extension"
6
+ rescue LoadError
7
+ puts 'Running specs without active_model extension'
6
8
  end
7
9
 
8
- require File.dirname(__FILE__) + '/../lib/valvat.rb'
10
+ require "#{File.dirname(__FILE__)}/../lib/valvat.rb"
9
11
 
10
12
  RSpec.configure do |config|
11
13
  config.mock_with :rspec
12
- config.filter_run :focus => true
14
+ config.filter_run focus: true
13
15
  config.run_all_when_everything_filtered = true
14
- config.backtrace_exclusion_patterns = [/rspec\/(core|expectations)/]
16
+ config.backtrace_exclusion_patterns = [%r{rspec/(core|expectations)}]
15
17
  end
16
18
 
17
- if defined?(I18n)
18
- I18n.enforce_available_locales = false
19
- end
19
+ I18n.enforce_available_locales = false if defined?(I18n)
20
20
 
21
21
  if defined?(ActiveModel)
22
22
  class ModelBase
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::AT do
4
- %w(ATU13585627 ATU66059506 ATU42403001).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
- expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
6
+ %w[ATU13585627 ATU66059506 ATU42403001].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
8
+ expect(Valvat::Checksum.validate(valid_vat)).to be(true)
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-3]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
12
- expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
13
+ it "returns false on invalid VAT #{invalid_vat}" do
14
+ expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
13
15
  end
14
16
  end
15
- end
17
+ end
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::BE do
4
- %w(BE0123456749 BE0136695962 BE0817331995).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
- expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
6
+ %w[BE0123456749 BE0136695962 BE0817331995].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
8
+ expect(Valvat::Checksum.validate(valid_vat)).to be(true)
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
12
- expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
13
+ it "returns false on invalid VAT #{invalid_vat}" do
14
+ expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
13
15
  end
14
16
  end
15
- end
17
+ end
@@ -1,15 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::BG do
4
- %w(BG123456786 BG926067143 BG926067770 BG0101011739 BG0121013021 BG5041019992 BG1521687837 BG1431889037).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
- expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
6
+ %w[BG123456786 BG926067143 BG926067770 BG0101011739 BG0121013021 BG5041019992 BG1521687837
7
+ BG1431889037].each do |valid_vat|
8
+ it "returns true on valid VAT #{valid_vat}" do
9
+ expect(Valvat::Checksum.validate(valid_vat)).to be(true)
7
10
  end
8
11
 
9
12
  invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-4]}"
10
13
 
11
- it "returns false on invalid vat #{invalid_vat}" do
12
- expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
14
+ it "returns false on invalid VAT #{invalid_vat}" do
15
+ expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
13
16
  end
14
17
  end
15
- end
18
+ end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::CY do
4
- %w(CY01234567U CY00532445O).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
+ %w[CY01234567U CY00532445O].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
6
8
  expect(Valvat::Checksum.validate(valid_vat)).to be true
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-2]}#{valid_vat[-3]}#{valid_vat[-1]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
13
+ it "returns false on invalid VAT #{invalid_vat}" do
12
14
  expect(Valvat::Checksum.validate(invalid_vat)).to be false
13
15
  end
14
16
  end
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::DE do
4
- %w(DE280857971 DE281381706 DE283108332 DE813622378 DE813628528 DE814178359 DE811907980).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
- expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
6
+ %w[DE280857971 DE281381706 DE283108332 DE813622378 DE813628528 DE814178359 DE811907980].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
8
+ expect(Valvat::Checksum.validate(valid_vat)).to be(true)
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
12
- expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
13
+ it "returns false on invalid VAT #{invalid_vat}" do
14
+ expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
13
15
  end
14
16
  end
15
- end
17
+ end
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::DK do
4
- %w(DK13585628 DK61126228).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
- expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
6
+ %w[DK13585628 DK61126228].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
8
+ expect(Valvat::Checksum.validate(valid_vat)).to be(true)
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
12
- expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
13
+ it "returns false on invalid VAT #{invalid_vat}" do
14
+ expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
13
15
  end
14
16
  end
15
- end
17
+ end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::EE do
4
- %w(EE101234568 EE100207415).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
+ %w[EE101234568 EE100207415].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
6
8
  expect(Valvat::Checksum.validate(valid_vat)).to be true
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
13
+ it "returns false on invalid VAT #{invalid_vat}" do
12
14
  expect(Valvat::Checksum.validate(invalid_vat)).to be false
13
15
  end
14
16
  end
@@ -1,15 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::ES do
4
- %w(ESA13585625 ESB83871236 ESE54507058 ES25139013J ESQ1518001A ESQ5018001G ESX4942978W ESX7676464F ESB10317980 ESY3860557K ESY2207765D).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
- expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
6
+ %w[ESA13585625 ESB83871236 ESE54507058 ES25139013J ESQ1518001A ESQ5018001G ESX4942978W ESX7676464F ESB10317980
7
+ ESY3860557K ESY2207765D].each do |valid_vat|
8
+ it "returns true on valid VAT #{valid_vat}" do
9
+ expect(Valvat::Checksum.validate(valid_vat)).to be(true)
7
10
  end
8
11
 
9
12
  invalid_vat = "#{valid_vat[0..-6]}#{valid_vat[-2]}#{valid_vat[-5]}#{valid_vat[-4]}#{valid_vat[-3]}#{valid_vat[-1]}"
10
13
 
11
- it "returns false on invalid vat #{invalid_vat}" do
12
- expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
14
+ it "returns false on invalid VAT #{invalid_vat}" do
15
+ expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
13
16
  end
14
17
  end
15
- end
18
+ end
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::FI do
4
- %w(FI13669598 FI20584306 FI01080233).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
- expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
6
+ %w[FI13669598 FI20584306 FI01080233].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
8
+ expect(Valvat::Checksum.validate(valid_vat)).to be(true)
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-3]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
12
- expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
13
+ it "returns false on invalid VAT #{invalid_vat}" do
14
+ expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
13
15
  end
14
16
  end
15
- end
17
+ end
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::FR do
4
- %w(FR60528551658 FR43820567501).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
- expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
6
+ %w[FR60528551658 FR43820567501].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
8
+ expect(Valvat::Checksum.validate(valid_vat)).to be(true)
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
12
- expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
13
+ it "returns false on invalid VAT #{invalid_vat}" do
14
+ expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
13
15
  end
14
16
  end
15
- end
17
+ end
@@ -1,11 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
1
5
  describe Valvat::Checksum::GB do
2
- %w(GBGD100 GBHA600).each do |gov_agency_vat|
3
- it "returns true on valid vat for government agency #{gov_agency_vat}" do
6
+ %w[GBGD100 GBHA600].each do |gov_agency_vat|
7
+ it "returns true on valid VAT for government agency #{gov_agency_vat}" do
4
8
  expect(Valvat::Checksum.validate(gov_agency_vat)).to be true
5
9
  end
6
10
  end
7
11
 
8
- %w(GB000000000 GB000000000000).each do |invalid_vat|
12
+ %w[GB000000000 GB000000000000].each do |invalid_vat|
9
13
  it 'is false for all zero number' do
10
14
  expect(Valvat::Checksum.validate(invalid_vat)).to be false
11
15
  end
@@ -19,11 +23,11 @@ describe Valvat::Checksum::GB do
19
23
  expect(Valvat::Checksum.validate('GB434031439')).to be true
20
24
  end
21
25
 
22
- it 'is false for an old format vat in forbidden group' do
26
+ it 'is false for an old format VAT in forbidden group' do
23
27
  expect(Valvat::Checksum.validate('GB999999973')).to be false
24
28
  end
25
29
 
26
- it 'is false for a new format vat in forbidden group' do
30
+ it 'is false for a new format VAT in forbidden group' do
27
31
  expect(Valvat::Checksum.validate('GB100000034')).to be false
28
32
  end
29
33
  end
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::GR do
4
- %w(EL123456783 EL094543092 EL998219694).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
- expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
6
+ %w[EL123456783 EL094543092 EL998219694].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
8
+ expect(Valvat::Checksum.validate(valid_vat)).to be(true)
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
12
- expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
13
+ it "returns false on invalid VAT #{invalid_vat}" do
14
+ expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
13
15
  end
14
16
  end
15
- end
17
+ end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::HR do
4
- %w(HR06282943396 HR17099025134).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
+ %w[HR06282943396 HR17099025134].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
6
8
  expect(Valvat::Checksum.validate(valid_vat)).to be true
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
13
+ it "returns false on invalid VAT #{invalid_vat}" do
12
14
  expect(Valvat::Checksum.validate(invalid_vat)).to be false
13
15
  end
14
16
  end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::HU do
4
- %w(HU10672101 HU13460370 HU10747759).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
+ %w[HU10672101 HU13460370 HU10747759].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
6
8
  expect(Valvat::Checksum.validate(valid_vat)).to be true
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
13
+ it "returns false on invalid VAT #{invalid_vat}" do
12
14
  expect(Valvat::Checksum.validate(invalid_vat)).to be false
13
15
  end
14
16
  end
@@ -1,16 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::IE do
4
- %w(IE8473625E IE0123459N IE9B12345N IE1113571MH IE2973912UH IE2974611LH
5
- IE2974901UH IE3200115LH IE3206791MH IE3208913KH IE3214048CH).each do |valid_vat|
6
- it "returns true on valid vat #{valid_vat}" do
6
+ %w[IE8473625E IE0123459N IE9B12345N IE1113571MH IE2973912UH IE2974611LH
7
+ IE2974901UH IE3200115LH IE3206791MH IE3208913KH IE3214048CH].each do |valid_vat|
8
+ it "returns true on valid VAT #{valid_vat}" do
7
9
  expect(Valvat::Checksum.validate(valid_vat)).to eql(true), valid_vat
8
10
  end
9
11
 
10
12
  invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-2]}#{valid_vat[-3]}#{valid_vat[-1]}"
11
13
 
12
- it "returns false on invalid vat #{invalid_vat}" do
13
- expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
14
+ it "returns false on invalid VAT #{invalid_vat}" do
15
+ expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
16
+ end
17
+ end
18
+
19
+ %w[IE0000000XX IE0000000AZ].each do |invalid|
20
+ it "returns false on invalid VAT #{invalid}" do
21
+ expect(Valvat::Checksum.validate(invalid)).to be(false)
14
22
  end
15
23
  end
16
24
  end
@@ -1,23 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::IT do
4
- %w(IT12345670785 IT01897810162 IT00197200132 IT02762750210).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
- expect(Valvat::Checksum.validate(valid_vat)).to eql(true)
6
+ %w[IT12345670785 IT01897810162 IT00197200132 IT02762750210 IT00146089990].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
8
+ expect(Valvat::Checksum.validate(valid_vat)).to be(true)
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
12
- expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
13
+ it "returns false on invalid VAT #{invalid_vat}" do
14
+ expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
13
15
  end
14
16
  end
15
17
 
16
- it "returns false on invalid special case vat IT12345671783" do
17
- expect(Valvat::Checksum.validate("IT12345671783")).to eql(false)
18
+ it 'returns false on invalid special case VAT IT12345671783' do
19
+ expect(Valvat::Checksum.validate('IT12345671783')).to be(false)
18
20
  end
19
21
 
20
- it "returns false on invalid special case vat IT00000000133" do
21
- expect(Valvat::Checksum.validate("IT00000000133")).to eql(false)
22
+ it 'returns false on invalid special case VAT IT00000000133' do
23
+ expect(Valvat::Checksum.validate('IT00000000133')).to be(false)
22
24
  end
23
- end
25
+ end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Valvat::Checksum::LT do
4
- %w(LT213179412 LT290061371314).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
6
+ %w[LT213179412 LT290061371314].each do |valid_vat|
7
+ it "returns true on valid VAT #{valid_vat}" do
6
8
  expect(Valvat::Checksum.validate(valid_vat)).to be true
7
9
  end
8
10
 
9
11
  invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
10
12
 
11
- it "returns false on invalid vat #{invalid_vat}" do
13
+ it "returns false on invalid VAT #{invalid_vat}" do
12
14
  expect(Valvat::Checksum.validate(invalid_vat)).to be false
13
15
  end
14
16
  end