validates_zipcode 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7d7f06af04e43e053ee9e02218e80b91ad7ab09
4
- data.tar.gz: 8dd09b5e491b61031fbd38feea26ebaf90d92635
3
+ metadata.gz: d310c9cbfd785c952d2daf6b683f224e6ade763e
4
+ data.tar.gz: 17485d2b67e7ff6ee5ecaa9b7fcbb746445ebae4
5
5
  SHA512:
6
- metadata.gz: 16cd34364f9c9ada814c4c1369f40687352ea417813aa67234111c3c81f2ae9aef07781da4d3d04b4886d88c553c6c7628ae95426d485bd929b1cb3d73e31f50
7
- data.tar.gz: fdcc70486056bfddaae572eacdf3b2409309768133dd70da82822007cc9684001c24f5a964b3e0737786259d46403cb668d4ef9cfd17ee198344b6ef0f2a925a
6
+ metadata.gz: 5c40cc987d5e497c36369d8268ec115b0cf93172b1d5137bd054e30ae2202d268ff10ab525b765f11c0c6eb410d152776c95c795d590891f8fb3abd97245d34b
7
+ data.tar.gz: fa7f25b102a97c394fa2543d4b624510850b5d56b20fc3d25de13faa4f3a15a0955ad10ad85566a1d38281e68ae52326d50bb8baaf09fbd9c525076142688996
@@ -202,7 +202,7 @@ module ValidatesZipcode
202
202
  NA: /\A\d{5}\z/,
203
203
  NP: /\A\d{6}\z/,
204
204
  NR: /\A([a-zA-Z\d\s]){3,}\z/,
205
- PT: /\A\d{8}\z/,
205
+ PT: /\A\d{4}([\-]\d{3})?\z/,
206
206
  PS: /\A\d{3}\z/,
207
207
  PA: /\A\d{6}\z/,
208
208
  PE: /\A\d{5}\z/,
@@ -1,3 +1,3 @@
1
1
  module ValidatesZipcode
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -100,13 +100,13 @@ describe ValidatesZipcode, '#validate_each' do
100
100
  record = build_record('21000', 'RS')
101
101
  zipcode_should_be_valid(record)
102
102
  end
103
-
103
+
104
104
  it 'does not validate with an invalid zipcode' do
105
105
  record = build_record('2100', 'RS')
106
106
  zipcode_should_be_invalid(record)
107
107
  end
108
108
  end
109
-
109
+
110
110
  context "unknown country" do
111
111
  it 'does not add errors with a any zipcode' do
112
112
  record = build_record('A1J2Z9', 'ZZ')
@@ -119,7 +119,7 @@ describe ValidatesZipcode, '#validate_each' do
119
119
  record = build_record('LT-0110', 'LT')
120
120
  zipcode_should_be_valid(record)
121
121
  end
122
-
122
+
123
123
  it 'does not validate with an invalid zipcode' do
124
124
  record = build_record('21006', 'LT')
125
125
  zipcode_should_be_invalid(record)
@@ -131,13 +131,27 @@ describe ValidatesZipcode, '#validate_each' do
131
131
  record = build_record('MD2001', 'MD')
132
132
  zipcode_should_be_valid(record)
133
133
  end
134
-
134
+
135
135
  it 'does not validate with an invalid zipcode' do
136
136
  record = build_record('MD-2100', 'MD')
137
137
  zipcode_should_be_invalid(record)
138
138
  end
139
139
  end
140
-
140
+
141
+ context 'Portugal' do
142
+ it 'validates with a valid zipcode' do
143
+ ['4500', '4500-250'].each do |zipcode|
144
+ record = build_record(zipcode, 'PT')
145
+ zipcode_should_be_valid(record)
146
+ end
147
+ end
148
+
149
+ it 'does not validate with an invalid zipcode' do
150
+ record = build_record('4500-2500', 'PT')
151
+ zipcode_should_be_invalid(record)
152
+ end
153
+ end
154
+
141
155
  def zipcode_should_be_valid(record)
142
156
  ValidatesZipcode::Validator.new(attributes: :zipcode).validate(record)
143
157
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_zipcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Gil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-14 00:00:00.000000000 Z
11
+ date: 2015-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel