big-phoney 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/big-phoney.gemspec +1 -1
- data/lib/big_phoney/phone_number.rb +2 -1
- data/lib/big_phoney/rails.rb +1 -1
- data/spec/big_phoney_spec.rb +10 -0
- metadata +3 -3
data/big-phoney.gemspec
CHANGED
data/lib/big_phoney/rails.rb
CHANGED
@@ -21,7 +21,7 @@ module BigPhoney
|
|
21
21
|
record.errors[attribute] << "must be a valid US phone number"
|
22
22
|
end
|
23
23
|
|
24
|
-
if number and not BigPhoney::PhoneNumber.new(number).valid?
|
24
|
+
if number and not BigPhoney::PhoneNumber.new(number, :country_code => record.try(:country_code)).valid?
|
25
25
|
if record.errors[attribute].empty?
|
26
26
|
record.errors[attribute] << "is not valid"
|
27
27
|
end
|
data/spec/big_phoney_spec.rb
CHANGED
@@ -7,6 +7,11 @@ describe BigPhoney::PhoneNumber do
|
|
7
7
|
number.should be_valid
|
8
8
|
end
|
9
9
|
|
10
|
+
it "is valid with international numbers" do
|
11
|
+
number = BigPhoney::PhoneNumber.new('31624124705')
|
12
|
+
number.should be_valid
|
13
|
+
end
|
14
|
+
|
10
15
|
it "is invalid with wrong country code" do
|
11
16
|
number = BigPhoney::PhoneNumber.new('+29 (484) 123-1234')
|
12
17
|
number.should_not be_valid
|
@@ -114,6 +119,11 @@ describe BigPhoney::PhoneNumber do
|
|
114
119
|
BigPhoney::PhoneNumber.assume_us = false
|
115
120
|
end
|
116
121
|
|
122
|
+
it "can be passed a country code" do
|
123
|
+
phone = BigPhoney::PhoneNumber.new('932211000', :country_code => "34")
|
124
|
+
phone.country_code.should == "34"
|
125
|
+
end
|
126
|
+
|
117
127
|
it "parses 1 digit country code" do
|
118
128
|
phone = BigPhoney::PhoneNumber.new('74841231234')
|
119
129
|
phone.country_code.should == '7'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: big-phoney
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pat Nakajima
|