phonelib 0.10.19 → 0.10.20
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/lib/phonelib/version.rb +1 -1
- metadata +3 -185
- data/spec/benchmark_helper.rb +0 -32
- data/spec/coverage/assets/0.10.0/application.css +0 -799
- data/spec/coverage/assets/0.10.0/application.js +0 -1707
- data/spec/coverage/assets/0.10.0/colorbox/border.png +0 -0
- data/spec/coverage/assets/0.10.0/colorbox/controls.png +0 -0
- data/spec/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
- data/spec/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
- data/spec/coverage/assets/0.10.0/favicon_green.png +0 -0
- data/spec/coverage/assets/0.10.0/favicon_red.png +0 -0
- data/spec/coverage/assets/0.10.0/favicon_yellow.png +0 -0
- data/spec/coverage/assets/0.10.0/loading.gif +0 -0
- data/spec/coverage/assets/0.10.0/magnify.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/coverage/index.html +0 -72
- data/spec/dummy/README.rdoc +0 -261
- data/spec/dummy/Rakefile +0 -8
- data/spec/dummy/app/assets/config/manifest.js +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/javascripts/phones.js +0 -2
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/assets/stylesheets/phones.css +0 -4
- data/spec/dummy/app/assets/stylesheets/scaffold.css +0 -56
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/controllers/phones_controller.rb +0 -98
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/helpers/phones_helper.rb +0 -2
- data/spec/dummy/app/models/phone.rb +0 -22
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/app/views/phones/_form.html.erb +0 -25
- data/spec/dummy/app/views/phones/edit.html.erb +0 -6
- data/spec/dummy/app/views/phones/index.html.erb +0 -25
- data/spec/dummy/app/views/phones/new.html.erb +0 -5
- data/spec/dummy/app/views/phones/show.html.erb +0 -14
- data/spec/dummy/config/application.rb +0 -62
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -39
- data/spec/dummy/config/environments/production.rb +0 -67
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/phonelib.rb +0 -2
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -60
- data/spec/dummy/config/storage.yml +0 -4
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20130121173847_create_phones.rb +0 -9
- data/spec/dummy/db/migrate/20130122075331_add_possible_number_to_phone.rb +0 -5
- data/spec/dummy/db/migrate/20140318165956_add_more_fields_to_phone.rb +0 -6
- data/spec/dummy/db/migrate/20161009182201_add_strict_field_to_phone.rb +0 -5
- data/spec/dummy/db/migrate/20161230181632_add_country_to_phone.rb +0 -5
- data/spec/dummy/db/migrate/20180522050128_add_country_number_to_phone.rb +0 -5
- data/spec/dummy/db/migrate/20180731040557_add_type_mobile_number_to_phone.rb +0 -5
- data/spec/dummy/db/migrate/20181021065112_add_country_specifier_proc_number_to_phone.rb +0 -5
- data/spec/dummy/db/schema.rb +0 -30
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/override_phone_data.dat +0 -0
- data/spec/dummy/log/development.log +0 -219
- data/spec/dummy/log/test.log +0 -5375
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/dummy/spec/controllers/phones_controller_spec.rb +0 -88
- data/spec/dummy/spec/fixtures/phones.yml +0 -65
- data/spec/dummy/spec/spec_helper.rb +0 -35
- data/spec/dummy/spec/unit/phone_spec.rb +0 -122
- data/spec/dummy/tmp/development_secret.txt +0 -1
- data/spec/phonelib_bench.rb +0 -20
- data/spec/phonelib_ips_bench.rb +0 -27
- data/spec/phonelib_memory_bench.rb +0 -29
- data/spec/phonelib_spec.rb +0 -1534
data/spec/dummy/public/404.html
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
-
<style type="text/css">
|
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
-
div.dialog {
|
|
8
|
-
width: 25em;
|
|
9
|
-
padding: 0 4em;
|
|
10
|
-
margin: 4em auto 0 auto;
|
|
11
|
-
border: 1px solid #ccc;
|
|
12
|
-
border-right-color: #999;
|
|
13
|
-
border-bottom-color: #999;
|
|
14
|
-
}
|
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<!-- This file lives in public/404.html -->
|
|
21
|
-
<div class="dialog">
|
|
22
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
|
23
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
|
24
|
-
</div>
|
|
25
|
-
</body>
|
|
26
|
-
</html>
|
data/spec/dummy/public/422.html
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
|
5
|
-
<style type="text/css">
|
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
-
div.dialog {
|
|
8
|
-
width: 25em;
|
|
9
|
-
padding: 0 4em;
|
|
10
|
-
margin: 4em auto 0 auto;
|
|
11
|
-
border: 1px solid #ccc;
|
|
12
|
-
border-right-color: #999;
|
|
13
|
-
border-bottom-color: #999;
|
|
14
|
-
}
|
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<!-- This file lives in public/422.html -->
|
|
21
|
-
<div class="dialog">
|
|
22
|
-
<h1>The change you wanted was rejected.</h1>
|
|
23
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
24
|
-
</div>
|
|
25
|
-
</body>
|
|
26
|
-
</html>
|
data/spec/dummy/public/500.html
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
-
<style type="text/css">
|
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
-
div.dialog {
|
|
8
|
-
width: 25em;
|
|
9
|
-
padding: 0 4em;
|
|
10
|
-
margin: 4em auto 0 auto;
|
|
11
|
-
border: 1px solid #ccc;
|
|
12
|
-
border-right-color: #999;
|
|
13
|
-
border-bottom-color: #999;
|
|
14
|
-
}
|
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<!-- This file lives in public/500.html -->
|
|
21
|
-
<div class="dialog">
|
|
22
|
-
<h1>We're sorry, but something went wrong.</h1>
|
|
23
|
-
</div>
|
|
24
|
-
</body>
|
|
25
|
-
</html>
|
|
File without changes
|
data/spec/dummy/script/rails
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
-
|
|
4
|
-
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
5
|
-
require File.expand_path('../../config/boot', __FILE__)
|
|
6
|
-
require 'rails/commands'
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
|
2
|
-
|
|
3
|
-
describe PhonesController, :type => :controller do
|
|
4
|
-
|
|
5
|
-
before(:all) do
|
|
6
|
-
@phone = phones(:valid_and_possible)
|
|
7
|
-
@phone.save
|
|
8
|
-
Phonelib.default_country = nil
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it 'should get index' do
|
|
12
|
-
get :index
|
|
13
|
-
if Rails::VERSION::MAJOR > 5
|
|
14
|
-
expect(response).to have_http_status(:ok)
|
|
15
|
-
else
|
|
16
|
-
expect(response).to be_success
|
|
17
|
-
end
|
|
18
|
-
expect(assigns(:phones)).not_to be_nil
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'should get new' do
|
|
22
|
-
get :new
|
|
23
|
-
if Rails::VERSION::MAJOR > 5
|
|
24
|
-
expect(response).to have_http_status(:ok)
|
|
25
|
-
else
|
|
26
|
-
expect(response).to be_success
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'should create phone' do
|
|
31
|
-
assert_difference(Phone, :count) do
|
|
32
|
-
if Rails::VERSION::MAJOR > 4
|
|
33
|
-
post :create, params: { phone: { number: @phone.number } }
|
|
34
|
-
else
|
|
35
|
-
post :create, phone: { number: @phone.number }
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
expect(response).to redirect_to(phone_path(assigns(:phone)))
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'should show phone' do
|
|
43
|
-
if Rails::VERSION::MAJOR > 4
|
|
44
|
-
get :show, params: { id: @phone }
|
|
45
|
-
else
|
|
46
|
-
get :show, id: @phone
|
|
47
|
-
end
|
|
48
|
-
if Rails::VERSION::MAJOR > 5
|
|
49
|
-
expect(response).to have_http_status(:ok)
|
|
50
|
-
else
|
|
51
|
-
expect(response).to be_success
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'should get edit' do
|
|
56
|
-
if Rails::VERSION::MAJOR > 4
|
|
57
|
-
get :edit, params: { id: @phone }
|
|
58
|
-
else
|
|
59
|
-
get :edit, id: @phone
|
|
60
|
-
end
|
|
61
|
-
if Rails::VERSION::MAJOR > 5
|
|
62
|
-
expect(response).to have_http_status(:ok)
|
|
63
|
-
else
|
|
64
|
-
expect(response).to be_success
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it 'should update phone' do
|
|
69
|
-
if Rails::VERSION::MAJOR > 4
|
|
70
|
-
put :update, params: { id: @phone, phone: { number: @phone.number } }
|
|
71
|
-
else
|
|
72
|
-
put :update, id: @phone, phone: { number: @phone.number }
|
|
73
|
-
end
|
|
74
|
-
expect(response).to redirect_to(phone_path(assigns(:phone)))
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it 'should destroy phone' do
|
|
78
|
-
assert_difference(Phone, :count, -1) do
|
|
79
|
-
if Rails::VERSION::MAJOR > 4
|
|
80
|
-
delete :destroy, params: { id: @phone }
|
|
81
|
-
else
|
|
82
|
-
delete :destroy, id: @phone
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
expect(response).to redirect_to(phones_path)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
valid_and_possible:
|
|
2
|
-
number: '972542234567'
|
|
3
|
-
country_specifier_proc_number: '972542234567'
|
|
4
|
-
possible_number: '972542234567'
|
|
5
|
-
|
|
6
|
-
wrong:
|
|
7
|
-
number: 'wrong'
|
|
8
|
-
country_specifier_proc_number: '972542234567'
|
|
9
|
-
|
|
10
|
-
only_valid:
|
|
11
|
-
number: '972542234567'
|
|
12
|
-
country_specifier_proc_number: '972542234567'
|
|
13
|
-
|
|
14
|
-
only_possible:
|
|
15
|
-
possible_number: '972542234567'
|
|
16
|
-
country_specifier_proc_number: '972542234567'
|
|
17
|
-
|
|
18
|
-
valid_with_bad_possible:
|
|
19
|
-
number: '972542234567'
|
|
20
|
-
possible_number: 'wrong'
|
|
21
|
-
country_specifier_proc_number: '972542234567'
|
|
22
|
-
|
|
23
|
-
valid_type:
|
|
24
|
-
number: '972542234567'
|
|
25
|
-
type_number: '97221234567'
|
|
26
|
-
country_specifier_proc_number: '972542234567'
|
|
27
|
-
|
|
28
|
-
invalid_type:
|
|
29
|
-
number: '972542234567'
|
|
30
|
-
type_number: '972542234567'
|
|
31
|
-
country_specifier_proc_number: '972542234567'
|
|
32
|
-
|
|
33
|
-
possible_type:
|
|
34
|
-
number: '972542234567'
|
|
35
|
-
possible_type_number: '972542234567'
|
|
36
|
-
country_specifier_proc_number: '972542234567'
|
|
37
|
-
|
|
38
|
-
impossible_type:
|
|
39
|
-
number: '972542234567'
|
|
40
|
-
possible_type_number: '97221234567'
|
|
41
|
-
country_specifier_proc_number: '972542234567'
|
|
42
|
-
|
|
43
|
-
invalid_strict:
|
|
44
|
-
strict_number: '972347'
|
|
45
|
-
country_specifier_proc_number: '972542234567'
|
|
46
|
-
|
|
47
|
-
valid_countries:
|
|
48
|
-
number: '972542234567'
|
|
49
|
-
country_number: '12015551234'
|
|
50
|
-
country_specifier_proc_number: '972542234567'
|
|
51
|
-
|
|
52
|
-
invalid_countries:
|
|
53
|
-
number: '972542234567'
|
|
54
|
-
country_number: '972542234567'
|
|
55
|
-
country_specifier_proc_number: '972542234567'
|
|
56
|
-
|
|
57
|
-
mobile_or_fixed_valid_type:
|
|
58
|
-
number: '972542234567'
|
|
59
|
-
type_mobile_number: '7879238675'
|
|
60
|
-
country_specifier_proc_number: '972542234567'
|
|
61
|
-
|
|
62
|
-
fixed_valid_type:
|
|
63
|
-
number: '972542234567'
|
|
64
|
-
country_specifier_proc_number: '972542234567'
|
|
65
|
-
type_mobile_number: '7171774791'
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
ENV["RAILS_ENV"] ||= 'test'
|
|
2
|
-
|
|
3
|
-
require File.absolute_path("../../config/environment", __FILE__)
|
|
4
|
-
require 'rspec/rails'
|
|
5
|
-
require 'rspec/autorun'
|
|
6
|
-
require 'active_support'
|
|
7
|
-
require 'yaml'
|
|
8
|
-
|
|
9
|
-
# fixtures method definition
|
|
10
|
-
FIXTURES = Dir[File.absolute_path('../fixtures/*.yml', __FILE__)].map do |f|
|
|
11
|
-
File.basename(f)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def method_missing(method, *args)
|
|
15
|
-
if FIXTURES.include? "#{method}.yml"
|
|
16
|
-
file = File.absolute_path("../fixtures/#{method}.yml", __FILE__)
|
|
17
|
-
klass = method.to_s.singularize.capitalize.constantize
|
|
18
|
-
fixtures = HashWithIndifferentAccess.new(YAML.load_file(file))
|
|
19
|
-
klass.new(fixtures[args[0]])
|
|
20
|
-
else
|
|
21
|
-
super
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# assert_difference method definition
|
|
26
|
-
def assert_difference(klass, method, change = nil, &block)
|
|
27
|
-
before = klass.send(method)
|
|
28
|
-
block.call
|
|
29
|
-
after = klass.send(method)
|
|
30
|
-
if change
|
|
31
|
-
expect(after).to eq(before + change)
|
|
32
|
-
else
|
|
33
|
-
expect(after).not_to eq(before)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
|
2
|
-
|
|
3
|
-
describe Phone do
|
|
4
|
-
it 'saves with valid phone' do
|
|
5
|
-
phone = Phone.new(number: '972542234567')
|
|
6
|
-
|
|
7
|
-
expect(phone.save).to be true
|
|
8
|
-
expect(phone.errors.empty?).to be true
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "can't save with invalid phone" do
|
|
12
|
-
phone = Phone.new(number: 'wrong')
|
|
13
|
-
|
|
14
|
-
expect(phone.save).to be false
|
|
15
|
-
expect(phone.errors.any?).to be true
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "is invalid when phone is invalid and country is specified" do
|
|
19
|
-
phone = Phone.new(number: '1305558858', country: 'us')
|
|
20
|
-
|
|
21
|
-
expect(phone.valid?).to be false
|
|
22
|
-
expect(phone.errors.any?).to be true
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "is valid when phone is valid and country is specified" do
|
|
26
|
-
phone = Phone.new(number: '3175082248', country: 'us')
|
|
27
|
-
|
|
28
|
-
expect(phone.valid?).to be true
|
|
29
|
-
expect(phone.errors.any?).to be false
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'passes when valid' do
|
|
33
|
-
phone = phones(:valid_and_possible)
|
|
34
|
-
expect(phone.save).to be true
|
|
35
|
-
expect(phone.errors.empty?).to be true
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it 'fails with wrong' do
|
|
39
|
-
phone = phones(:wrong)
|
|
40
|
-
expect(phone.save).to be false
|
|
41
|
-
expect(phone.errors.any?).to be true
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'passes with allow blank' do
|
|
45
|
-
phone = phones(:only_valid)
|
|
46
|
-
expect(phone.save).to be true
|
|
47
|
-
expect(phone.errors.empty?).to be true
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'fails without allow blank' do
|
|
51
|
-
phone = phones(:only_possible)
|
|
52
|
-
expect(phone.save).to be false
|
|
53
|
-
expect(phone.errors.any?).to be true
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it 'fails when wrong possible and not blank' do
|
|
57
|
-
phone = phones(:valid_with_bad_possible)
|
|
58
|
-
expect(phone.save).to be false
|
|
59
|
-
expect(phone.errors.any?).to be true
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it 'should pass with valid type' do
|
|
63
|
-
phone = phones(:valid_type)
|
|
64
|
-
expect(phone.save).to be true
|
|
65
|
-
expect(phone.errors.empty?).to be true
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it 'should fail with invalid type' do
|
|
69
|
-
phone = phones(:invalid_type)
|
|
70
|
-
expect(phone.save).to be false
|
|
71
|
-
expect(phone.errors.any?).to be true
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it 'should pass with possible type' do
|
|
75
|
-
phone = phones(:possible_type)
|
|
76
|
-
expect(phone.save).to be true
|
|
77
|
-
expect(phone.errors.empty?).to be true
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it 'should fail with impossible type' do
|
|
81
|
-
phone = phones(:impossible_type)
|
|
82
|
-
expect(phone.save).to be false
|
|
83
|
-
expect(phone.errors.any?).to be true
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it 'should raise ActiveModel::StrictValidationFailed on strict fields' do
|
|
87
|
-
if Rails::VERSION::STRING >= '3.2'
|
|
88
|
-
phone = phones(:invalid_strict)
|
|
89
|
-
expect{phone.valid?}.to raise_error(ActiveModel::StrictValidationFailed)
|
|
90
|
-
else
|
|
91
|
-
# this test is suitable for rails >= 3.2 only
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it 'should save with valid country phone' do
|
|
96
|
-
phone = phones(:valid_countries)
|
|
97
|
-
expect(phone.save).to be true
|
|
98
|
-
expect(phone.errors.any?).to be false
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
it 'should fail with impossible type' do
|
|
102
|
-
phone = phones(:invalid_countries)
|
|
103
|
-
expect(phone.save).to be false
|
|
104
|
-
expect(phone.errors.any?).to be true
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
it 'should pass with mobile valid type' do
|
|
108
|
-
Phonelib.default_country = 'IN'
|
|
109
|
-
phone = phones(:mobile_or_fixed_valid_type)
|
|
110
|
-
expect(phone.save).to be true
|
|
111
|
-
Phonelib.default_country = nil
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
it 'should fail with fixed valid number but mobile type defined' do
|
|
115
|
-
Phonelib.default_country = 'IN'
|
|
116
|
-
phone = phones(:fixed_valid_type)
|
|
117
|
-
expect(phone.save).to be false
|
|
118
|
-
expect(phone.errors.any?).to be true
|
|
119
|
-
Phonelib.default_country = nil
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
81c08ac8a862e5efd66f239dcf3673761c377a4c6e2d0ed1f75f5a332df949fc195aba8ff128c9886078f53c8720763764862a4f641ec830bc3f14a0a0e79057
|
data/spec/phonelib_bench.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'benchmark_helper'
|
|
2
|
-
|
|
3
|
-
RUNS = Integer(ENV['RUNS'] || 10)
|
|
4
|
-
|
|
5
|
-
def run_benchmark(test_numbers)
|
|
6
|
-
start = Time.now
|
|
7
|
-
2.times do
|
|
8
|
-
test_numbers.each do |country, numbers|
|
|
9
|
-
numbers.each do |number|
|
|
10
|
-
Phonelib.parse(number, country)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
eta = Time.now - start
|
|
15
|
-
puts " => parsing rate = #{eta / 100.0} for cycle; #{eta} for 100 cycles"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
RUNS.times do
|
|
19
|
-
run_benchmark(test_numbers)
|
|
20
|
-
end
|
data/spec/phonelib_ips_bench.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'benchmark_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Phonelib, :benchmark do
|
|
4
|
-
it 'parsing numbers' do
|
|
5
|
-
Benchmark.ips do |x|
|
|
6
|
-
x.config(time: 5, warmup: 2)
|
|
7
|
-
|
|
8
|
-
x.report('known country') do
|
|
9
|
-
test_numbers.each do |country, numbers|
|
|
10
|
-
numbers.each do |number|
|
|
11
|
-
Phonelib.parse(number, country)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
x.report('unknown country') do
|
|
17
|
-
test_numbers.each do |country, numbers|
|
|
18
|
-
numbers.each do |number|
|
|
19
|
-
Phonelib.parse(number)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
x.compare!
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require 'benchmark_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Phonelib, :benchmark do
|
|
4
|
-
before do
|
|
5
|
-
Phonelib.parse(test_numbers.each_value.first)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it 'parsing numbers' do
|
|
9
|
-
Benchmark.memory do |x|
|
|
10
|
-
x.report('known country') do
|
|
11
|
-
test_numbers.each do |country, numbers|
|
|
12
|
-
numbers.each do |number|
|
|
13
|
-
Phonelib.parse(number, country)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
x.report('unknown country') do
|
|
19
|
-
test_numbers.each do |country, numbers|
|
|
20
|
-
numbers.each do |number|
|
|
21
|
-
Phonelib.parse(number)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
x.compare!
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|