jpmobile 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -3
- data/.rubocop.yml +123 -0
- data/CONTRIBUTING.md +16 -14
- data/Gemfile +6 -0
- data/Gemfile.lock +198 -0
- data/README.md +409 -0
- data/Rakefile +9 -9
- data/circle.yml +14 -0
- data/jpmobile.gemspec +9 -10
- data/lib/jpmobile.rb +6 -5
- data/lib/jpmobile/datum_conv.rb +35 -35
- data/lib/jpmobile/docomo_guid.rb +7 -8
- data/lib/jpmobile/email.rb +12 -12
- data/lib/jpmobile/emoticon.rb +85 -76
- data/lib/jpmobile/emoticon/au.rb +1284 -1284
- data/lib/jpmobile/emoticon/conversion_table.rb +3905 -3906
- data/lib/jpmobile/emoticon/docomo.rb +252 -252
- data/lib/jpmobile/emoticon/google.rb +9 -9
- data/lib/jpmobile/emoticon/softbank.rb +471 -471
- data/lib/jpmobile/emoticon/unicode.rb +9 -9
- data/lib/jpmobile/emoticon/z_combine.rb +20 -23
- data/lib/jpmobile/encoding.rb +1 -1
- data/lib/jpmobile/fallback_view_selector.rb +2 -3
- data/lib/jpmobile/filter.rb +44 -47
- data/lib/jpmobile/helpers.rb +38 -38
- data/lib/jpmobile/hook_action_view.rb +7 -7
- data/lib/jpmobile/hook_test_request.rb +0 -1
- data/lib/jpmobile/lookup_context.rb +1 -2
- data/lib/jpmobile/mail.rb +156 -134
- data/lib/jpmobile/mailer.rb +4 -4
- data/lib/jpmobile/mobile/abstract_mobile.rb +62 -36
- data/lib/jpmobile/mobile/android.rb +0 -1
- data/lib/jpmobile/mobile/android_tablet.rb +0 -1
- data/lib/jpmobile/mobile/au.rb +40 -28
- data/lib/jpmobile/mobile/black_berry.rb +0 -1
- data/lib/jpmobile/mobile/ddipocket.rb +1 -2
- data/lib/jpmobile/mobile/docomo.rb +47 -36
- data/lib/jpmobile/mobile/emobile.rb +1 -2
- data/lib/jpmobile/mobile/google_emoticon.rb +1 -1
- data/lib/jpmobile/mobile/ipad.rb +0 -1
- data/lib/jpmobile/mobile/iphone.rb +0 -1
- data/lib/jpmobile/mobile/smart_phone.rb +0 -1
- data/lib/jpmobile/mobile/softbank.rb +24 -20
- data/lib/jpmobile/mobile/tablet.rb +0 -1
- data/lib/jpmobile/mobile/unicode_emoticon.rb +15 -15
- data/lib/jpmobile/mobile/vodafone.rb +0 -1
- data/lib/jpmobile/mobile/willcom.rb +7 -7
- data/lib/jpmobile/mobile/windows_phone.rb +0 -1
- data/lib/jpmobile/path_set.rb +1 -1
- data/lib/jpmobile/position.rb +30 -14
- data/lib/jpmobile/rack/filter.rb +4 -4
- data/lib/jpmobile/rack/mobile_carrier.rb +0 -1
- data/lib/jpmobile/rack/params_filter.rb +7 -6
- data/lib/jpmobile/rails.rb +3 -4
- data/lib/jpmobile/request_with_mobile.rb +9 -6
- data/lib/jpmobile/resolver.rb +23 -17
- data/lib/jpmobile/session/active_record_store.rb +7 -9
- data/lib/jpmobile/session/mem_cache_store.rb +7 -9
- data/lib/jpmobile/sinatra.rb +1 -1
- data/lib/jpmobile/trans_sid.rb +15 -20
- data/lib/jpmobile/util.rb +61 -77
- data/lib/jpmobile/version.rb +1 -1
- data/lib/tasks/jpmobile_tasks.rake +35 -28
- data/spec/rack/jpmobile/android_spec.rb +5 -5
- data/spec/rack/jpmobile/au_spec.rb +74 -59
- data/spec/rack/jpmobile/black_berry_spec.rb +5 -5
- data/spec/rack/jpmobile/docomo_spec.rb +77 -64
- data/spec/rack/jpmobile/emoticon_spec.rb +137 -121
- data/spec/rack/jpmobile/filter_spec.rb +149 -128
- data/spec/rack/jpmobile/iphone_spec.rb +9 -8
- data/spec/rack/jpmobile/mobile_by_ua_spec.rb +22 -21
- data/spec/rack/jpmobile/params_filter_spec.rb +104 -96
- data/spec/rack/jpmobile/softbank_spec.rb +49 -42
- data/spec/rack/jpmobile/willcom_spec.rb +22 -18
- data/spec/rack/jpmobile/windows_phone.rb +5 -5
- data/spec/rack_helper.rb +9 -8
- data/spec/spec_helper.rb +5 -6
- data/spec/unit/decorated_mail_spec.rb +8 -9
- data/spec/unit/email_spec.rb +44 -44
- data/spec/unit/emoticon_spec.rb +57 -58
- data/spec/unit/encoding_spec.rb +35 -36
- data/spec/unit/is_carrier_spec.rb +49 -49
- data/spec/unit/mail_spec.rb +153 -143
- data/spec/unit/mobile/iphone_spec.rb +6 -7
- data/spec/unit/receive_mail_spec.rb +172 -173
- data/spec/unit/spec_helper.rb +6 -6
- data/spec/unit/util_spec.rb +125 -46
- data/spec/unit/valid_ip_spec.rb +35 -35
- data/spec/unit/variants_spec.rb +18 -19
- data/test/rails/overrides/Gemfile +54 -0
- data/test/rails/overrides/Gemfile.jpmobile +1 -2
- data/test/rails/overrides/app/controllers/admin/top_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/filter_controller_base.rb +14 -6
- data/test/rails/overrides/app/controllers/hankaku_input_filter_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/template_path_controller.rb +1 -2
- data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -10
- data/test/rails/overrides/app/controllers/trans_sid_metal_controller.rb +0 -1
- data/test/rails/overrides/app/mailers/decorated_mailer.rb +3 -4
- data/test/rails/overrides/app/mailers/mobile_mailer.rb +5 -6
- data/test/rails/overrides/app/mailers/normal_mailer.rb +2 -3
- data/test/rails/overrides/autotest/discover.rb +2 -2
- data/test/rails/overrides/config/initializers/jpmobile_generator.rb +2 -2
- data/test/rails/overrides/config/routes.rb +95 -2
- data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +2 -2
- data/test/rails/overrides/db/migrate/20100824062306_create_users.rb +1 -1
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +24 -25
- data/test/rails/overrides/spec/controllers/helpers_spec.rb +88 -88
- data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +9 -9
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +19 -19
- data/test/rails/overrides/spec/features/admin/top_spec.rb +7 -7
- data/test/rails/overrides/spec/features/filter_spec.rb +101 -102
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +4 -4
- data/test/rails/overrides/spec/mailers/decorated_mailer_spec.rb +12 -12
- data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +209 -194
- data/test/rails/overrides/spec/mailers/normal_mailer_spec.rb +10 -10
- data/test/rails/overrides/spec/rails_helper.rb +1 -1
- data/test/rails/overrides/spec/requests/docomo_spec.rb +13 -13
- data/test/rails/overrides/spec/requests/emobile_spec.rb +19 -19
- data/test/rails/overrides/spec/requests/pc_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/template_path_spec.rb +60 -60
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +89 -89
- data/test/sinatra/test/filter_test.rb +10 -11
- data/tools/e4u_conv.rb +0 -1
- metadata +18 -14
- data/README +0 -0
- data/README.rdoc +0 -308
data/spec/unit/spec_helper.rb
CHANGED
@@ -4,20 +4,20 @@ require 'rspec/its'
|
|
4
4
|
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib')))
|
5
5
|
require 'jpmobile'
|
6
6
|
begin
|
7
|
-
require File.dirname(__FILE__)+'/../../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
|
7
|
+
require File.dirname(__FILE__) + '/../../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
|
8
8
|
rescue LoadError
|
9
|
-
puts
|
9
|
+
puts 'IP Address test requires jpmobile-ipaddresses module'
|
10
10
|
end
|
11
11
|
begin
|
12
|
-
require File.dirname(__FILE__)+'/../../vendor/jpmobile-terminfo/lib/jpmobile-terminfo'
|
12
|
+
require File.dirname(__FILE__) + '/../../vendor/jpmobile-terminfo/lib/jpmobile-terminfo'
|
13
13
|
rescue LoadError
|
14
|
-
puts
|
14
|
+
puts 'Terminal display information test requires jpmobile-terminfo module'
|
15
15
|
end
|
16
16
|
|
17
17
|
RSpec.configure do |config|
|
18
|
-
config.filter_run :
|
18
|
+
config.filter_run focus: true
|
19
19
|
config.run_all_when_everything_filtered = true
|
20
20
|
config.color = true
|
21
|
-
config.filter_run_excluding :
|
21
|
+
config.filter_run_excluding broken: true
|
22
22
|
# config.full_backtrace = true
|
23
23
|
end
|
data/spec/unit/util_spec.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
3
2
|
require 'stringio'
|
4
3
|
require 'nkf'
|
@@ -7,62 +6,78 @@ describe Jpmobile::Util do
|
|
7
6
|
include Jpmobile::Util
|
8
7
|
|
9
8
|
describe 'utf8_to_sjis' do
|
10
|
-
it
|
11
|
-
expect(utf8_to_sjis(
|
9
|
+
it 'utf8_to_sjis で変換できない文字列が含んでいた場合?に変換される' do
|
10
|
+
expect(utf8_to_sjis('اللغة العربية')).to eq(sjis('????? ???????'))
|
12
11
|
end
|
13
12
|
|
14
|
-
it
|
13
|
+
it 'utf8_to_sjis ですべての改行コードが CRLF に変更されること' do
|
15
14
|
expect(utf8_to_sjis("UTF8\rSAMPLE\nTEXT\r\n")).to eq(sjis("UTF8\r\nSAMPLE\r\nTEXT\r\n"))
|
16
15
|
end
|
17
16
|
|
18
|
-
it
|
19
|
-
expect(utf8_to_sjis([0xffe3].pack(
|
17
|
+
it 'U+FFE3が0x8150に変換されること' do
|
18
|
+
expect(utf8_to_sjis([0xffe3].pack('U'))).to eq(sjis("\x81\x50"))
|
20
19
|
end
|
21
20
|
|
22
|
-
it
|
23
|
-
expect(utf8_to_sjis([0x203e].pack(
|
21
|
+
it 'U+203Eが0x8150に変換されること' do
|
22
|
+
expect(utf8_to_sjis([0x203e].pack('U'))).to eq(sjis("\x81\x50"))
|
24
23
|
end
|
25
24
|
|
26
|
-
it
|
27
|
-
expect(utf8_to_sjis([0x2014].pack(
|
25
|
+
it 'U+2014が0x815Cに変換されること' do
|
26
|
+
expect(utf8_to_sjis([0x2014].pack('U'))).to eq(sjis("\x81\x5C"))
|
28
27
|
end
|
29
28
|
|
30
|
-
it
|
31
|
-
expect(utf8_to_sjis([0x2212].pack(
|
29
|
+
it 'U+2212が0x817Cに変換されること' do
|
30
|
+
expect(utf8_to_sjis([0x2212].pack('U'))).to eq(sjis("\x81\x7C"))
|
32
31
|
end
|
33
32
|
|
34
|
-
it
|
35
|
-
expect(utf8_to_jis(
|
33
|
+
it 'utf8_to_sjis で変換できない文字列が含んでいた場合?に変換される' do
|
34
|
+
expect(utf8_to_jis('اللغة العربية')).to eq(jis('????? ???????'))
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'frozenでも通過すること' do
|
38
|
+
expect { utf8_to_jis('漢字'.freeze) }.not_to raise_error
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
42
|
describe 'sjis_to_utf8' do
|
40
|
-
it
|
41
|
-
expect(sjis_to_utf8(sjis("\x81\x50"))).to eq([0xffe3].pack(
|
43
|
+
it '0x8150がU+FFE3に変換されること' do
|
44
|
+
expect(sjis_to_utf8(sjis("\x81\x50"))).to eq([0xffe3].pack('U'))
|
42
45
|
end
|
43
46
|
|
44
|
-
it
|
47
|
+
it 'sjis_to_utf8 ですべての改行コードが LF に変更されること' do
|
45
48
|
expect(sjis_to_utf8("SJIS\rSAMPLE\nTEXT\r\n")).to eq(utf8("SJIS\nSAMPLE\nTEXT\n"))
|
46
49
|
end
|
50
|
+
|
51
|
+
it 'frozenでも通過すること' do
|
52
|
+
expect { sjis_to_utf8('漢字'.encode('SJIS').freeze) }.not_to raise_error
|
53
|
+
end
|
47
54
|
end
|
48
55
|
|
49
56
|
describe 'utf8_to_jis' do
|
50
|
-
it
|
57
|
+
it 'utf8_to_jis ですべての改行コードが CRLF に変更されること' do
|
51
58
|
expect(utf8_to_jis("UTF8\rSAMPLE\nTEXT\r\n")).to eq(jis("UTF8\r\nSAMPLE\r\nTEXT\r\n"))
|
52
59
|
end
|
60
|
+
|
61
|
+
it 'frozenでも通過すること' do
|
62
|
+
expect { utf8_to_jis('漢字'.freeze) }.not_to raise_error
|
63
|
+
end
|
53
64
|
end
|
54
65
|
|
55
66
|
describe 'jis_string_regexp' do
|
56
|
-
it
|
57
|
-
expect(jis_string_regexp.match(ascii_8bit(utf8_to_jis(
|
58
|
-
expect(jis_to_utf8(jis("\x1b\x24\x42#{
|
67
|
+
it 'jis_string_regexpでISO-2022-JPの文字列がマッチすること' do
|
68
|
+
expect(jis_string_regexp.match(ascii_8bit(utf8_to_jis('abcしからずんばこじをえずdef')))).not_to be_nil
|
69
|
+
expect(jis_to_utf8(jis("\x1b\x24\x42#{Regexp.last_match(1)}\x1b\x28\x42"))).to eq('しからずんばこじをえず')
|
59
70
|
end
|
60
71
|
end
|
61
72
|
|
62
73
|
describe 'jis_to_utf8' do
|
63
|
-
it
|
74
|
+
it 'jis_to_utf8 ですべての改行コードが LF に変更されること' do
|
64
75
|
expect(jis_to_utf8("JIS\rSAMPLE\nTEXT\r\n")).to eq(utf8("JIS\nSAMPLE\nTEXT\n"))
|
65
76
|
end
|
77
|
+
|
78
|
+
it 'frozenでも通過すること' do
|
79
|
+
expect { jis_to_utf8('漢字'.encode('ISO-2022-JP').freeze) }.not_to raise_error
|
80
|
+
end
|
66
81
|
end
|
67
82
|
|
68
83
|
describe '#force_encode' do
|
@@ -71,59 +86,123 @@ describe Jpmobile::Util do
|
|
71
86
|
end
|
72
87
|
|
73
88
|
it 'does not enter infinite loop on retry' do
|
74
|
-
expect{ force_encode("\e\x28\x49\x9a\x43\x3D\x44\e\x28\x42".force_encoding('ISO-2022-JP'), 'iso-2022-jp', 'UTF-8') }.to raise_error ::Encoding::InvalidByteSequenceError
|
89
|
+
expect { force_encode("\e\x28\x49\x9a\x43\x3D\x44\e\x28\x42".force_encoding('ISO-2022-JP'), 'iso-2022-jp', 'UTF-8') }.to raise_error ::Encoding::InvalidByteSequenceError
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'frozenでも通過すること' do
|
93
|
+
expect { force_encode('漢字'.encode('ISO-2022-JP').freeze, 'iso-2022-jp', 'UTF-8') }.not_to raise_error
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#fold_text' do
|
98
|
+
it 'UTF-8の日本語文字列が指定文字数で折り返された配列で返ること' do
|
99
|
+
expect(fold_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15)).
|
100
|
+
to eq(
|
101
|
+
%w[
|
102
|
+
長い日本語の題名で折り返される
|
103
|
+
かようにするには事前に分割して
|
104
|
+
いないとダメなことがわかりまし
|
105
|
+
たよ
|
106
|
+
]
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'UTF-8の短い文字列は折り返されないこと' do
|
111
|
+
expect(fold_text('短い', 15)).to eq(['短い'])
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'frozenでも通過すること' do
|
115
|
+
expect { fold_text(('漢字' * 10).freeze, 15) }.not_to raise_error
|
75
116
|
end
|
76
117
|
end
|
77
118
|
|
78
|
-
|
79
|
-
|
80
|
-
'
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
119
|
+
describe '#split_text' do
|
120
|
+
it 'UTF-8の日本語文字列が指定文字数で2つに分割されること' do
|
121
|
+
expect(split_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15)).
|
122
|
+
to eq(
|
123
|
+
%w[
|
124
|
+
長い日本語の題名で折り返される
|
125
|
+
かようにするには事前に分割していないとダメなことがわかりましたよ
|
126
|
+
]
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'nilかblankの場合はnilが返ること' do
|
131
|
+
expect(split_text('', 15)).to be_nil
|
132
|
+
expect(split_text(nil, 15)).to be_nil
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'frozenでも通過すること' do
|
136
|
+
expect { split_text(('漢字' * 10).freeze, 15) }.not_to raise_error
|
137
|
+
end
|
85
138
|
end
|
86
139
|
|
87
|
-
|
88
|
-
|
140
|
+
describe '#sjis' do
|
141
|
+
it 'frozenでも通過すること' do
|
142
|
+
expect { sjis('漢字'.freeze) }.not_to raise_error
|
143
|
+
end
|
89
144
|
end
|
90
145
|
|
91
|
-
|
92
|
-
|
93
|
-
'
|
94
|
-
|
95
|
-
])
|
146
|
+
describe '#utf8' do
|
147
|
+
it 'frozenでも通過すること' do
|
148
|
+
expect { utf8('漢字'.freeze) }.not_to raise_error
|
149
|
+
end
|
96
150
|
end
|
97
151
|
|
98
|
-
|
99
|
-
|
100
|
-
|
152
|
+
describe '#jis' do
|
153
|
+
it 'frozenでも通過すること' do
|
154
|
+
expect { jis('漢字'.freeze) }.not_to raise_error
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe '#jis_win' do
|
159
|
+
it 'frozenでも通過すること' do
|
160
|
+
expect { jis_win('漢字'.freeze) }.not_to raise_error
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe '#ascii_8bit' do
|
165
|
+
it 'frozenでも通過すること' do
|
166
|
+
expect { ascii_8bit('漢字'.freeze) }.not_to raise_error
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe '#ascii_compatible!' do
|
171
|
+
it 'frozenでも通過すること' do
|
172
|
+
expect { ascii_compatible!('漢字'.freeze) }.not_to raise_error
|
173
|
+
end
|
101
174
|
end
|
102
175
|
|
103
|
-
it
|
176
|
+
it '全角チルダがjisに適切に変換されること' do
|
104
177
|
expect(ascii_8bit(utf8_to_jis("\xef\xbd\x9e"))).to eq(ascii_8bit("\x1b\x24\x42\x21\x41\x1b\x28\x42"))
|
105
|
-
expect(ascii_8bit(encode("\xef\xbd\x9e",
|
178
|
+
expect(ascii_8bit(encode("\xef\xbd\x9e", 'ISO-2022-JP'))).to eq(ascii_8bit("\x1b\x24\x42\x21\x41\x1b\x28\x42"))
|
106
179
|
end
|
107
180
|
|
108
181
|
describe 'invert_table' do
|
109
182
|
it 'pickups the first(least) of duplicated values when inverting hash table' do
|
110
|
-
hash = invert_table(
|
183
|
+
hash = invert_table(
|
184
|
+
{
|
111
185
|
0xFE009 => 0xE63E,
|
112
186
|
0xFE00A => 0xE63E,
|
113
187
|
0xFE00B => 0x3013,
|
114
188
|
0xFE010 => 0xE6B3,
|
115
|
-
0xFE038 => 0xE73F
|
189
|
+
0xFE038 => 0xE73F,
|
190
|
+
}
|
191
|
+
)
|
116
192
|
expect(hash[0xE63E]).to eq(0xFE009)
|
117
193
|
expect(hash[0x3013]).to eq(0xFE00B)
|
118
194
|
end
|
119
195
|
|
120
196
|
it 'should not raise error when hash has Array keys' do
|
121
|
-
hash = invert_table(
|
197
|
+
hash = invert_table(
|
198
|
+
{
|
122
199
|
[0x1F1E8, 0x1F1F3] => 0x3013,
|
123
200
|
0x1F1FF => 0x3013,
|
124
201
|
0x1F526 => 0xE6FB,
|
125
202
|
[0x0023, 0x20E3] => 0xE6E0,
|
126
|
-
0x1F354 => 0xE673
|
203
|
+
0x1F354 => 0xE673,
|
204
|
+
}
|
205
|
+
)
|
127
206
|
expect(hash[0x3013]).to eq([0x1F1E8, 0x1F1F3])
|
128
207
|
expect(hash[0xE6FB]).to eq(0x1F526)
|
129
208
|
end
|
data/spec/unit/valid_ip_spec.rb
CHANGED
@@ -2,47 +2,47 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
|
2
2
|
|
3
3
|
describe 'Jpmobile::Mobile::valid_ip?' do
|
4
4
|
[
|
5
|
-
[
|
6
|
-
[
|
7
|
-
[
|
8
|
-
[
|
9
|
-
[
|
10
|
-
[
|
11
|
-
[
|
12
|
-
[
|
13
|
-
[
|
14
|
-
[
|
15
|
-
[
|
16
|
-
[
|
17
|
-
[
|
18
|
-
[
|
5
|
+
['210.153.84.1', :Docomo],
|
6
|
+
['210.153.84.254', :Docomo],
|
7
|
+
['210.230.128.225', :Au],
|
8
|
+
['210.230.128.238', :Au],
|
9
|
+
['123.108.237.1', :Softbank],
|
10
|
+
['123.108.237.31', :Softbank],
|
11
|
+
['123.108.237.1', :Vodafone],
|
12
|
+
['123.108.237.31', :Vodafone],
|
13
|
+
['61.198.142.1', :Willcom],
|
14
|
+
['61.198.142.254', :Willcom],
|
15
|
+
['61.198.142.1', :Ddipocket],
|
16
|
+
['61.198.142.254', :Ddipocket],
|
17
|
+
['117.55.1.224', :Emobile],
|
18
|
+
['117.55.1.254', :Emobile],
|
19
19
|
].each do |remote_ip, carrier|
|
20
|
-
it "should be return true if #{remote_ip} is in #{
|
20
|
+
it "should be return true if #{remote_ip} is in #{carrier} address" do
|
21
21
|
expect(Jpmobile::Mobile.const_get(carrier).valid_ip?(remote_ip)).to eq(true)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
[
|
26
|
-
[
|
27
|
-
[
|
28
|
-
[
|
29
|
-
[
|
30
|
-
[
|
31
|
-
[
|
32
|
-
[
|
33
|
-
[
|
34
|
-
[
|
35
|
-
[
|
36
|
-
[
|
37
|
-
[
|
38
|
-
[
|
39
|
-
[
|
40
|
-
[
|
41
|
-
[
|
42
|
-
[
|
43
|
-
[
|
44
|
-
[
|
45
|
-
[
|
26
|
+
['127.0.0.1', :Docomo],
|
27
|
+
['210.153.83.1', :Docomo],
|
28
|
+
['210.153.83.254', :Docomo],
|
29
|
+
['127.0.0.1', :Au],
|
30
|
+
['210.169.41.1', :Au],
|
31
|
+
['210.169.41.254', :Au],
|
32
|
+
['127.0.0.1', :Softbank],
|
33
|
+
['123.108.238.1', :Softbank],
|
34
|
+
['123.108.238.254', :Softbank],
|
35
|
+
['127.0.0.1', :Vodafone],
|
36
|
+
['123.108.238.1', :Vodafone],
|
37
|
+
['123.108.238.254', :Vodafone],
|
38
|
+
['127.0.0.1', :Willcom],
|
39
|
+
['61.198.144.1', :Willcom],
|
40
|
+
['61.198.144.254', :Willcom],
|
41
|
+
['127.0.0.1', :Ddipocket],
|
42
|
+
['61.198.144.1', :Ddipocket],
|
43
|
+
['61.198.144.254', :Ddipocket],
|
44
|
+
['127.0.0.1', :Emobile],
|
45
|
+
['117.55.1.223', :Emobile],
|
46
46
|
].each do |remote_ip, carrier|
|
47
47
|
it 'should not be return true if #{:remote_ip} is in #{carrier} address' do
|
48
48
|
expect(Jpmobile::Mobile.const_get(carrier).valid_ip?(remote_ip)).not_to eq(true)
|
data/spec/unit/variants_spec.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
3
2
|
require 'mail'
|
4
3
|
require 'jpmobile/mail'
|
5
4
|
|
6
5
|
describe Jpmobile::Mobile::AbstractMobile do
|
7
|
-
subject{ Jpmobile::Mobile::AbstractMobile.new(nil, nil) }
|
6
|
+
subject { Jpmobile::Mobile::AbstractMobile.new(nil, nil) }
|
8
7
|
|
9
8
|
describe '#variants' do
|
10
9
|
describe '#variants' do
|
11
10
|
subject { super().variants }
|
12
|
-
it { is_expected.to
|
11
|
+
it { is_expected.to eq(['mobile']) }
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
@@ -22,12 +21,12 @@ describe Jpmobile::Mobile::AbstractMobile do
|
|
22
21
|
end
|
23
22
|
|
24
23
|
describe Jpmobile::Mobile::Docomo do
|
25
|
-
subject{ Jpmobile::Mobile::Docomo.new(nil, nil) }
|
24
|
+
subject { Jpmobile::Mobile::Docomo.new(nil, nil) }
|
26
25
|
|
27
26
|
describe '#variants' do
|
28
27
|
describe '#variants' do
|
29
28
|
subject { super().variants }
|
30
|
-
it { is_expected.to eq([
|
29
|
+
it { is_expected.to eq(%w[mobile_docomo mobile]) }
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
@@ -39,12 +38,12 @@ describe Jpmobile::Mobile::Docomo do
|
|
39
38
|
end
|
40
39
|
|
41
40
|
describe Jpmobile::Mobile::Au do
|
42
|
-
subject{ Jpmobile::Mobile::Au.new(nil, nil) }
|
41
|
+
subject { Jpmobile::Mobile::Au.new(nil, nil) }
|
43
42
|
|
44
43
|
describe '#variants' do
|
45
44
|
describe '#variants' do
|
46
45
|
subject { super().variants }
|
47
|
-
it { is_expected.to eq([
|
46
|
+
it { is_expected.to eq(%w[mobile_au mobile]) }
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
@@ -56,12 +55,12 @@ describe Jpmobile::Mobile::Au do
|
|
56
55
|
end
|
57
56
|
|
58
57
|
describe Jpmobile::Mobile::Softbank do
|
59
|
-
subject{ Jpmobile::Mobile::Softbank.new(nil, nil) }
|
58
|
+
subject { Jpmobile::Mobile::Softbank.new(nil, nil) }
|
60
59
|
|
61
60
|
describe '#variants' do
|
62
61
|
describe '#variants' do
|
63
62
|
subject { super().variants }
|
64
|
-
it { is_expected.to eq([
|
63
|
+
it { is_expected.to eq(%w[mobile_softbank mobile]) }
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
@@ -73,12 +72,12 @@ describe Jpmobile::Mobile::Softbank do
|
|
73
72
|
end
|
74
73
|
|
75
74
|
describe Jpmobile::Mobile::Android do
|
76
|
-
subject{ Jpmobile::Mobile::Android.new(nil, nil) }
|
75
|
+
subject { Jpmobile::Mobile::Android.new(nil, nil) }
|
77
76
|
|
78
77
|
describe '#variants' do
|
79
78
|
describe '#variants' do
|
80
79
|
subject { super().variants }
|
81
|
-
it { is_expected.to eq([
|
80
|
+
it { is_expected.to eq(%w[smart_phone_android smart_phone]) }
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
@@ -90,12 +89,12 @@ describe Jpmobile::Mobile::Android do
|
|
90
89
|
end
|
91
90
|
|
92
91
|
describe Jpmobile::Mobile::AndroidTablet do
|
93
|
-
subject{ Jpmobile::Mobile::AndroidTablet.new(nil, nil) }
|
92
|
+
subject { Jpmobile::Mobile::AndroidTablet.new(nil, nil) }
|
94
93
|
|
95
94
|
describe '#variants' do
|
96
95
|
describe '#variants' do
|
97
96
|
subject { super().variants }
|
98
|
-
it { is_expected.to eq([
|
97
|
+
it { is_expected.to eq(%w[tablet_android_tablet tablet smart_phone]) }
|
99
98
|
end
|
100
99
|
end
|
101
100
|
|
@@ -107,12 +106,12 @@ describe Jpmobile::Mobile::AndroidTablet do
|
|
107
106
|
end
|
108
107
|
|
109
108
|
describe Jpmobile::Mobile::Iphone do
|
110
|
-
subject{ Jpmobile::Mobile::Iphone.new(nil, nil) }
|
109
|
+
subject { Jpmobile::Mobile::Iphone.new(nil, nil) }
|
111
110
|
|
112
111
|
describe '#variants' do
|
113
112
|
describe '#variants' do
|
114
113
|
subject { super().variants }
|
115
|
-
it { is_expected.to eq([
|
114
|
+
it { is_expected.to eq(%w[smart_phone_iphone smart_phone]) }
|
116
115
|
end
|
117
116
|
end
|
118
117
|
|
@@ -124,12 +123,12 @@ describe Jpmobile::Mobile::Iphone do
|
|
124
123
|
end
|
125
124
|
|
126
125
|
describe Jpmobile::Mobile::Ipad do
|
127
|
-
subject{ Jpmobile::Mobile::Ipad.new(nil, nil) }
|
126
|
+
subject { Jpmobile::Mobile::Ipad.new(nil, nil) }
|
128
127
|
|
129
128
|
describe '#variants' do
|
130
129
|
describe '#variants' do
|
131
130
|
subject { super().variants }
|
132
|
-
it { is_expected.to eq([
|
131
|
+
it { is_expected.to eq(%w[tablet_ipad tablet smart_phone]) }
|
133
132
|
end
|
134
133
|
end
|
135
134
|
|
@@ -141,12 +140,12 @@ describe Jpmobile::Mobile::Ipad do
|
|
141
140
|
end
|
142
141
|
|
143
142
|
describe Jpmobile::Mobile::WindowsPhone do
|
144
|
-
subject{ Jpmobile::Mobile::WindowsPhone.new(nil, nil) }
|
143
|
+
subject { Jpmobile::Mobile::WindowsPhone.new(nil, nil) }
|
145
144
|
|
146
145
|
describe '#variants' do
|
147
146
|
describe '#variants' do
|
148
147
|
subject { super().variants }
|
149
|
-
it { is_expected.to eq([
|
148
|
+
it { is_expected.to eq(%w[smart_phone_windows_phone smart_phone]) }
|
150
149
|
end
|
151
150
|
end
|
152
151
|
|