validates_zipcode 0.7.1 → 0.8.0
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 +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/validates_zipcode/cldr_regex_collection.rb +7 -53
- data/lib/validates_zipcode/countries_without_postcodes.rb +58 -0
- data/lib/validates_zipcode/version.rb +1 -1
- data/lib/validates_zipcode/zipcode.rb +1 -1
- data/lib/validates_zipcode.rb +1 -0
- data/spec/spec_helper.rb +313 -952
- data/spec/validates_zipcode_spec.rb +22 -0
- metadata +3 -2
|
@@ -41,6 +41,19 @@ describe ValidatesZipcode, '#validate_each' do
|
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
+
context 'countries without postcodes' do
|
|
45
|
+
ValidatesZipcode::CldrRegexpCollection::COUNTRIES_WITHOUT_POSTCODES.each_key do |country_code|
|
|
46
|
+
it "accepts a blank zipcode for #{country_code}" do
|
|
47
|
+
zipcode_should_be_valid(build_record('', country_code))
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "has no zipcode regex or fixture for #{country_code}" do
|
|
51
|
+
expect(ValidatesZipcode::CldrRegexpCollection::ZIPCODES_REGEX).not_to have_key(country_code)
|
|
52
|
+
expect(TEST_DATA).not_to have_key(country_code)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
44
57
|
context 'Excluded existing country code' do
|
|
45
58
|
context 'Panama' do
|
|
46
59
|
it 'validates with a valid zipcode' do
|
|
@@ -101,6 +114,15 @@ describe ValidatesZipcode, '.valid?' do
|
|
|
101
114
|
end
|
|
102
115
|
end
|
|
103
116
|
|
|
117
|
+
context 'with nil zipcodes' do
|
|
118
|
+
it 'accepts nil for optional postcodes and rejects it for required postcodes' do
|
|
119
|
+
optional_country_code = 'TO'
|
|
120
|
+
required_country_code = 'US'
|
|
121
|
+
expect(ValidatesZipcode.valid?(nil, optional_country_code)).to eq(true)
|
|
122
|
+
expect(ValidatesZipcode.valid?(nil, required_country_code)).to eq(false)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
104
126
|
context 'with formatting' do
|
|
105
127
|
it 'is true with a valid zipcode for a given country code' do
|
|
106
128
|
expect(ValidatesZipcode.valid?('28 108', 'ES', format: true)).to eq(true)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: validates_zipcode
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Gil
|
|
@@ -48,6 +48,7 @@ files:
|
|
|
48
48
|
- gemfiles/rails_edge.gemfile
|
|
49
49
|
- lib/validates_zipcode.rb
|
|
50
50
|
- lib/validates_zipcode/cldr_regex_collection.rb
|
|
51
|
+
- lib/validates_zipcode/countries_without_postcodes.rb
|
|
51
52
|
- lib/validates_zipcode/formatter.rb
|
|
52
53
|
- lib/validates_zipcode/helper_methods.rb
|
|
53
54
|
- lib/validates_zipcode/invalid_zipcode_error.rb
|
|
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
80
81
|
- !ruby/object:Gem::Version
|
|
81
82
|
version: '0'
|
|
82
83
|
requirements: []
|
|
83
|
-
rubygems_version:
|
|
84
|
+
rubygems_version: 3.6.9
|
|
84
85
|
specification_version: 4
|
|
85
86
|
summary: Localizable zipcode validation for Rails.
|
|
86
87
|
test_files: []
|