mobile-subscriber 0.0.1.alpha3 → 0.0.1.alpha4
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/mobile-subscriber.rb +2 -1
- data/lib/mobile_subscriber/detection/from_msisdn_http_request_header.rb +97 -7
- data/lib/mobile_subscriber/detection/from_x_nokia_msisdn_http_request_header.rb +3 -1
- data/lib/mobile_subscriber/detection/from_x_up_calling_line_id_http_request_header.rb +3 -2
- data/lib/mobile_subscriber/detection/from_x_up_ch_msisdn_http_request_header.rb +7 -5
- data/lib/mobile_subscriber/detection/from_x_up_subno_http_request_header.rb +48 -0
- data/lib/mobile_subscriber/isdn.rb +3 -2
- data/lib/mobile_subscriber/version.rb +1 -1
- data/spec/detection/from_msisdn_http_request_header_spec.rb +48 -0
- data/spec/detection/from_x_nokia_msisdn_http_request_header_spec.rb +35 -0
- data/spec/factories/requests.rb +34 -3
- data/spec/models/isdn_spec.rb +39 -6
- data/spec/shared_examples/of_msisdn_detection_from_http_request.rb +84 -0
- data/spec/spec_helper.rb +1 -3
- metadata +8 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae7f7ff2ab99759a49beef779711360052c0cc85
|
4
|
+
data.tar.gz: daa60ed245a79d3161c29f142244866c4afb2016
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4781b295edb467703313ed06d9167998d457a5418445b52a31915563eea46e53561a0ec144cff37eaceba3ab0b264eae875d0445579ef644a87b0cc0b6747b67
|
7
|
+
data.tar.gz: f237cdbbc072af9ad6f4389fbcab25052982041727086a4a422035317b29842e43393fa33e08988a636e9598d2135b03123fb668afc066b134c5c60d44c2a357
|
data/lib/mobile-subscriber.rb
CHANGED
@@ -10,7 +10,8 @@ module MobileSubscriber
|
|
10
10
|
extend ActiveSupport::Autoload
|
11
11
|
autoload :FromMsisdnHttpRequestHeader
|
12
12
|
autoload :FromXNokiaMsisdnHttpRequestHeader
|
13
|
-
autoload :FromXUpChMsisdnHttpRequestHeader
|
14
13
|
autoload :FromXUpCallingLineIdHttpRequestHeader
|
14
|
+
autoload :FromXUpChMsisdnHttpRequestHeader
|
15
|
+
autoload :FromXUpSubnoHttpRequestHeader
|
15
16
|
end
|
16
17
|
end
|
@@ -1,9 +1,21 @@
|
|
1
|
+
require 'mobile_subscriber/dictionaries/dialing_and_country_codes'
|
2
|
+
|
1
3
|
module MobileSubscriber
|
2
4
|
module Detection
|
3
5
|
|
4
|
-
# Módulo que provee métodos de
|
6
|
+
# Módulo que provee métodos de detección y validacion para MSISDN por el
|
5
7
|
# header de HTTP 'Msisdn':
|
6
|
-
#
|
8
|
+
# - Claro Brasil
|
9
|
+
# - Claro Chile
|
10
|
+
# - Claro Colombia
|
11
|
+
# - Claro Costa Rica
|
12
|
+
# - Claro República Dominicana
|
13
|
+
# - Claro Ecuador
|
14
|
+
# - Claro El Salvador
|
15
|
+
# - Claro Guatemala
|
16
|
+
# - Claro Nicaragua
|
17
|
+
# - Claro Panamá
|
18
|
+
# - Claro Paraguay
|
7
19
|
module FromMsisdnHttpRequestHeader
|
8
20
|
|
9
21
|
extend ActiveSupport::Concern
|
@@ -15,8 +27,8 @@ module MobileSubscriber
|
|
15
27
|
|
16
28
|
isdn_attributes = nil
|
17
29
|
|
18
|
-
isdn_attributes = if msisdn = request.env[header_env_key] and msisdn.length >= 8
|
19
|
-
|
30
|
+
isdn_attributes = if msisdn = request.env[header_env_key] and msisdn.strip.length >= 8
|
31
|
+
msisdn.strip!
|
20
32
|
detection_cues = {
|
21
33
|
remote_ip: request.env["REMOTE_ADDR"],
|
22
34
|
http_request_headers: { 'Msisdn' => msisdn }
|
@@ -28,12 +40,90 @@ module MobileSubscriber
|
|
28
40
|
# TODO: Validar por IP, etc.
|
29
41
|
case country_code
|
30
42
|
when 'BR'
|
31
|
-
#
|
43
|
+
# Claro Brasil
|
44
|
+
# TODO: Determinar correctamente el MNC (05, 38)
|
32
45
|
{
|
33
46
|
id: msisdn,
|
34
47
|
mobile_country_code: "724",
|
35
|
-
mobile_network_code: "
|
36
|
-
}
|
48
|
+
mobile_network_code: "05"
|
49
|
+
}.merge(detection_cues: detection_cues)
|
50
|
+
when 'CL'
|
51
|
+
# Claro Chile
|
52
|
+
{
|
53
|
+
id: msisdn,
|
54
|
+
mobile_country_code: "730",
|
55
|
+
mobile_network_code: "03"
|
56
|
+
}.merge(detection_cues: detection_cues)
|
57
|
+
when 'CO'
|
58
|
+
# Claro Colombia
|
59
|
+
{
|
60
|
+
id: msisdn,
|
61
|
+
mobile_country_code: "732",
|
62
|
+
mobile_network_code: "101"
|
63
|
+
}.merge(detection_cues: detection_cues)
|
64
|
+
when 'CR'
|
65
|
+
# Claro Costa Rica
|
66
|
+
{
|
67
|
+
id: msisdn,
|
68
|
+
mobile_country_code: "712",
|
69
|
+
mobile_network_code: "03"
|
70
|
+
}.merge(detection_cues: detection_cues)
|
71
|
+
when 'DO'
|
72
|
+
# Claro Dominicana:
|
73
|
+
{
|
74
|
+
id: msisdn,
|
75
|
+
mobile_country_code: "370",
|
76
|
+
mobile_network_code: "02"
|
77
|
+
}.merge(detection_cues: detection_cues)
|
78
|
+
when 'EC'
|
79
|
+
# Claro Ecuador:
|
80
|
+
{
|
81
|
+
id: msisdn,
|
82
|
+
mobile_country_code: "740",
|
83
|
+
mobile_network_code: "01"
|
84
|
+
}.merge(detection_cues: detection_cues)
|
85
|
+
when 'SV'
|
86
|
+
# Claro El Salvador:
|
87
|
+
{
|
88
|
+
id: msisdn,
|
89
|
+
mobile_country_code: "706",
|
90
|
+
mobile_network_code: "01"
|
91
|
+
}.merge(detection_cues: detection_cues)
|
92
|
+
when 'GT'
|
93
|
+
# Claro Guatemala:
|
94
|
+
{
|
95
|
+
id: msisdn,
|
96
|
+
mobile_country_code: "704",
|
97
|
+
mobile_network_code: "01"
|
98
|
+
}.merge(detection_cues: detection_cues)
|
99
|
+
when 'HN'
|
100
|
+
# Claro Honduras:
|
101
|
+
{
|
102
|
+
id: msisdn,
|
103
|
+
mobile_country_code: "708",
|
104
|
+
mobile_network_code: "001"
|
105
|
+
}.merge(detection_cues: detection_cues)
|
106
|
+
when 'NI'
|
107
|
+
# Claro Nicaragua:
|
108
|
+
{
|
109
|
+
id: msisdn,
|
110
|
+
mobile_country_code: "710",
|
111
|
+
mobile_network_code: "21"
|
112
|
+
}.merge(detection_cues: detection_cues)
|
113
|
+
when 'PA'
|
114
|
+
# Claro Panamá:
|
115
|
+
{
|
116
|
+
id: msisdn,
|
117
|
+
mobile_country_code: "714",
|
118
|
+
mobile_network_code: "03"
|
119
|
+
}.merge(detection_cues: detection_cues)
|
120
|
+
when 'PY'
|
121
|
+
# Claro Paraguay:
|
122
|
+
{
|
123
|
+
id: msisdn,
|
124
|
+
mobile_country_code: "744",
|
125
|
+
mobile_network_code: "02"
|
126
|
+
}.merge(detection_cues: detection_cues)
|
37
127
|
end
|
38
128
|
|
39
129
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'mobile_subscriber/dictionaries/dialing_and_country_codes'
|
1
2
|
module MobileSubscriber
|
2
3
|
module Detection
|
3
4
|
|
@@ -14,7 +15,8 @@ module MobileSubscriber
|
|
14
15
|
header_name = 'X-Nokia-Msisdn'
|
15
16
|
header_env_key = "HTTP_#{header_name.gsub('-','_').upcase}"
|
16
17
|
|
17
|
-
isdn_attributes = if msisdn = request.env[header_env_key] and msisdn.length >= 8
|
18
|
+
isdn_attributes = if msisdn = request.env[header_env_key] and msisdn.strip.length >= 8
|
19
|
+
msisdn.strip!
|
18
20
|
detection_cues = {
|
19
21
|
remote_ip: request.env["REMOTE_ADDR"],
|
20
22
|
http_request_headers: { 'X-Nokia-Msisdn' => msisdn }
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'mobile_subscriber/dictionaries/dialing_and_country_codes'
|
1
2
|
module MobileSubscriber
|
2
3
|
module Detection
|
3
4
|
|
@@ -19,8 +20,8 @@ module MobileSubscriber
|
|
19
20
|
header_name = 'X-Up-Calling-Line-Id'
|
20
21
|
header_env_key = "HTTP_#{header_name.gsub('-','_').upcase}"
|
21
22
|
|
22
|
-
isdn_attributes = if msisdn = request.env[header_env_key] and msisdn.length >= 8
|
23
|
-
|
23
|
+
isdn_attributes = if msisdn = request.env[header_env_key] and msisdn.strip.length >= 8
|
24
|
+
msisdn.strip!
|
24
25
|
detection_cues = {
|
25
26
|
remote_ip: request.env["REMOTE_ADDR"],
|
26
27
|
http_request_headers: { header_name => msisdn }
|
@@ -1,8 +1,9 @@
|
|
1
|
+
require 'mobile_subscriber/dictionaries/dialing_and_country_codes'
|
1
2
|
module MobileSubscriber
|
2
3
|
module Detection
|
3
4
|
|
4
5
|
# Módulo que provee métodos de deteccion y validacion para MSISDN's de:
|
5
|
-
# -
|
6
|
+
# - Vivo Brasil
|
6
7
|
module FromXUpChMsisdnHttpRequestHeader
|
7
8
|
|
8
9
|
extend ActiveSupport::Concern
|
@@ -12,8 +13,8 @@ module MobileSubscriber
|
|
12
13
|
header_name = 'X-Up-Ch-Msisdn'
|
13
14
|
header_env_key = "HTTP_#{header_name.gsub('-','_').upcase}"
|
14
15
|
|
15
|
-
isdn_attributes = if msisdn = request.env[header_env_key] and msisdn.length >= 8
|
16
|
-
|
16
|
+
isdn_attributes = if msisdn = request.env[header_env_key] and msisdn.strip.length >= 8
|
17
|
+
msisdn.strip!
|
17
18
|
detection_cues = {
|
18
19
|
remote_ip: request.env["REMOTE_ADDR"],
|
19
20
|
http_request_headers: { 'X-Up-Ch-Msisdn' => msisdn }
|
@@ -25,11 +26,12 @@ module MobileSubscriber
|
|
25
26
|
# TODO: Validar por IP, etc.
|
26
27
|
case country_code
|
27
28
|
when 'BR'
|
28
|
-
#
|
29
|
+
# Vivo:
|
30
|
+
# TODO: Determinar el MNC correcto (06, 10, 11, 23)
|
29
31
|
{
|
30
32
|
id: msisdn,
|
31
33
|
mobile_country_code: "724",
|
32
|
-
mobile_network_code: "
|
34
|
+
mobile_network_code: "06"
|
33
35
|
}.merge(detection_cues: detection_cues)
|
34
36
|
end
|
35
37
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'mobile_subscriber/dictionaries/dialing_and_country_codes'
|
2
|
+
module MobileSubscriber
|
3
|
+
module Detection
|
4
|
+
|
5
|
+
# Módulo que provee métodos de deteccion y validacion para MSISDN por el
|
6
|
+
# header de HTTP 'Msisdn':
|
7
|
+
# - Comcel Colombia
|
8
|
+
module FromXUpSubnoHttpRequestHeader
|
9
|
+
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def extract_from_x_up_subno_http_request_header(request)
|
14
|
+
header_name = 'X-Up-Subno'
|
15
|
+
header_env_key = "HTTP_#{header_name.gsub('-','_').upcase}"
|
16
|
+
|
17
|
+
isdn_attributes = nil
|
18
|
+
|
19
|
+
isdn_attributes = if msisdn = request.env[header_env_key] and msisdn.strip.length >= 8
|
20
|
+
msisdn.strip!
|
21
|
+
detection_cues = {
|
22
|
+
remote_ip: request.env["REMOTE_ADDR"],
|
23
|
+
http_request_headers: { header_name => msisdn }
|
24
|
+
}
|
25
|
+
|
26
|
+
country_code = MobileSubscriber::DIALING_COUNTRY_CODES[msisdn[0,2]]
|
27
|
+
|
28
|
+
# Determinar la procedencia del MSISDN
|
29
|
+
# TODO: Validar por IP, etc.
|
30
|
+
case country_code
|
31
|
+
when 'CO'
|
32
|
+
# Comcel Colombia
|
33
|
+
{
|
34
|
+
id: msisdn,
|
35
|
+
mobile_country_code: "732",
|
36
|
+
mobile_network_code: "101"
|
37
|
+
}.merge(detection_cues: detection_cues)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
isdn_attributes
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -11,8 +11,9 @@ module MobileSubscriber
|
|
11
11
|
|
12
12
|
include MobileSubscriber::Detection::FromMsisdnHttpRequestHeader
|
13
13
|
include MobileSubscriber::Detection::FromXNokiaMsisdnHttpRequestHeader
|
14
|
-
include MobileSubscriber::Detection::FromXUpChMsisdnHttpRequestHeader
|
15
14
|
include MobileSubscriber::Detection::FromXUpCallingLineIdHttpRequestHeader
|
15
|
+
include MobileSubscriber::Detection::FromXUpChMsisdnHttpRequestHeader
|
16
|
+
include MobileSubscriber::Detection::FromXUpSubnoHttpRequestHeader
|
16
17
|
|
17
18
|
def initialize(attributes={})
|
18
19
|
@id = attributes.delete :id
|
@@ -60,7 +61,7 @@ module MobileSubscriber
|
|
60
61
|
def self.new_from_request(request)
|
61
62
|
detected_attributes = self.methods.select do |x|
|
62
63
|
x.to_s =~ /\Aextract_from_(\w+)_http_request_header\z/i
|
63
|
-
end.reduce(nil) do |attrs, detection_method|
|
64
|
+
end.sort.reduce(nil) do |attrs, detection_method|
|
64
65
|
attrs = self.send detection_method, request unless attrs.present?
|
65
66
|
attrs
|
66
67
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe MobileSubscriber::Detection::FromMsisdnHttpRequestHeader do
|
4
|
+
|
5
|
+
include described_class::ClassMethods
|
6
|
+
|
7
|
+
let :test_request do
|
8
|
+
build :mobile_request_from_claro_brasil
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "the returned object of self.extract_from_msisdn_http_request_header" do
|
12
|
+
|
13
|
+
subject do
|
14
|
+
extract_from_msisdn_http_request_header test_request
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when given a request made from Claro Brasil" do
|
18
|
+
let(:test_request) { build :mobile_request_from_claro_brasil }
|
19
|
+
|
20
|
+
include_examples "of detection of msisdn from a valid brazilian mobile network http request"
|
21
|
+
|
22
|
+
it "has a :mobile_network_code value of '05' or '38'" do
|
23
|
+
expect(subject[:mobile_network_code]).to match /05|38/i
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when given a request made from Claro Chile" do
|
28
|
+
let(:test_request) { build :mobile_request_from_claro_chile }
|
29
|
+
|
30
|
+
include_examples "of detection of msisdn from a valid chilean mobile network http request"
|
31
|
+
|
32
|
+
it "has a :mobile_network_code value of '03'" do
|
33
|
+
expect(subject[:mobile_network_code]).to eq '03'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when given a request made from Claro Colomobia" do
|
38
|
+
let(:test_request) { build :mobile_request_from_claro_colombia }
|
39
|
+
|
40
|
+
include_examples "of detection of msisdn from a valid colombian mobile network http request"
|
41
|
+
|
42
|
+
it "has a :mobile_network_code value of '101'" do
|
43
|
+
expect(subject[:mobile_network_code]).to eq '101'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe MobileSubscriber::Detection::FromXNokiaMsisdnHttpRequestHeader do
|
4
|
+
|
5
|
+
include described_class::ClassMethods
|
6
|
+
|
7
|
+
describe "the returned object of self.extract_from_msisdn_http_request_header" do
|
8
|
+
|
9
|
+
subject do
|
10
|
+
extract_from_x_nokia_msisdn_http_request_header test_request
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when given a request made from Telcel México" do
|
14
|
+
let(:test_request) { build :mobile_request_from_telcel_mexico }
|
15
|
+
|
16
|
+
include_examples "of detection of msisdn from a valid mexican mobile network http request"
|
17
|
+
|
18
|
+
it "has a :mobile_network_code value of '020'" do
|
19
|
+
expect(subject[:mobile_network_code]).to eq '020'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when given a request made from Claro Argentina" do
|
24
|
+
let(:test_request) { build :mobile_request_from_claro_argentina }
|
25
|
+
|
26
|
+
include_examples "of detection of msisdn from a valid argentinian mobile network http request"
|
27
|
+
|
28
|
+
# TODO: Bad test... we need to test for each network code, if it can be determined:
|
29
|
+
it "has a :mobile_network_code value of '310', '320', or '330'" do
|
30
|
+
expect(subject[:mobile_network_code]).to match /310|320|330/
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/spec/factories/requests.rb
CHANGED
@@ -49,9 +49,30 @@ FactoryGirl.define do
|
|
49
49
|
factory :mobile_request_from_claro_brasil do
|
50
50
|
initialize_with do
|
51
51
|
new build(:common_mobile_request_env).merge(
|
52
|
-
"REMOTE_ADDR"
|
53
|
-
"REMOTE_HOST"
|
54
|
-
"
|
52
|
+
"REMOTE_ADDR" => "201.23.176.202",
|
53
|
+
"REMOTE_HOST" => "201.23.176.202",
|
54
|
+
"HTTP_MSISDN" => "5500000000000"
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# http://ns.myip.ms/view/ip_owners/181034/Claro_Chile_S_a.html
|
60
|
+
factory :mobile_request_from_claro_chile do
|
61
|
+
initialize_with do
|
62
|
+
new build(:common_mobile_request_env).merge(
|
63
|
+
"REMOTE_ADDR" => "191.116.39.114",
|
64
|
+
"REMOTE_HOST" => "191.116.39.114",
|
65
|
+
"HTTP_MSISDN" => "56024445202"
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
factory :mobile_request_from_claro_colombia do
|
71
|
+
initialize_with do
|
72
|
+
new build(:common_mobile_request_env).merge(
|
73
|
+
"REMOTE_ADDR" => "200.26.137.100",
|
74
|
+
"REMOTE_HOST" => "200.26.137.100",
|
75
|
+
"HTTP_MSISDN" => "57000000000"
|
55
76
|
)
|
56
77
|
end
|
57
78
|
end
|
@@ -67,6 +88,16 @@ FactoryGirl.define do
|
|
67
88
|
end
|
68
89
|
end
|
69
90
|
|
91
|
+
factory :mobile_request_from_vivo_brasil do
|
92
|
+
initialize_with do
|
93
|
+
new build(:common_mobile_request_env).merge(
|
94
|
+
"REMOTE_ADDR" => "187.26.59.4",
|
95
|
+
"REMOTE_HOST" => "187.26.59.4",
|
96
|
+
"HTTP_X_UP_CH_MSISDN" => "5500000000000"
|
97
|
+
)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
70
101
|
|
71
102
|
end
|
72
103
|
end
|
data/spec/models/isdn_spec.rb
CHANGED
@@ -109,6 +109,24 @@ describe MobileSubscriber::ISDN do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
shared_examples "of detection from a request made from a chilean mobile network" do
|
113
|
+
it "responds to #id with a string starting with '56'" do
|
114
|
+
expect(subject.id).to match /\A56/
|
115
|
+
end
|
116
|
+
|
117
|
+
it "responds to #mobile_country_code with '730'" do
|
118
|
+
expect(subject.mobile_country_code).to eq '730'
|
119
|
+
end
|
120
|
+
|
121
|
+
it "responds to #dialing_code with '56'" do
|
122
|
+
expect(subject.dialing_code).to eq '56'
|
123
|
+
end
|
124
|
+
|
125
|
+
it "responds to #iso_3166_country_code with 'CL'" do
|
126
|
+
expect(subject.iso_3166_country_code).to eq 'CL'
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
112
130
|
shared_examples "of detection from a request made from a peruvian mobile network" do
|
113
131
|
it "responds to #id with a string starting with '51'" do
|
114
132
|
expect(subject.id).to match /\A51/
|
@@ -168,6 +186,22 @@ describe MobileSubscriber::ISDN do
|
|
168
186
|
|
169
187
|
end
|
170
188
|
|
189
|
+
context "from a request made from Claro Perú" do
|
190
|
+
|
191
|
+
subject do
|
192
|
+
described_class.new_from_request(build :mobile_request_from_claro_peru)
|
193
|
+
end
|
194
|
+
|
195
|
+
include_examples "of detection from a valid request"
|
196
|
+
include_examples "of detection from a request made from a peruvian mobile network"
|
197
|
+
include_examples "of detection from a request made from a Claro network"
|
198
|
+
|
199
|
+
it "responds to #mobile_network_operator with 'América Móvil Perú'" do
|
200
|
+
expect(subject.mobile_network_operator).to eq 'América Móvil Perú'
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
171
205
|
context "from a request made from Claro Brasil" do
|
172
206
|
|
173
207
|
subject do
|
@@ -183,20 +217,19 @@ describe MobileSubscriber::ISDN do
|
|
183
217
|
end
|
184
218
|
end
|
185
219
|
|
186
|
-
context "from a request made from Claro
|
220
|
+
context "from a request made from Claro Chile" do
|
187
221
|
|
188
222
|
subject do
|
189
|
-
described_class.new_from_request(build :
|
223
|
+
described_class.new_from_request(build :mobile_request_from_claro_chile)
|
190
224
|
end
|
191
225
|
|
192
226
|
include_examples "of detection from a valid request"
|
193
|
-
include_examples "of detection from a request made from a
|
227
|
+
include_examples "of detection from a request made from a chilean mobile network"
|
194
228
|
include_examples "of detection from a request made from a Claro network"
|
195
229
|
|
196
|
-
it "responds to #mobile_network_operator with '
|
197
|
-
expect(subject.mobile_network_operator).to eq '
|
230
|
+
it "responds to #mobile_network_operator with 'Claro Chile S.A.'" do
|
231
|
+
expect(subject.mobile_network_operator).to eq 'Claro Chile S.A.'
|
198
232
|
end
|
199
|
-
|
200
233
|
end
|
201
234
|
|
202
235
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
shared_examples "of detection of msisdn from a valid mobile network http request" do
|
4
|
+
it "is not nil" do
|
5
|
+
expect(subject).not_to be_nil
|
6
|
+
end
|
7
|
+
it "is not blank" do
|
8
|
+
expect(subject).not_to be_blank
|
9
|
+
end
|
10
|
+
|
11
|
+
it "has an :id key" do
|
12
|
+
expect(subject).to have_key :id
|
13
|
+
end
|
14
|
+
it "has a non-blank :id value" do
|
15
|
+
expect(subject[:id]).not_to be_blank
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has an :mobile_country_code key" do
|
19
|
+
expect(subject).to have_key :mobile_country_code
|
20
|
+
end
|
21
|
+
it "has a non-blank :mobile_country_code value" do
|
22
|
+
expect(subject[:mobile_country_code]).not_to be_blank
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has an :mobile_network_code key" do
|
26
|
+
expect(subject).to have_key :mobile_network_code
|
27
|
+
end
|
28
|
+
it "has a non-blank :mobile_network_code value" do
|
29
|
+
expect(subject[:mobile_network_code]).not_to be_blank
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
shared_examples "of detection of msisdn from a valid argentinian mobile network http request" do
|
34
|
+
include_examples "of detection of msisdn from a valid mobile network http request"
|
35
|
+
it "has an :id value that starts with '54'" do
|
36
|
+
expect(subject[:id]).to match /\A54/
|
37
|
+
end
|
38
|
+
it "has a :mobile_country_code value of '722'" do
|
39
|
+
expect(subject[:mobile_country_code]).to eq '722'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
shared_examples "of detection of msisdn from a valid mexican mobile network http request" do
|
44
|
+
include_examples "of detection of msisdn from a valid mobile network http request"
|
45
|
+
it "has an :id value that starts with '52'" do
|
46
|
+
expect(subject[:id]).to match /\A52/
|
47
|
+
end
|
48
|
+
it "has a :mobile_country_code value of '334'" do
|
49
|
+
expect(subject[:mobile_country_code]).to eq '334'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
shared_examples "of detection of msisdn from a valid brazilian mobile network http request" do
|
54
|
+
include_examples "of detection of msisdn from a valid mobile network http request"
|
55
|
+
it "has an :id value that starts with '55'" do
|
56
|
+
expect(subject[:id]).to match /\A55/
|
57
|
+
end
|
58
|
+
|
59
|
+
it "has a :mobile_country_code value of '724'" do
|
60
|
+
expect(subject[:mobile_country_code]).to eq '724'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
shared_examples "of detection of msisdn from a valid chilean mobile network http request" do
|
65
|
+
include_examples "of detection of msisdn from a valid mobile network http request"
|
66
|
+
it "has an :id value that starts with '56'" do
|
67
|
+
expect(subject[:id]).to match /\A56/
|
68
|
+
end
|
69
|
+
|
70
|
+
it "has a :mobile_country_code value of '730'" do
|
71
|
+
expect(subject[:mobile_country_code]).to eq '730'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
shared_examples "of detection of msisdn from a valid colombian mobile network http request" do
|
76
|
+
include_examples "of detection of msisdn from a valid mobile network http request"
|
77
|
+
it "has an :id value that starts with '57'" do
|
78
|
+
expect(subject[:id]).to match /\A57/
|
79
|
+
end
|
80
|
+
|
81
|
+
it "has a :mobile_country_code value of '732'" do
|
82
|
+
expect(subject[:mobile_country_code]).to eq '732'
|
83
|
+
end
|
84
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -67,13 +67,11 @@ RSpec.configure do |config|
|
|
67
67
|
|
68
68
|
config.raise_errors_for_deprecations!
|
69
69
|
|
70
|
-
|
71
|
-
|
72
70
|
# Allow to use the FactoryGirl methods (build, create, build_stubbed)
|
73
71
|
# directly on specs, instead of prefacing them with "FactoryGirl":
|
74
72
|
config.include FactoryGirl::Syntax::Methods
|
75
73
|
|
76
|
-
|
77
74
|
Dir["spec/factories/*.rb"].each { |f| load f }
|
75
|
+
Dir["spec/shared_examples/*.rb"].each { |f| load f }
|
78
76
|
|
79
77
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobile-subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.alpha4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Quintanilla
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- lib/mobile_subscriber/detection/from_x_nokia_msisdn_http_request_header.rb
|
118
118
|
- lib/mobile_subscriber/detection/from_x_up_calling_line_id_http_request_header.rb
|
119
119
|
- lib/mobile_subscriber/detection/from_x_up_ch_msisdn_http_request_header.rb
|
120
|
+
- lib/mobile_subscriber/detection/from_x_up_subno_http_request_header.rb
|
120
121
|
- lib/mobile_subscriber/dictionaries/dialing_and_country_codes.rb
|
121
122
|
- lib/mobile_subscriber/dictionaries/mobile_and_iso_country_codes.rb
|
122
123
|
- lib/mobile_subscriber/dictionaries/operator_data.rb
|
@@ -124,9 +125,12 @@ files:
|
|
124
125
|
- lib/mobile_subscriber/version.rb
|
125
126
|
- mobile-subscriber.gemspec
|
126
127
|
- mobile_subscriber.thor
|
128
|
+
- spec/detection/from_msisdn_http_request_header_spec.rb
|
129
|
+
- spec/detection/from_x_nokia_msisdn_http_request_header_spec.rb
|
127
130
|
- spec/factories/requests.rb
|
128
131
|
- spec/mobile_subscriber_spec.rb
|
129
132
|
- spec/models/isdn_spec.rb
|
133
|
+
- spec/shared_examples/of_msisdn_detection_from_http_request.rb
|
130
134
|
- spec/spec_helper.rb
|
131
135
|
- templates/mobile_and_iso_country_codes.rb.erb
|
132
136
|
- templates/operator_data.rb.erb
|
@@ -155,7 +159,10 @@ signing_key:
|
|
155
159
|
specification_version: 4
|
156
160
|
summary: Mobile MSISDN detection & validation.
|
157
161
|
test_files:
|
162
|
+
- spec/detection/from_msisdn_http_request_header_spec.rb
|
163
|
+
- spec/detection/from_x_nokia_msisdn_http_request_header_spec.rb
|
158
164
|
- spec/factories/requests.rb
|
159
165
|
- spec/mobile_subscriber_spec.rb
|
160
166
|
- spec/models/isdn_spec.rb
|
167
|
+
- spec/shared_examples/of_msisdn_detection_from_http_request.rb
|
161
168
|
- spec/spec_helper.rb
|