phony_rails 0.14.3 → 0.14.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.rubocop.yml +2 -0
- data/.rubocop_todo.yml +1 -1
- data/.travis.yml +10 -3
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +49 -54
- data/Guardfile +1 -0
- data/Rakefile +1 -0
- data/lib/phony_rails.rb +7 -9
- data/lib/phony_rails/string_extensions.rb +1 -0
- data/lib/phony_rails/version.rb +2 -1
- data/lib/validators/phony_validator.rb +1 -0
- data/phony_rails.gemspec +3 -2
- data/spec/lib/phony_rails_spec.rb +33 -15
- data/spec/lib/validators/phony_validator_spec.rb +12 -5
- data/spec/spec_helper.rb +1 -0
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MzI5ZjE3YTU1MjhiZTRiY2RjZjhhZDg0YjA0MGViZDNkNjI5OWVhYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTc5ZGJhMTAyM2ZhNmVmNWZhODJmN2JiZWVjYzViMzNmMWUyY2NmNQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ODRhZGZmZDVjNjkxMjJiZjc3NGE3ZjI1NWFhYTg3OWQzMTJlMDc1ZTk0YTJm
|
10
|
+
Y2NjYzQ0MDczZWVjODM0ZDE4MzQ5YjRlNjA5NzIwOTczNWJiOWMxNmE0MTdj
|
11
|
+
Yzg2NjJlMjU5YTJkNDYwMWFlOWFiMDIwMTA3MDFjNWU0Yjk2N2E=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZmMxYmY5NTU0MDcxOWJkN2JiMjY1NWU3MDhiNDA0MmUxMmZmNDc3OGM0YTMy
|
14
|
+
YmQ2M2M4NGRjNzQ1MzE2Yzg2ODk3ZDVlMGFmZjYyYzY5ZjUzNjA3ODIyM2Fm
|
15
|
+
MjM3MDdjZTU1NTc0OTlhNWU4ZTY1ZWZiMGI4MDI1MDJiOGIyNGM=
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
|
3
|
+
- 2.2.5
|
4
|
+
- 2.3.1
|
4
5
|
script:
|
5
|
-
|
6
|
-
|
6
|
+
- bundle exec rspec spec
|
7
|
+
- bundle exec rubocop
|
8
|
+
deploy:
|
9
|
+
provider: rubygems
|
10
|
+
api_key:
|
11
|
+
secure: KP9HSdb/cWP66VD57MgLG3c3H6nlzWH0h6jF/j4Hi5ylJH1BcAU7FYB8ej2yj/WvCCk8Nwc6Pvr3xipAkDzRPCeDiZk0MPu0U+nnE+vlytZ3wmcoo0puDSRxn2KMjCv78ZdgbQkE3ik1a7TsmaxMMQGNrkT5ADDi2XHBneyCPYs=
|
12
|
+
on:
|
13
|
+
tags: true
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [Unreleased](https://github.com/joost/phony_rails/tree/HEAD)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/joost/phony_rails/compare/v0.14.2...HEAD)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- Add support for internal Russian phone style \(8 926 ... instead of +7 926 ...\) [\#148](https://github.com/joost/phony_rails/issues/148)
|
10
|
+
- is it necessary to extend ActiveRecord::Base instead of ActiveModel::Model ? [\#143](https://github.com/joost/phony_rails/issues/143)
|
11
|
+
|
3
12
|
## [v0.14.2](https://github.com/joost/phony_rails/tree/v0.14.2) (2016-06-16)
|
4
13
|
[Full Changelog](https://github.com/joost/phony_rails/compare/v0.14.1...v0.14.2)
|
5
14
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,40 +1,38 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
phony_rails (0.14.
|
4
|
+
phony_rails (0.14.4)
|
5
5
|
activesupport (>= 3.0)
|
6
6
|
phony (~> 2.15)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (
|
12
|
-
activesupport (=
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
activemodel (5.0.0.1)
|
12
|
+
activesupport (= 5.0.0.1)
|
13
|
+
activerecord (5.0.0.1)
|
14
|
+
activemodel (= 5.0.0.1)
|
15
|
+
activesupport (= 5.0.0.1)
|
16
|
+
arel (~> 7.0)
|
17
|
+
activesupport (5.0.0.1)
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
19
|
i18n (~> 0.7)
|
20
|
-
json (~> 1.7, >= 1.7.7)
|
21
20
|
minitest (~> 5.1)
|
22
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
23
21
|
tzinfo (~> 1.1)
|
24
|
-
arel (
|
22
|
+
arel (7.1.4)
|
25
23
|
ast (2.3.0)
|
26
24
|
bson (4.1.1)
|
27
|
-
builder (3.2.2)
|
28
25
|
coderay (1.1.1)
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
concurrent-ruby (1.0.2)
|
27
|
+
coveralls (0.8.15)
|
28
|
+
json (>= 1.8, < 3)
|
29
|
+
simplecov (~> 0.12.0)
|
32
30
|
term-ansicolor (~> 1.3)
|
33
31
|
thor (~> 0.19.1)
|
34
|
-
tins (
|
32
|
+
tins (>= 1.6.0, < 2)
|
35
33
|
diff-lcs (1.2.5)
|
36
34
|
docile (1.1.5)
|
37
|
-
ffi (1.9.
|
35
|
+
ffi (1.9.14)
|
38
36
|
formatador (0.2.5)
|
39
37
|
guard (2.14.0)
|
40
38
|
formatador (>= 0.2.4)
|
@@ -50,81 +48,78 @@ GEM
|
|
50
48
|
guard (~> 2.2)
|
51
49
|
guard-compat (~> 1.1)
|
52
50
|
guard-compat (1.2.1)
|
53
|
-
guard-rspec (4.7.
|
51
|
+
guard-rspec (4.7.3)
|
54
52
|
guard (~> 2.1)
|
55
53
|
guard-compat (~> 1.1)
|
56
54
|
rspec (>= 2.99.0, < 4.0)
|
57
55
|
i18n (0.7.0)
|
58
|
-
json (
|
56
|
+
json (2.0.2)
|
59
57
|
listen (3.1.5)
|
60
58
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
61
59
|
rb-inotify (~> 0.9, >= 0.9.7)
|
62
60
|
ruby_dep (~> 1.2)
|
63
61
|
lumberjack (1.0.10)
|
64
62
|
method_source (0.8.2)
|
65
|
-
minitest (5.9.
|
66
|
-
mongo (2.
|
67
|
-
bson (~> 4.
|
68
|
-
mongoid (
|
69
|
-
activemodel (~>
|
70
|
-
mongo (~> 2.
|
71
|
-
origin (~> 2.2)
|
72
|
-
tzinfo (>= 0.3.37)
|
63
|
+
minitest (5.9.1)
|
64
|
+
mongo (2.3.0)
|
65
|
+
bson (~> 4.1)
|
66
|
+
mongoid (6.0.0)
|
67
|
+
activemodel (~> 5.0)
|
68
|
+
mongo (~> 2.3)
|
73
69
|
nenv (0.3.0)
|
74
|
-
notiffany (0.1.
|
70
|
+
notiffany (0.1.1)
|
75
71
|
nenv (~> 0.1)
|
76
72
|
shellany (~> 0.0)
|
77
|
-
|
78
|
-
parser (2.3.1.2)
|
73
|
+
parser (2.3.1.4)
|
79
74
|
ast (~> 2.2)
|
80
|
-
phony (2.15.
|
75
|
+
phony (2.15.32)
|
81
76
|
powerpack (0.1.1)
|
82
|
-
pry (0.10.
|
77
|
+
pry (0.10.4)
|
83
78
|
coderay (~> 1.1.0)
|
84
79
|
method_source (~> 0.8.1)
|
85
80
|
slop (~> 3.4)
|
86
81
|
rainbow (2.1.0)
|
87
|
-
rake (11.
|
82
|
+
rake (11.3.0)
|
88
83
|
rb-fsevent (0.9.7)
|
89
84
|
rb-inotify (0.9.7)
|
90
85
|
ffi (>= 0.5.0)
|
91
|
-
rspec (3.
|
92
|
-
rspec-core (~> 3.
|
93
|
-
rspec-expectations (~> 3.
|
94
|
-
rspec-mocks (~> 3.
|
95
|
-
rspec-core (3.
|
96
|
-
rspec-support (~> 3.
|
97
|
-
rspec-expectations (3.
|
86
|
+
rspec (3.5.0)
|
87
|
+
rspec-core (~> 3.5.0)
|
88
|
+
rspec-expectations (~> 3.5.0)
|
89
|
+
rspec-mocks (~> 3.5.0)
|
90
|
+
rspec-core (3.5.4)
|
91
|
+
rspec-support (~> 3.5.0)
|
92
|
+
rspec-expectations (3.5.0)
|
98
93
|
diff-lcs (>= 1.2.0, < 2.0)
|
99
|
-
rspec-support (~> 3.
|
100
|
-
rspec-mocks (3.
|
94
|
+
rspec-support (~> 3.5.0)
|
95
|
+
rspec-mocks (3.5.0)
|
101
96
|
diff-lcs (>= 1.2.0, < 2.0)
|
102
|
-
rspec-support (~> 3.
|
103
|
-
rspec-support (3.
|
104
|
-
rubocop (0.
|
105
|
-
parser (>= 2.3.1.
|
97
|
+
rspec-support (~> 3.5.0)
|
98
|
+
rspec-support (3.5.0)
|
99
|
+
rubocop (0.43.0)
|
100
|
+
parser (>= 2.3.1.1, < 3.0)
|
106
101
|
powerpack (~> 0.1)
|
107
102
|
rainbow (>= 1.99.1, < 3.0)
|
108
103
|
ruby-progressbar (~> 1.7)
|
109
104
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
110
105
|
ruby-progressbar (1.8.1)
|
111
|
-
ruby_dep (1.
|
106
|
+
ruby_dep (1.5.0)
|
112
107
|
shellany (0.0.1)
|
113
|
-
simplecov (0.
|
108
|
+
simplecov (0.12.0)
|
114
109
|
docile (~> 1.1.0)
|
115
|
-
json (
|
110
|
+
json (>= 1.8, < 3)
|
116
111
|
simplecov-html (~> 0.10.0)
|
117
112
|
simplecov-html (0.10.0)
|
118
113
|
slop (3.6.0)
|
119
|
-
sqlite3 (1.3.
|
120
|
-
term-ansicolor (1.
|
114
|
+
sqlite3 (1.3.12)
|
115
|
+
term-ansicolor (1.4.0)
|
121
116
|
tins (~> 1.0)
|
122
117
|
thor (0.19.1)
|
123
118
|
thread_safe (0.3.5)
|
124
|
-
tins (1.
|
119
|
+
tins (1.12.0)
|
125
120
|
tzinfo (1.2.2)
|
126
121
|
thread_safe (~> 0.1)
|
127
|
-
unicode-display_width (1.
|
122
|
+
unicode-display_width (1.1.1)
|
128
123
|
|
129
124
|
PLATFORMS
|
130
125
|
ruby
|
data/Guardfile
CHANGED
data/Rakefile
CHANGED
data/lib/phony_rails.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'phony'
|
2
3
|
require 'phony_rails/string_extensions'
|
3
4
|
require 'validators/phony_validator'
|
@@ -71,14 +72,11 @@ module PhonyRails
|
|
71
72
|
# We try to add the default country number and see if it is a
|
72
73
|
# correct phone number. See https://github.com/joost/phony_rails/issues/87#issuecomment-89324426
|
73
74
|
unless number =~ /\A\+/ # if we don't have a +
|
74
|
-
if Phony.plausible?("#{default_country_number}#{number}") || !Phony.plausible?(number) || country_code_from_number(number).nil?
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
# we prefer that one.
|
80
|
-
return "#{default_country_number}#{number.gsub(/^0/, '')}"
|
81
|
-
end
|
75
|
+
return "#{default_country_number}#{number}" if Phony.plausible?("#{default_country_number}#{number}") || !Phony.plausible?(number) || country_code_from_number(number).nil?
|
76
|
+
# If the number starts with ONE zero (two might indicate a country code)
|
77
|
+
# and this is a plausible number for the default_country
|
78
|
+
# we prefer that one.
|
79
|
+
return "#{default_country_number}#{number.gsub(/^0/, '')}" if (number =~ /^0[^0]/) && Phony.plausible?("#{default_country_number}#{number.gsub(/^0/, '')}")
|
82
80
|
end
|
83
81
|
# number = "#{default_country_number}#{number}" unless Phony.plausible?(number)
|
84
82
|
# Just return the number unchanged
|
@@ -97,7 +95,7 @@ module PhonyRails
|
|
97
95
|
# Wrapper for Phony.plausible?. Takes the same options as #normalize_number.
|
98
96
|
# NB: This method calls #normalize_number and passes _options_ directly to that method.
|
99
97
|
def self.plausible_number?(number, options = {})
|
100
|
-
return false if number.
|
98
|
+
return false if number.blank?
|
101
99
|
number = extract_extension(number).first
|
102
100
|
number = normalize_number(number, options)
|
103
101
|
country_number = options[:country_number] || country_number_for(options[:country_code]) ||
|
data/lib/phony_rails/version.rb
CHANGED
data/phony_rails.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
require File.expand_path('../lib/phony_rails/version', __FILE__)
|
3
4
|
|
4
5
|
Gem::Specification.new do |gem|
|
@@ -19,8 +20,8 @@ Gem::Specification.new do |gem|
|
|
19
20
|
gem.post_install_message = 'PhonyRails v0.10.0 changes the way numbers are stored!'
|
20
21
|
gem.post_install_message = "It now adds a '+' to the normalized number when it starts with a country number!"
|
21
22
|
|
22
|
-
gem.
|
23
|
-
gem.
|
23
|
+
gem.add_runtime_dependency 'phony', '~> 2.15'
|
24
|
+
gem.add_runtime_dependency 'activesupport', '>= 3.0'
|
24
25
|
gem.add_development_dependency 'activerecord', '>= 3.0'
|
25
26
|
gem.add_development_dependency 'mongoid', '>= 3.0'
|
26
27
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe PhonyRails do
|
@@ -9,22 +10,23 @@ describe PhonyRails do
|
|
9
10
|
|
10
11
|
describe 'phony_format String extension' do
|
11
12
|
describe 'the phony_formatted method' do
|
12
|
-
it '
|
13
|
+
it 'does not modify the original options Hash' do
|
13
14
|
options = { normalize: :NL, format: :international }
|
14
15
|
'0101234123'.phony_formatted(options)
|
15
16
|
expect(options).to eql(normalize: :NL, format: :international)
|
16
17
|
end
|
17
18
|
|
18
19
|
describe 'with the bang!' do
|
19
|
-
it '
|
20
|
-
|
20
|
+
it 'changes the String using the bang method' do
|
21
|
+
# Mutable String
|
22
|
+
s = +'0101234123' rescue '0101234123' # rubocop:disable Style/RescueModifier
|
21
23
|
expect(s.phony_formatted!(normalize: :NL, format: :international)).to eql('+31 10 123 4123')
|
22
24
|
expect(s).to eql('+31 10 123 4123')
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
28
|
describe 'with strict option' do
|
27
|
-
it '
|
29
|
+
it 'returns nil with non plausible number' do
|
28
30
|
number = '+319090' # not valid
|
29
31
|
expect(Phony.plausible?(number)).to be false
|
30
32
|
expect(number.phony_formatted(strict: true)).to eql(nil)
|
@@ -77,7 +79,7 @@ describe PhonyRails do
|
|
77
79
|
end
|
78
80
|
|
79
81
|
context 'when raise is false (default)' do
|
80
|
-
it '
|
82
|
+
it 'returns original String on exception' do
|
81
83
|
expect('8887716095'.phony_formatted(format: :international)).to eq('8887716095')
|
82
84
|
end
|
83
85
|
end
|
@@ -393,35 +395,35 @@ describe PhonyRails do
|
|
393
395
|
let(:empty_number) { '' }
|
394
396
|
let(:nil_number) { nil }
|
395
397
|
|
396
|
-
it '
|
398
|
+
it 'returns true for a valid number' do
|
397
399
|
is_expected.to be_plausible_number valid_number, country_code: 'US'
|
398
400
|
end
|
399
401
|
|
400
|
-
it '
|
402
|
+
it 'returns false for an invalid number' do
|
401
403
|
is_expected.not_to be_plausible_number invalid_number, country_code: 'US'
|
402
404
|
end
|
403
405
|
|
404
|
-
it '
|
406
|
+
it 'returns true for a normalizable number' do
|
405
407
|
is_expected.to be_plausible_number normalizable_number, country_code: 'US'
|
406
408
|
end
|
407
409
|
|
408
|
-
it '
|
410
|
+
it 'returns false for a valid number with the wrong country code' do
|
409
411
|
is_expected.not_to be_plausible_number normalizable_number, country_code: 'FR'
|
410
412
|
end
|
411
413
|
|
412
|
-
it '
|
414
|
+
it 'returns true for a well formatted valid number' do
|
413
415
|
is_expected.to be_plausible_number formatted_french_number_with_country_code, country_code: 'FR'
|
414
416
|
end
|
415
417
|
|
416
|
-
it '
|
418
|
+
it 'returns false for an empty number' do
|
417
419
|
is_expected.not_to be_plausible_number empty_number, country_code: 'US'
|
418
420
|
end
|
419
421
|
|
420
|
-
it '
|
422
|
+
it 'returns false for a nil number' do
|
421
423
|
is_expected.not_to be_plausible_number nil_number, country_code: 'US'
|
422
424
|
end
|
423
425
|
|
424
|
-
it '
|
426
|
+
it 'returns false when no country code is supplied' do
|
425
427
|
is_expected.not_to be_plausible_number normalizable_number
|
426
428
|
end
|
427
429
|
|
@@ -563,12 +565,12 @@ describe PhonyRails do
|
|
563
565
|
|
564
566
|
describe 'using model#phony_normalized_method' do
|
565
567
|
# Following examples have complete number (with country code!)
|
566
|
-
it '
|
568
|
+
it 'returns a normalized version of an attribute' do
|
567
569
|
model = model_klass.new(phone_attribute: '+31-(0)10-1234123')
|
568
570
|
expect(model.normalized_phone_attribute).to eql('+31101234123')
|
569
571
|
end
|
570
572
|
|
571
|
-
it '
|
573
|
+
it 'returnsa normalized version of a method' do
|
572
574
|
model = model_klass.new(phone_method: '+31-(0)10-1234123')
|
573
575
|
expect(model.normalized_phone_method).to eql('+31101234123')
|
574
576
|
end
|
@@ -641,6 +643,22 @@ describe PhonyRails do
|
|
641
643
|
expect(model.phone_number).to eql(nil)
|
642
644
|
end
|
643
645
|
|
646
|
+
it 'should nilify attribute when it is set to nil' do
|
647
|
+
model = ActiveRecordModel.create!(phone_number: '+31-(0)10-1234123')
|
648
|
+
model.phone_number = nil
|
649
|
+
expect(model).to be_valid
|
650
|
+
expect(model.save).to be(true)
|
651
|
+
expect(model.reload.phone_number).to eql(nil)
|
652
|
+
end
|
653
|
+
|
654
|
+
it 'should empty attribute when it is set to ""' do # Github issue #149
|
655
|
+
model = ActiveRecordModel.create!(phone_number: '+31-(0)10-1234123')
|
656
|
+
model.phone_number = ''
|
657
|
+
expect(model).to be_valid
|
658
|
+
expect(model.save).to be(true)
|
659
|
+
expect(model.reload.phone_number).to eql('')
|
660
|
+
end
|
661
|
+
|
644
662
|
it 'should set a normalized version of an attribute using :as option' do
|
645
663
|
model_klass.phony_normalize :phone_number, as: :phone_number_as_normalized
|
646
664
|
model = model_klass.new(phone_number: '+31-(0)10-1234123')
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
require 'spec_helper'
|
3
4
|
|
4
5
|
#-----------------------------------------------------------------------------------------------------------------------
|
@@ -230,7 +231,7 @@ describe PhonyPlausibleValidator do
|
|
230
231
|
I18n.with_locale(:fr) do
|
231
232
|
@home.phone_number = INVALID_NUMBER
|
232
233
|
@home.valid?
|
233
|
-
expect(@home.errors.messages).to include(phone_number: [
|
234
|
+
expect(@home.errors.messages).to include(phone_number: ['est un numéro invalide'])
|
234
235
|
end
|
235
236
|
end
|
236
237
|
|
@@ -238,7 +239,7 @@ describe PhonyPlausibleValidator do
|
|
238
239
|
I18n.with_locale(:ja) do
|
239
240
|
@home.phone_number = INVALID_NUMBER
|
240
241
|
@home.valid?
|
241
|
-
expect(@home.errors.messages).to include(phone_number: [
|
242
|
+
expect(@home.errors.messages).to include(phone_number: ['は正しい電話番号ではありません'])
|
242
243
|
end
|
243
244
|
end
|
244
245
|
|
@@ -246,7 +247,7 @@ describe PhonyPlausibleValidator do
|
|
246
247
|
I18n.with_locale(:km) do
|
247
248
|
@home.phone_number = INVALID_NUMBER
|
248
249
|
@home.valid?
|
249
|
-
expect(@home.errors.messages).to include(phone_number: [
|
250
|
+
expect(@home.errors.messages).to include(phone_number: ['គឺជាលេខមិនត្រឹមត្រូវ'])
|
250
251
|
end
|
251
252
|
end
|
252
253
|
|
@@ -254,7 +255,7 @@ describe PhonyPlausibleValidator do
|
|
254
255
|
I18n.with_locale(:uk) do
|
255
256
|
@home.phone_number = INVALID_NUMBER
|
256
257
|
@home.valid?
|
257
|
-
expect(@home.errors.messages).to include(phone_number: [
|
258
|
+
expect(@home.errors.messages).to include(phone_number: ['є недійсним номером'])
|
258
259
|
end
|
259
260
|
end
|
260
261
|
|
@@ -262,7 +263,7 @@ describe PhonyPlausibleValidator do
|
|
262
263
|
I18n.with_locale(:ru) do
|
263
264
|
@home.phone_number = INVALID_NUMBER
|
264
265
|
@home.valid?
|
265
|
-
expect(@home.errors.messages).to include(phone_number: [
|
266
|
+
expect(@home.errors.messages).to include(phone_number: ['является недействительным номером'])
|
266
267
|
end
|
267
268
|
end
|
268
269
|
end
|
@@ -323,7 +324,13 @@ describe ActiveModel::Validations::HelperMethods do
|
|
323
324
|
@home = OptionalHelpfulHome.new
|
324
325
|
end
|
325
326
|
|
327
|
+
it 'should validate an nil number' do
|
328
|
+
@home.phone_number = nil
|
329
|
+
expect(@home).to be_valid
|
330
|
+
end
|
331
|
+
|
326
332
|
it 'should validate an empty number' do
|
333
|
+
@home.phone_number = ''
|
327
334
|
expect(@home).to be_valid
|
328
335
|
end
|
329
336
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phony_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joost Hietbrink
|
@@ -14,56 +14,56 @@ dependencies:
|
|
14
14
|
name: phony
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.15'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.15'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activerecord
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mongoid
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
69
|
description: This Gem adds useful methods to your Rails app to validate, display and
|
@@ -74,11 +74,11 @@ executables: []
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
77
|
+
- .gitignore
|
78
|
+
- .rspec
|
79
|
+
- .rubocop.yml
|
80
|
+
- .rubocop_todo.yml
|
81
|
+
- .travis.yml
|
82
82
|
- CHANGELOG.md
|
83
83
|
- Gemfile
|
84
84
|
- Gemfile.lock
|
@@ -117,17 +117,17 @@ require_paths:
|
|
117
117
|
- lib
|
118
118
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- -
|
120
|
+
- - ! '>='
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
|
-
- -
|
125
|
+
- - ! '>='
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.5
|
130
|
+
rubygems_version: 2.4.5
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: This Gem adds useful methods to your Rails app to validate, display and save
|