valvat 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b170f10e2a265c6da14bbd5c84d60efa9bae5519
4
- data.tar.gz: f146300ab0f27c975c0abd00a491f7cfaec40092
3
+ metadata.gz: de213034100a14f27abc0826f14073d390864ca0
4
+ data.tar.gz: f7b2ac840be2d736e3a0ca9fe7505b2884fe4022
5
5
  SHA512:
6
- metadata.gz: c8ef6a1375a425b8c6d5637e9cac5978c32d7279888966a9f1c9a530c1d71e4f36a5b02ce5ecd68ffe0e32bbf64eda6249540a44b560769ccbcfcbfcfda159e1
7
- data.tar.gz: 7851b20ae347a34f5466bcb67aa3a198083e400155b0a86176424ba807f0cf4abb9b585f1713045eec3680a7c66220fd4b490a8325bedf8c9909b776f3d5a85a
6
+ metadata.gz: 2af8967f19c4de9ebd3476196bd1d85be240d1dfc2545cd77d77cfced868ae5337b27597ab360641831fb15ce543dd58215720ad14b899ea9d4566cbd10e2627
7
+ data.tar.gz: 640305dfc1ce256f77e62cb396ea5f38b6042fdf2c9c66b2c9ad99c0aaa5fff038d47ac340c3c5f25babb138c6010cd69d1dd525fd04bc80605fcaa8f7e00196
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.1.2
data/.travis.yml CHANGED
@@ -1,10 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.0
3
+ - 2.1.1
4
4
  - 2.0.0
5
5
  - 1.9.3
6
6
  - jruby-19mode
7
- - rbx-2.1.1
7
+ - rbx-2.2.9
8
8
  gemfile:
9
9
  - gemfiles/activemodel-4
10
10
  - gemfiles/activemodel-3-2
data/CHANGES.md CHANGED
@@ -1,6 +1,14 @@
1
1
  ### dev
2
2
 
3
- [full changelog](http://github.com/yolk/valvat/compare/v0.6.4...master)
3
+ [full changelog](http://github.com/yolk/valvat/compare/v0.6.5...master)
4
+
5
+ ### 0.6.5 / 2014-06-19
6
+
7
+ [full changelog](http://github.com/yolk/valvat/compare/v0.6.4...v0.6.5)
8
+
9
+ * Added french, spanish and danish translations (by [Roman Lehnert](https://github.com/romanlehnert))
10
+ * Specs: Fixed issues with rspec 3
11
+ * Specs: Switched to :expect syntax
4
12
 
5
13
  ### 0.6.4 / 2014-04-09
6
14
 
data/README.md CHANGED
@@ -11,10 +11,10 @@ Validates european vat numbers. Standalone or as a ActiveModel validator.
11
11
  * Lookup via the VIES web service
12
12
  * (Optional) ActiveModel/Rails3 integration
13
13
  * Works standalone without ActiveModel
14
- * I18n locales for country specific error messages in English, German, Swedish, Italian, Portuguese, Polish, Dutch, Bulgarian, Romanian and Latvian.
14
+ * I18n locales for country specific error messages in English, German, French, Spanish, Italian, Portuguese, Polish, Swedish, Dutch, Danish, Bulgarian, Romanian and Latvian.
15
15
  * *Experimental* checksum verification
16
16
 
17
- valvat is tested and works with ruby MRI 1.9.3/2.0/2.1 and jruby (in 1.9 mode) and ActiveModel 3.2/4.0
17
+ valvat is tested and works with ruby MRI 1.9.3/2.0/2.1, jruby (in 1.9 mode) and rubinius 2.2 and ActiveModel 3.2/4.1
18
18
 
19
19
  ## Installation
20
20
 
@@ -188,6 +188,7 @@ There seems to be a problem when using the VIES service over IPv6. Sadly this is
188
188
 
189
189
  ## Contributions by
190
190
 
191
+ * [Roman Lehnert](https://github.com/romanlehnert)
191
192
  * [0scarius](https://github.com/0scarius)
192
193
  * [Davidslv](https://github.com/Davidslv)
193
194
  * [brianphillips](https://github.com/brianphillips)
@@ -3,7 +3,7 @@ source "http://rubygems.org"
3
3
  gem "savon", "2.3.0"
4
4
  gem "activemodel", "3.2.15"
5
5
 
6
- gem 'rspec', '>= 2.14.0'
6
+ gem 'rspec', '~> 3.0'
7
7
  gem 'fakeweb', '>= 1.3.0'
8
8
  gem 'rake'
9
9
 
@@ -3,7 +3,7 @@ source "http://rubygems.org"
3
3
  gem "savon", "2.3.0"
4
4
  gem "activemodel", "4.0.1"
5
5
 
6
- gem 'rspec', '>= 2.14.0'
6
+ gem 'rspec', '~> 3.0'
7
7
  gem 'fakeweb', '>= 1.3.0'
8
8
  gem 'rake'
9
9
 
data/gemfiles/standalone CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
2
2
 
3
3
  gem "savon", "2.3.0"
4
4
 
5
- gem 'rspec', '>= 2.14.0'
5
+ gem 'rspec', '~> 3.0'
6
6
  gem 'fakeweb', '>= 1.3.0'
7
7
  gem 'rake'
8
8
 
@@ -0,0 +1,34 @@
1
+ da:
2
+ errors:
3
+ messages:
4
+ invalid_vat: Er ikke et gyldigt %{country_adjective} moms-nummer
5
+ valvat:
6
+ country_adjectives:
7
+ eu: Europæisk
8
+ at: Østrigsk
9
+ be: Belgisk
10
+ bg: Bulgarsk
11
+ cy: Cypriotisk
12
+ cz: Tjekkisk
13
+ de: Tysk
14
+ dk: Dansk
15
+ ee: Estisk
16
+ es: Spansk
17
+ fi: Finsk
18
+ fr: Fransk
19
+ gb: Engelsk
20
+ gr: Græsk
21
+ hu: Ungarsk
22
+ ie: Irsk
23
+ it: Italiensk
24
+ lt: Litauisk
25
+ lu: Luxembourgsk
26
+ lv: Lettisk
27
+ mt: Maltesisk
28
+ nl: Nederlandsk
29
+ pl: Polsk
30
+ pt: Portugisisk
31
+ ro: Rumænsk
32
+ se: Svensk
33
+ si: Slovensk
34
+ sk: Slovakisk
@@ -0,0 +1,34 @@
1
+ es:
2
+ errors:
3
+ messages:
4
+ invalid_vat: el impuesto sobre el valor añadido %{country_adjective} no es válido
5
+ valvat:
6
+ country_adjectives:
7
+ eu: europeo
8
+ at: austriaco
9
+ be: belga
10
+ bg: búlgaro
11
+ cy: chipriota
12
+ cz: checo
13
+ de: alemán
14
+ dk: danés
15
+ ee: estonio
16
+ es: español
17
+ fi: finlandés
18
+ fr: francés
19
+ gb: británico
20
+ gr: griego
21
+ hu: úngaro
22
+ ie: irlandés
23
+ it: italiano
24
+ lt: lituano
25
+ lu: luxemburgués
26
+ lv: letón
27
+ mt: maltés
28
+ nl: holandés
29
+ pl: polaco
30
+ pt: portugués
31
+ ro: romano
32
+ se: sueco
33
+ si: eslovenio
34
+ sk: eslovaco
@@ -0,0 +1,33 @@
1
+ fr:
2
+ errors:
3
+ messages:
4
+ invalid_vat: "ce n`est pas un nombre d`identification de TVA %{country_adjective} valide"
5
+ valvat:
6
+ country_adjectives:
7
+ eu: européen
8
+ at: autrichienne
9
+ be: belge
10
+ bg: bulgare
11
+ cy: chypriote
12
+ cz: tchèque
13
+ de: allemande
14
+ dk: danoise
15
+ ee: estonien
16
+ es: espagnole
17
+ fi: finlandaise
18
+ fr: français
19
+ gb: britannique
20
+ gr: grec
21
+ ie: irlandais
22
+ it: italien
23
+ lt: lituanienne
24
+ lu: luxembourgeoise
25
+ lv: letton
26
+ mt: maltais
27
+ nl: français
28
+ pl: polonais
29
+ pt: portugais
30
+ ro: roumaine
31
+ se: suédois
32
+ si: suédois
33
+ sk: slovaque
@@ -1,3 +1,3 @@
1
1
  class Valvat
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
@@ -44,7 +44,7 @@ if defined?(ActiveModel)
44
44
  describe Invoice do
45
45
  context "with valid vat number" do
46
46
  it "should be valid" do
47
- Invoice.new(:vat_number => "DE259597697").should be_valid
47
+ expect(Invoice.new(:vat_number => "DE259597697")).to be_valid
48
48
  end
49
49
  end
50
50
 
@@ -52,12 +52,12 @@ if defined?(ActiveModel)
52
52
  let(:invoice) { Invoice.new(:vat_number => "DE259597697123") }
53
53
 
54
54
  it "should not be valid" do
55
- invoice.should_not be_valid
55
+ expect(invoice).not_to be_valid
56
56
  end
57
57
 
58
58
  it "should add default (country specific) error message" do
59
59
  invoice.valid?
60
- invoice.errors[:vat_number].should 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
@@ -71,7 +71,7 @@ if defined?(ActiveModel)
71
71
 
72
72
  it "should use translation" do
73
73
  invoice.valid?
74
- invoice.errors[:vat_number].should eql(["is ugly."])
74
+ expect(invoice.errors[:vat_number]).to eql(["is ugly."])
75
75
  end
76
76
  end
77
77
 
@@ -87,21 +87,21 @@ if defined?(ActiveModel)
87
87
  it "should replace country adjective placeholder" do
88
88
  invoice = Invoice.new(:vat_number => "IE123")
89
89
  invoice.valid?
90
- invoice.errors[:vat_number].should eql(["is not a Irish vat"])
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
94
  invoice = Invoice.new(:vat_number => "XX123")
95
95
  invoice.valid?
96
- invoice.errors[:vat_number].should eql(["is not a European vat"])
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
101
  context "with blank vat number" do
102
102
  it "should not be valid" do
103
- Invoice.new(:vat_number => "").should_not be_valid
104
- Invoice.new(:vat_number => nil).should_not 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
@@ -109,34 +109,34 @@ if defined?(ActiveModel)
109
109
  describe InvoiceWithLookup do
110
110
  context "with valid but not existing vat number" do
111
111
  before do
112
- Valvat::Syntax.stub(:validate => true)
113
- Valvat::Lookup.stub(: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
- InvoiceWithLookup.new(:vat_number => "DE123").should_not be_valid
117
+ expect(InvoiceWithLookup.new(:vat_number => "DE123")).not_to be_valid
118
118
  end
119
119
  end
120
120
 
121
121
  context "with valid and existing vat number" do
122
122
  before do
123
- Valvat::Syntax.stub(:validate => true)
124
- Valvat::Lookup.stub(: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
- InvoiceWithLookup.new(:vat_number => "DE123").should be_valid
128
+ expect(InvoiceWithLookup.new(:vat_number => "DE123")).to be_valid
129
129
  end
130
130
  end
131
131
 
132
132
  context "with valid vat number and VIES country service down" do
133
133
  before do
134
- Valvat::Syntax.stub(:validate => true)
135
- Valvat::Lookup.stub(: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
- InvoiceWithLookup.new(:vat_number => "DE123").should be_valid
139
+ expect(InvoiceWithLookup.new(:vat_number => "DE123")).to be_valid
140
140
  end
141
141
  end
142
142
  end
@@ -144,12 +144,12 @@ if defined?(ActiveModel)
144
144
  describe InvoiceWithLookupAndFailIfDown do
145
145
  context "with valid vat number and VIES country service down" do
146
146
  before do
147
- Valvat::Syntax.stub(:validate => true)
148
- Valvat::Lookup.stub(: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
- InvoiceWithLookupAndFailIfDown.new(:vat_number => "DE123").should_not be_valid
152
+ expect(InvoiceWithLookupAndFailIfDown.new(:vat_number => "DE123")).not_to be_valid
153
153
  end
154
154
  end
155
155
  end
@@ -157,8 +157,8 @@ if defined?(ActiveModel)
157
157
  describe InvoiceAllowBlank do
158
158
  context "with blank vat number" do
159
159
  it "should be valid" do
160
- InvoiceAllowBlank.new(:vat_number => "").should be_valid
161
- InvoiceAllowBlank.new(:vat_number => nil).should 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
@@ -166,62 +166,62 @@ if defined?(ActiveModel)
166
166
  describe InvoiceAllowBlankOnAll do
167
167
  context "with blank vat number" do
168
168
  it "should be valid" do
169
- InvoiceAllowBlankOnAll.new(:vat_number => "").should be_valid
170
- InvoiceAllowBlankOnAll.new(:vat_number => nil).should 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
- InvoiceCheckCountry.new(:country => nil, :vat_number => "DE259597697").should_not be_valid
178
- InvoiceCheckCountry.new(:country => "", :vat_number => "DE259597697").should_not 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
- InvoiceCheckCountry.new(:country => "XAXXX", :vat_number => "DE259597697").should_not be_valid
183
- InvoiceCheckCountry.new(:country => "ZO", :vat_number => "DE259597697").should_not 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
- InvoiceCheckCountry.new(:country => "FR", :vat_number => "DE259597697").should_not be_valid
188
- InvoiceCheckCountry.new(:country => "AT", :vat_number => "DE259597697").should_not be_valid
189
- InvoiceCheckCountry.new(:country => "DE", :vat_number => "ATU65931334").should_not 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
- InvoiceCheckCountry.new(:country => "DE", :vat_number => "DE259597697").should be_valid
194
- InvoiceCheckCountry.new(:country => "AT", :vat_number => "ATU65931334").should 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
198
  invoice = InvoiceCheckCountry.new(:country => "FR", :vat_number => "DE259597697")
199
199
  invoice.valid?
200
- invoice.errors[:vat_number].should 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
203
  it "should give back error message with country from :country_match even on invalid vat number" do
204
204
  invoice = InvoiceCheckCountry.new(:country => "FR", :vat_number => "DE259597697123")
205
205
  invoice.valid?
206
- invoice.errors[:vat_number].should 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
- Valvat::Syntax.stub(:validate => true)
213
- Valvat::Lookup.stub(: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
- Valvat::Syntax.should_not_receive(:validate)
218
- Valvat::Lookup.should_not_receive(:validate)
217
+ expect(Valvat::Syntax).not_to receive(:validate)
218
+ expect(Valvat::Lookup).not_to receive(:validate)
219
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
- Valvat::Syntax.should_receive(:validate).and_return(true)
224
- Valvat::Lookup.should_receive(:validate).and_return(true)
223
+ expect(Valvat::Syntax).to receive(:validate).and_return(true)
224
+ expect(Valvat::Lookup).to receive(:validate).and_return(true)
225
225
  InvoiceCheckCountryWithLookup.new(:country => "DE", :vat_number => "DE259597697").valid?
226
226
  end
227
227
  end
@@ -229,13 +229,13 @@ if defined?(ActiveModel)
229
229
  describe InvoiceWithChecksum do
230
230
  context "with valid vat number" do
231
231
  it "should be valid" do
232
- InvoiceWithChecksum.new(:vat_number => "DE259597697").should be_valid
232
+ expect(InvoiceWithChecksum.new(:vat_number => "DE259597697")).to be_valid
233
233
  end
234
234
  end
235
235
 
236
236
  context "with invalid vat number" do
237
237
  it "should not be valid" do
238
- InvoiceWithChecksum.new(:vat_number => "DE259597687").should_not be_valid
238
+ expect(InvoiceWithChecksum.new(:vat_number => "DE259597687")).not_to be_valid
239
239
  end
240
240
  end
241
241
  end
data/spec/spec_helper.rb CHANGED
@@ -12,7 +12,6 @@ $fakeweb = true
12
12
 
13
13
  RSpec.configure do |config|
14
14
  config.mock_with :rspec
15
- config.treat_symbols_as_metadata_keys_with_true_values = true
16
15
  config.filter_run :focus => true
17
16
  config.run_all_when_everything_filtered = true
18
17
  config.backtrace_exclusion_patterns = [/rspec\/(core|expectations)/]
@@ -3,13 +3,13 @@ require 'spec_helper'
3
3
  describe Valvat::Checksum::AT do
4
4
  %w(ATU13585627 ATU66059506 ATU42403001).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