divISOr 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
data/divISOr.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{divISOr}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Henry and Alberto Pe\303\261a"]
data/lib/divISOr/iso.rb CHANGED
@@ -5,7 +5,7 @@ module ISO
5
5
  end
6
6
 
7
7
  def validate(value, field=:code)
8
- values(field).include?(value.upcase)
8
+ !value.nil? && values(field).include?(value.to_s.upcase)
9
9
  end
10
10
 
11
11
  def all(value, field=:code)
@@ -25,10 +25,23 @@ end
25
25
  describe ISO3166::Codes do
26
26
  context 'validation' do
27
27
  let(:iso_3166) {ISO3166::Codes.new}
28
- let(:iso_records) { mock(:values_for => ['US']) }
28
+ let(:iso_records) { mock(:values_for => ['US', '123']) }
29
29
  before { ISORecords.stub(:new => iso_records) }
30
30
 
31
31
  context 'on default field' do
32
+ it 'returns false for a nil value' do
33
+ iso_3166.validate(nil).should be_false
34
+ end
35
+
36
+ it 'does not match nil to ""' do
37
+ iso_records.stub(:values_for => [''])
38
+ iso_3166.validate(nil).should be_false
39
+ end
40
+
41
+ it 'validates a number' do
42
+ iso_3166.validate(123).should be_true
43
+ end
44
+
32
45
  it 'gets a list of values' do
33
46
  iso_records.should_receive(:values_for).with(:code)
34
47
  iso_3166.validate('US')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: divISOr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - "David Henry and Alberto Pe\xC3\xB1a"