valvat 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +4 -1
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +2 -1
  5. data/.travis.yml +33 -18
  6. data/CHANGES.md +43 -2
  7. data/Gemfile +2 -3
  8. data/README.md +95 -67
  9. data/certs/yolk.pem +23 -19
  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/locales/en.yml +1 -1
  26. data/lib/valvat/locales/fr.yml +17 -17
  27. data/lib/valvat/locales/nb.yml +34 -0
  28. data/lib/valvat/lookup.rb +11 -43
  29. data/lib/valvat/lookup/fault.rb +30 -0
  30. data/lib/valvat/lookup/request.rb +33 -12
  31. data/lib/valvat/lookup/response.rb +36 -0
  32. data/lib/valvat/utils.rb +1 -1
  33. data/lib/valvat/version.rb +1 -1
  34. data/spec/active_model/validations/valvat_validator_spec.rb +66 -66
  35. data/spec/valvat/checksum/at_spec.rb +2 -2
  36. data/spec/valvat/checksum/be_spec.rb +2 -2
  37. data/spec/valvat/checksum/bg_spec.rb +2 -2
  38. data/spec/valvat/checksum/cy_spec.rb +2 -2
  39. data/spec/valvat/checksum/de_spec.rb +2 -2
  40. data/spec/valvat/checksum/dk_spec.rb +2 -2
  41. data/spec/valvat/checksum/ee_spec.rb +2 -2
  42. data/spec/valvat/checksum/es_spec.rb +2 -2
  43. data/spec/valvat/checksum/fi_spec.rb +2 -2
  44. data/spec/valvat/checksum/fr_spec.rb +2 -2
  45. data/spec/valvat/checksum/gb_spec.rb +5 -3
  46. data/spec/valvat/checksum/gr_spec.rb +2 -2
  47. data/spec/valvat/checksum/hr_spec.rb +2 -2
  48. data/spec/valvat/checksum/hu_spec.rb +2 -2
  49. data/spec/valvat/checksum/ie_spec.rb +8 -2
  50. data/spec/valvat/checksum/it_spec.rb +4 -4
  51. data/spec/valvat/checksum/lt_spec.rb +2 -2
  52. data/spec/valvat/checksum/lu_spec.rb +2 -2
  53. data/spec/valvat/checksum/mt_spec.rb +2 -2
  54. data/spec/valvat/checksum/nl_spec.rb +4 -4
  55. data/spec/valvat/checksum/pl_spec.rb +3 -3
  56. data/spec/valvat/checksum/pt_spec.rb +2 -2
  57. data/spec/valvat/checksum/ro_spec.rb +2 -2
  58. data/spec/valvat/checksum/se_spec.rb +3 -3
  59. data/spec/valvat/checksum/si_spec.rb +7 -7
  60. data/spec/valvat/checksum_spec.rb +2 -2
  61. data/spec/valvat/lockup/fault_spec.rb +32 -0
  62. data/spec/valvat/lockup/request_spec.rb +15 -0
  63. data/spec/valvat/lockup/response_spec.rb +27 -0
  64. data/spec/valvat/lookup_spec.rb +168 -35
  65. data/spec/valvat/syntax_spec.rb +29 -29
  66. data/spec/valvat/utils_spec.rb +8 -6
  67. data/spec/valvat_spec.rb +18 -18
  68. data/valvat.gemspec +1 -0
  69. metadata +53 -25
  70. metadata.gz.sig +0 -0
  71. data/lib/valvat/lookup/request_with_id.rb +0 -31
@@ -0,0 +1,30 @@
1
+ class Valvat
2
+ class Lookup
3
+ class Fault < Response
4
+ private
5
+
6
+ def self.cleanup(hash)
7
+ fault = hash[:fault][:faultstring]
8
+ return {valid: false} if fault == "INVALID_INPUT"
9
+ {error: fault_to_error(fault)}
10
+ end
11
+
12
+ FAULTS = {
13
+ "SERVICE_UNAVAILABLE" => ServiceUnavailable,
14
+ "MS_UNAVAILABLE" => MemberStateUnavailable,
15
+ "INVALID_REQUESTER_INFO" => InvalidRequester,
16
+ "TIMEOUT" => Timeout,
17
+ "VAT_BLOCKED" => BlockedError,
18
+ "IP_BLOCKED" => BlockedError,
19
+ "GLOBAL_MAX_CONCURRENT_REQ" => RateLimitError,
20
+ "GLOBAL_MAX_CONCURRENT_REQ_TIME" => RateLimitError,
21
+ "MS_MAX_CONCURRENT_REQ" => RateLimitError,
22
+ "MS_MAX_CONCURRENT_REQ_TIME" => RateLimitError
23
+ }
24
+
25
+ def self.fault_to_error(fault)
26
+ (FAULTS[fault] || UnknownViesError).new(fault)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,30 +1,51 @@
1
+ require 'savon'
2
+
1
3
  class Valvat
2
4
  class Lookup
3
5
  class Request
4
- def initialize(vat)
5
- @vat = vat
6
+ VIES_WSDL_URL = 'https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'
7
+
8
+ def initialize(vat, options)
9
+ @vat = Valvat(vat)
10
+ @options = options || {}
11
+ @requester = @options[:requester] && Valvat(@options[:requester])
6
12
  end
7
13
 
8
- def perform(client)
9
- client.call(action, :message => body, :message_tag => message_tag).to_hash[response_key]
14
+ def perform
15
+ begin
16
+ Response.new(
17
+ client.call(action, message: message, message_tag: message_tag)
18
+ )
19
+ rescue Savon::SOAPFault => fault
20
+ Fault.new(fault)
21
+ end
10
22
  end
11
23
 
12
24
  private
13
25
 
14
- def body
15
- {:country_code => @vat.vat_country_code, :vat_number => @vat.to_s_wo_country}
26
+ def client
27
+ Savon::Client.new({
28
+ wsdl: VIES_WSDL_URL, log: false, follow_redirects: true
29
+ }.merge(@options[:savon] || {}))
16
30
  end
17
31
 
18
- def message_tag
19
- :checkVat
32
+ def message
33
+ {
34
+ country_code: @vat.vat_country_code,
35
+ vat_number: @vat.to_s_wo_country
36
+ }.merge(@requester ? {
37
+ requester_country_code: @requester.vat_country_code,
38
+ requester_vat_number: @requester.to_s_wo_country
39
+ } : {}
40
+ )
20
41
  end
21
42
 
22
- def action
23
- :check_vat
43
+ def message_tag
44
+ @requester ? :checkVatApprox : :checkVat
24
45
  end
25
46
 
26
- def response_key
27
- :check_vat_response
47
+ def action
48
+ @requester ? :check_vat_approx : :check_vat
28
49
  end
29
50
  end
30
51
  end
@@ -0,0 +1,36 @@
1
+ class Valvat
2
+ class Lookup
3
+ class Response
4
+ def initialize(raw)
5
+ @raw = raw
6
+ end
7
+
8
+ def [](key)
9
+ to_hash[key]
10
+ end
11
+
12
+ def to_hash
13
+ @hash ||= self.class.cleanup(@raw.to_hash)
14
+ end
15
+
16
+ private
17
+
18
+ def self.cleanup(hash)
19
+ (hash[:check_vat_approx_response] || hash[:check_vat_response] || {}).inject({}) do |hash, (key, value)|
20
+ hash[cleanup_key(key)] = cleanup_value(value) unless key == :"@xmlns"
21
+ hash
22
+ end
23
+ end
24
+
25
+ TRADER_PREFIX = /\Atrader_/
26
+
27
+ def self.cleanup_key(key)
28
+ key.to_s.sub(TRADER_PREFIX, "").to_sym
29
+ end
30
+
31
+ def self.cleanup_value(value)
32
+ value == "---" ? nil : value
33
+ end
34
+ end
35
+ end
36
+ end
@@ -3,7 +3,7 @@ class Valvat
3
3
 
4
4
  EU_COUNTRIES = %w(AT BE BG CY CZ DE DK EE ES FI FR GB GR HR HU IE IT LT LU LV MT NL PL PT RO SE SI SK)
5
5
  COUNTRY_PATTERN = /\A([A-Z]{2})(.+)\Z/
6
- NORMALIZE_PATTERN = /[-\.:_\s,;]+/
6
+ NORMALIZE_PATTERN = /[[:space:][:punct:][:cntrl:]]+/
7
7
 
8
8
  def self.split(vat)
9
9
  COUNTRY_PATTERN =~ vat
@@ -1,3 +1,3 @@
1
1
  class Valvat
2
- VERSION = "0.8.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -2,27 +2,27 @@ require 'spec_helper'
2
2
 
3
3
  if defined?(ActiveModel)
4
4
  class Invoice < ModelBase
5
- validates :vat_number, :valvat => true
5
+ validates :vat_number, valvat: true
6
6
  end
7
7
 
8
8
  class InvoiceWithLookup < ModelBase
9
- validates :vat_number, :valvat => {:lookup => true}
9
+ validates :vat_number, valvat: {lookup: true}
10
10
  end
11
11
 
12
12
  class InvoiceWithLookupAndFailIfDown < ModelBase
13
- validates :vat_number, :valvat => {:lookup => :fail_if_down}
13
+ validates :vat_number, valvat: {lookup: :fail_if_down}
14
14
  end
15
15
 
16
16
  class InvoiceAllowBlank < ModelBase
17
- validates :vat_number, :valvat => {:allow_blank => true}
17
+ validates :vat_number, valvat: {allow_blank: true}
18
18
  end
19
19
 
20
20
  class InvoiceAllowBlankOnAll < ModelBase
21
- validates :vat_number, :valvat => true, :allow_blank => true
21
+ validates :vat_number, valvat: true, allow_blank: true
22
22
  end
23
23
 
24
24
  class InvoiceCheckCountry < ModelBase
25
- validates :vat_number, :valvat => {:match_country => :country}
25
+ validates :vat_number, valvat: {match_country: :country}
26
26
 
27
27
  def country
28
28
  @attributes[:country]
@@ -30,7 +30,7 @@ if defined?(ActiveModel)
30
30
  end
31
31
 
32
32
  class InvoiceCheckCountryWithLookup < ModelBase
33
- validates :vat_number, :valvat => {:match_country => :country, :lookup => true}
33
+ validates :vat_number, valvat: {match_country: :country, lookup: true}
34
34
 
35
35
  def country
36
36
  @attributes[:country]
@@ -38,18 +38,18 @@ if defined?(ActiveModel)
38
38
  end
39
39
 
40
40
  class InvoiceWithChecksum < ModelBase
41
- validates :vat_number, :valvat => {:checksum => true}
41
+ validates :vat_number, valvat: {checksum: true}
42
42
  end
43
43
 
44
44
  describe Invoice do
45
- context "with valid vat number" do
45
+ context "with valid VAT number" do
46
46
  it "should be valid" do
47
- expect(Invoice.new(:vat_number => "DE259597697")).to be_valid
47
+ expect(Invoice.new(vat_number: "DE259597697")).to be_valid
48
48
  end
49
49
  end
50
50
 
51
- context "with invalid vat number" do
52
- let(:invoice) { Invoice.new(:vat_number => "DE259597697123") }
51
+ context "with invalid VAT number" do
52
+ let(:invoice) { Invoice.new(vat_number: "DE259597697123") }
53
53
 
54
54
  it "should not be valid" do
55
55
  expect(invoice).not_to be_valid
@@ -57,13 +57,13 @@ if defined?(ActiveModel)
57
57
 
58
58
  it "should add default (country specific) error message" do
59
59
  invoice.valid?
60
- expect(invoice.errors[:vat_number]).to eql(["is not a valid German vat number"])
60
+ expect(invoice.errors[:vat_number]).to eql(["is not a valid German VAT number"])
61
61
  end
62
62
 
63
63
  context "with i18n translation in place" do
64
64
  before do
65
- I18n.backend.store_translations(:en, :activemodel => {
66
- :errors => {:models => {:invoice => {:invalid_vat => "is ugly."}}}
65
+ I18n.backend.store_translations(:en, activemodel: {
66
+ errors: {models: {invoice: {invalid_vat: "is ugly."}}}
67
67
  })
68
68
  end
69
69
 
@@ -77,165 +77,165 @@ if defined?(ActiveModel)
77
77
 
78
78
  context "with i18n translation with country adjective placeholder in place" do
79
79
  before do
80
- I18n.backend.store_translations(:en, :activemodel => {
81
- :errors => {:models => {:invoice => {:invalid_vat => "is not a %{country_adjective} vat"}}}
80
+ I18n.backend.store_translations(:en, activemodel: {
81
+ errors: {models: {invoice: {invalid_vat: "is not a %{country_adjective} vat"}}}
82
82
  })
83
83
  end
84
84
 
85
85
  after { I18n.reload! }
86
86
 
87
87
  it "should replace country adjective placeholder" do
88
- invoice = Invoice.new(:vat_number => "IE123")
88
+ invoice = Invoice.new(vat_number: "IE123")
89
89
  invoice.valid?
90
90
  expect(invoice.errors[:vat_number]).to eql(["is not a Irish vat"])
91
91
  end
92
92
 
93
93
  it "should fall back to 'European' if country is missing" do
94
- invoice = Invoice.new(:vat_number => "XX123")
94
+ invoice = Invoice.new(vat_number: "XX123")
95
95
  invoice.valid?
96
96
  expect(invoice.errors[:vat_number]).to eql(["is not a European vat"])
97
97
  end
98
98
  end
99
99
  end
100
100
 
101
- context "with blank vat number" do
101
+ context "with blank VAT number" do
102
102
  it "should not be valid" do
103
- expect(Invoice.new(:vat_number => "")).not_to be_valid
104
- expect(Invoice.new(:vat_number => nil)).not_to be_valid
103
+ expect(Invoice.new(vat_number: "")).not_to be_valid
104
+ expect(Invoice.new(vat_number: nil)).not_to be_valid
105
105
  end
106
106
  end
107
107
  end
108
108
 
109
109
  describe InvoiceWithLookup do
110
- context "with valid but not existing vat number" do
110
+ context "with valid but not existing VAT number" do
111
111
  before do
112
- allow(Valvat::Syntax).to receive_messages(:validate => true)
113
- allow(Valvat::Lookup).to receive_messages(:validate => false)
112
+ allow(Valvat::Syntax).to receive_messages(validate: true)
113
+ allow(Valvat::Lookup).to receive_messages(validate: false)
114
114
  end
115
115
 
116
116
  it "should not be valid" do
117
- expect(InvoiceWithLookup.new(:vat_number => "DE123")).not_to be_valid
117
+ expect(InvoiceWithLookup.new(vat_number: "DE123")).not_to be_valid
118
118
  end
119
119
  end
120
120
 
121
- context "with valid and existing vat number" do
121
+ context "with valid and existing VAT number" do
122
122
  before do
123
- allow(Valvat::Syntax).to receive_messages(:validate => true)
124
- allow(Valvat::Lookup).to receive_messages(:validate => true)
123
+ allow(Valvat::Syntax).to receive_messages(validate: true)
124
+ allow(Valvat::Lookup).to receive_messages(validate: true)
125
125
  end
126
126
 
127
127
  it "should be valid" do
128
- expect(InvoiceWithLookup.new(:vat_number => "DE123")).to be_valid
128
+ expect(InvoiceWithLookup.new(vat_number: "DE123")).to be_valid
129
129
  end
130
130
  end
131
131
 
132
- context "with valid vat number and VIES country service down" do
132
+ context "with valid VAT number and VIES country service down" do
133
133
  before do
134
- allow(Valvat::Syntax).to receive_messages(:validate => true)
135
- allow(Valvat::Lookup).to receive_messages(:validate => nil)
134
+ allow(Valvat::Syntax).to receive_messages(validate: true)
135
+ allow(Valvat::Lookup).to receive_messages(validate: nil)
136
136
  end
137
137
 
138
138
  it "should be valid" do
139
- expect(InvoiceWithLookup.new(:vat_number => "DE123")).to be_valid
139
+ expect(InvoiceWithLookup.new(vat_number: "DE123")).to be_valid
140
140
  end
141
141
  end
142
142
  end
143
143
 
144
144
  describe InvoiceWithLookupAndFailIfDown do
145
- context "with valid vat number and VIES country service down" do
145
+ context "with valid VAT number and VIES country service down" do
146
146
  before do
147
- allow(Valvat::Syntax).to receive_messages(:validate => true)
148
- allow(Valvat::Lookup).to receive_messages(:validate => nil)
147
+ allow(Valvat::Syntax).to receive_messages(validate: true)
148
+ allow(Valvat::Lookup).to receive_messages(validate: nil)
149
149
  end
150
150
 
151
151
  it "should not be valid" do
152
- expect(InvoiceWithLookupAndFailIfDown.new(:vat_number => "DE123")).not_to be_valid
152
+ expect(InvoiceWithLookupAndFailIfDown.new(vat_number: "DE123")).not_to be_valid
153
153
  end
154
154
  end
155
155
  end
156
156
 
157
157
  describe InvoiceAllowBlank do
158
- context "with blank vat number" do
158
+ context "with blank VAT number" do
159
159
  it "should be valid" do
160
- expect(InvoiceAllowBlank.new(:vat_number => "")).to be_valid
161
- expect(InvoiceAllowBlank.new(:vat_number => nil)).to be_valid
160
+ expect(InvoiceAllowBlank.new(vat_number: "")).to be_valid
161
+ expect(InvoiceAllowBlank.new(vat_number: nil)).to be_valid
162
162
  end
163
163
  end
164
164
  end
165
165
 
166
166
  describe InvoiceAllowBlankOnAll do
167
- context "with blank vat number" do
167
+ context "with blank VAT number" do
168
168
  it "should be valid" do
169
- expect(InvoiceAllowBlankOnAll.new(:vat_number => "")).to be_valid
170
- expect(InvoiceAllowBlankOnAll.new(:vat_number => nil)).to be_valid
169
+ expect(InvoiceAllowBlankOnAll.new(vat_number: "")).to be_valid
170
+ expect(InvoiceAllowBlankOnAll.new(vat_number: nil)).to be_valid
171
171
  end
172
172
  end
173
173
  end
174
174
 
175
175
  describe InvoiceCheckCountry do
176
176
  it "should be not valid on blank country" do
177
- expect(InvoiceCheckCountry.new(:country => nil, :vat_number => "DE259597697")).not_to be_valid
178
- expect(InvoiceCheckCountry.new(:country => "", :vat_number => "DE259597697")).not_to be_valid
177
+ expect(InvoiceCheckCountry.new(country: nil, vat_number: "DE259597697")).not_to be_valid
178
+ expect(InvoiceCheckCountry.new(country: "", vat_number: "DE259597697")).not_to be_valid
179
179
  end
180
180
 
181
181
  it "should be not valid on wired country" do
182
- expect(InvoiceCheckCountry.new(:country => "XAXXX", :vat_number => "DE259597697")).not_to be_valid
183
- expect(InvoiceCheckCountry.new(:country => "ZO", :vat_number => "DE259597697")).not_to be_valid
182
+ expect(InvoiceCheckCountry.new(country: "XAXXX", vat_number: "DE259597697")).not_to be_valid
183
+ expect(InvoiceCheckCountry.new(country: "ZO", vat_number: "DE259597697")).not_to be_valid
184
184
  end
185
185
 
186
186
  it "should be not valid on mismatching (eu) country" do
187
- expect(InvoiceCheckCountry.new(:country => "FR", :vat_number => "DE259597697")).not_to be_valid
188
- expect(InvoiceCheckCountry.new(:country => "AT", :vat_number => "DE259597697")).not_to be_valid
189
- expect(InvoiceCheckCountry.new(:country => "DE", :vat_number => "ATU65931334")).not_to be_valid
187
+ expect(InvoiceCheckCountry.new(country: "FR", vat_number: "DE259597697")).not_to be_valid
188
+ expect(InvoiceCheckCountry.new(country: "AT", vat_number: "DE259597697")).not_to be_valid
189
+ expect(InvoiceCheckCountry.new(country: "DE", vat_number: "ATU65931334")).not_to be_valid
190
190
  end
191
191
 
192
192
  it "should be valid on matching country" do
193
- expect(InvoiceCheckCountry.new(:country => "DE", :vat_number => "DE259597697")).to be_valid
194
- expect(InvoiceCheckCountry.new(:country => "AT", :vat_number => "ATU65931334")).to be_valid
193
+ expect(InvoiceCheckCountry.new(country: "DE", vat_number: "DE259597697")).to be_valid
194
+ expect(InvoiceCheckCountry.new(country: "AT", vat_number: "ATU65931334")).to be_valid
195
195
  end
196
196
 
197
197
  it "should give back error message with country from :country_match" do
198
- invoice = InvoiceCheckCountry.new(:country => "FR", :vat_number => "DE259597697")
198
+ invoice = InvoiceCheckCountry.new(country: "FR", vat_number: "DE259597697")
199
199
  invoice.valid?
200
- expect(invoice.errors[:vat_number]).to eql(["is not a valid French vat number"])
200
+ expect(invoice.errors[:vat_number]).to eql(["is not a valid French VAT number"])
201
201
  end
202
202
 
203
- it "should give back error message with country from :country_match even on invalid vat number" do
204
- invoice = InvoiceCheckCountry.new(:country => "FR", :vat_number => "DE259597697123")
203
+ it "should give back error message with country from :country_match even on invalid VAT number" do
204
+ invoice = InvoiceCheckCountry.new(country: "FR", vat_number: "DE259597697123")
205
205
  invoice.valid?
206
- expect(invoice.errors[:vat_number]).to eql(["is not a valid French vat number"])
206
+ expect(invoice.errors[:vat_number]).to eql(["is not a valid French VAT number"])
207
207
  end
208
208
  end
209
209
 
210
210
  describe InvoiceCheckCountryWithLookup do
211
211
  before do
212
- allow(Valvat::Syntax).to receive_messages(:validate => true)
213
- allow(Valvat::Lookup).to receive_messages(:validate => true)
212
+ allow(Valvat::Syntax).to receive_messages(validate: true)
213
+ allow(Valvat::Lookup).to receive_messages(validate: true)
214
214
  end
215
215
 
216
216
  it "avoids lookup or syntax check on failed because of mismatching country" do
217
217
  expect(Valvat::Syntax).not_to receive(:validate)
218
218
  expect(Valvat::Lookup).not_to receive(:validate)
219
- InvoiceCheckCountryWithLookup.new(:country => "FR", :vat_number => "DE259597697").valid?
219
+ InvoiceCheckCountryWithLookup.new(country: "FR", vat_number: "DE259597697").valid?
220
220
  end
221
221
 
222
222
  it "check syntax and looup on matching country" do
223
223
  expect(Valvat::Syntax).to receive(:validate).and_return(true)
224
224
  expect(Valvat::Lookup).to receive(:validate).and_return(true)
225
- InvoiceCheckCountryWithLookup.new(:country => "DE", :vat_number => "DE259597697").valid?
225
+ InvoiceCheckCountryWithLookup.new(country: "DE", vat_number: "DE259597697").valid?
226
226
  end
227
227
  end
228
228
 
229
229
  describe InvoiceWithChecksum do
230
- context "with valid vat number" do
230
+ context "with valid VAT number" do
231
231
  it "should be valid" do
232
- expect(InvoiceWithChecksum.new(:vat_number => "DE259597697")).to be_valid
232
+ expect(InvoiceWithChecksum.new(vat_number: "DE259597697")).to be_valid
233
233
  end
234
234
  end
235
235
 
236
- context "with invalid vat number" do
236
+ context "with invalid VAT number" do
237
237
  it "should not be valid" do
238
- expect(InvoiceWithChecksum.new(:vat_number => "DE259597687")).not_to be_valid
238
+ expect(InvoiceWithChecksum.new(vat_number: "DE259597687")).not_to be_valid
239
239
  end
240
240
  end
241
241
  end
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe Valvat::Checksum::AT do
4
4
  %w(ATU13585627 ATU66059506 ATU42403001).each do |valid_vat|
5
- it "returns true on valid vat #{valid_vat}" do
5
+ it "returns true on valid VAT #{valid_vat}" do
6
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
- it "returns false on invalid vat #{invalid_vat}" do
11
+ it "returns false on invalid VAT #{invalid_vat}" do
12
12
  expect(Valvat::Checksum.validate(invalid_vat)).to eql(false)
13
13
  end
14
14
  end