jpmobile 4.1.1 → 4.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/jpmobile.gemspec +2 -0
- data/lib/jpmobile/emoticon.rb +3 -3
- data/lib/jpmobile/filter.rb +1 -1
- data/lib/jpmobile/mail.rb +3 -3
- data/lib/jpmobile/mobile/abstract_mobile.rb +5 -2
- data/lib/jpmobile/resolver.rb +17 -1
- data/lib/jpmobile/version.rb +1 -1
- data/lib/tasks/jpmobile_tasks.rake +5 -11
- data/spec/rack/jpmobile/android_spec.rb +4 -4
- data/spec/rack/jpmobile/au_spec.rb +46 -46
- data/spec/rack/jpmobile/black_berry_spec.rb +4 -4
- data/spec/rack/jpmobile/docomo_spec.rb +52 -52
- data/spec/rack/jpmobile/emoticon_spec.rb +67 -67
- data/spec/rack/jpmobile/filter_spec.rb +36 -36
- data/spec/rack/jpmobile/iphone_spec.rb +5 -5
- data/spec/rack/jpmobile/mobile_by_ua_spec.rb +2 -2
- data/spec/rack/jpmobile/params_filter_spec.rb +30 -30
- data/spec/rack/jpmobile/softbank_spec.rb +39 -39
- data/spec/rack/jpmobile/willcom_spec.rb +12 -12
- data/spec/rack/jpmobile/windows_phone.rb +4 -4
- data/spec/unit/decorated_mail_spec.rb +3 -3
- data/spec/unit/email_spec.rb +6 -6
- data/spec/unit/emoticon_spec.rb +33 -33
- data/spec/unit/encoding_spec.rb +14 -14
- data/spec/unit/is_carrier_spec.rb +1 -1
- data/spec/unit/mail_spec.rb +63 -63
- data/spec/unit/mobile/iphone_spec.rb +6 -6
- data/spec/unit/receive_mail_spec.rb +75 -75
- data/spec/unit/util_spec.rb +34 -34
- data/spec/unit/valid_ip_spec.rb +2 -2
- data/spec/unit/variants_spec.rb +40 -10
- data/test/rails/overrides/Gemfile +3 -3
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +6 -6
- data/test/rails/overrides/spec/controllers/helpers_spec.rb +22 -22
- data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +19 -19
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +8 -8
- data/test/rails/overrides/spec/controllers/trans_sid_controller_spec.rb +2 -2
- data/test/rails/overrides/spec/features/admin/top_spec.rb +3 -3
- data/test/rails/overrides/spec/features/filter_spec.rb +32 -32
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +3 -3
- data/test/rails/overrides/spec/mailers/decorated_mailer_spec.rb +3 -3
- data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +179 -179
- data/test/rails/overrides/spec/mailers/normal_mailer_spec.rb +7 -7
- data/test/rails/overrides/spec/requests/docomo_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/emobile_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/pc_spec.rb +3 -3
- data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/template_path_spec.rb +24 -24
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +16 -16
- metadata +39 -25
@@ -39,13 +39,13 @@ describe Jpmobile::Rack::ParamsFilter do
|
|
39
39
|
|
40
40
|
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::ParamsFilter.new(UnitApplication.new)).call(res)
|
41
41
|
req = Rack::Request.new(res[1])
|
42
|
-
req.params.size.
|
42
|
+
expect(req.params.size).to eq(4)
|
43
43
|
|
44
|
-
req.params[ascii_8bit(@query_params.keys.first.dup)].
|
45
|
-
req.params[ascii_8bit(@query_params.keys.last.dup)].
|
44
|
+
expect(req.params[ascii_8bit(@query_params.keys.first.dup)]).to eq(ascii_8bit(@query_params[@query_params.keys.first]))
|
45
|
+
expect(req.params[ascii_8bit(@query_params.keys.last.dup)]).to eq(ascii_8bit(@query_params[@query_params.keys.last]))
|
46
46
|
|
47
|
-
req.params[ascii_8bit(@form_params.keys.first.dup)].
|
48
|
-
req.params[ascii_8bit(@form_params.keys.last.dup)].
|
47
|
+
expect(req.params[ascii_8bit(@form_params.keys.first.dup)]).to eq(ascii_8bit(@form_params[@form_params.keys.first]))
|
48
|
+
expect(req.params[ascii_8bit(@form_params.keys.last.dup)]).to eq(ascii_8bit(@form_params[@form_params.keys.last]))
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -60,13 +60,13 @@ describe Jpmobile::Rack::ParamsFilter do
|
|
60
60
|
|
61
61
|
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::ParamsFilter.new(UnitApplication.new)).call(res)
|
62
62
|
req = Rack::Request.new(res[1])
|
63
|
-
req.params.size.
|
63
|
+
expect(req.params.size).to eq(4)
|
64
64
|
|
65
|
-
req.params[ascii_8bit(@query_params.keys.first.dup)].
|
66
|
-
req.params[ascii_8bit(@query_params.keys.last.dup)].
|
65
|
+
expect(req.params[ascii_8bit(@query_params.keys.first.dup)]).to eq(ascii_8bit(@query_params[@query_params.keys.first]))
|
66
|
+
expect(req.params[ascii_8bit(@query_params.keys.last.dup)]).to eq(ascii_8bit(@query_params[@query_params.keys.last]))
|
67
67
|
|
68
|
-
req.params[ascii_8bit(@form_params.keys.first.dup)].
|
69
|
-
req.params[ascii_8bit(@form_params.keys.last.dup)].
|
68
|
+
expect(req.params[ascii_8bit(@form_params.keys.first.dup)]).to eq(ascii_8bit(@form_params[@form_params.keys.first]))
|
69
|
+
expect(req.params[ascii_8bit(@form_params.keys.last.dup)]).to eq(ascii_8bit(@form_params[@form_params.keys.last]))
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -92,13 +92,13 @@ describe Jpmobile::Rack::ParamsFilter do
|
|
92
92
|
|
93
93
|
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::ParamsFilter.new(UnitApplication.new)).call(res)
|
94
94
|
req = Rack::Request.new(res[1])
|
95
|
-
req.params.size.
|
95
|
+
expect(req.params.size).to eq(4)
|
96
96
|
|
97
|
-
req.params[ascii_8bit(@query_params.keys.first.dup)].
|
98
|
-
req.params[ascii_8bit(@query_params.keys.last.dup)].
|
97
|
+
expect(req.params[ascii_8bit(@query_params.keys.first.dup)]).to eq(ascii_8bit(@query_params[@query_params.keys.first]))
|
98
|
+
expect(req.params[ascii_8bit(@query_params.keys.last.dup)]).to eq(ascii_8bit(@query_params[@query_params.keys.last]))
|
99
99
|
|
100
|
-
req.params[ascii_8bit(@form_params.keys.first.dup)].
|
101
|
-
req.params[ascii_8bit(@form_params.keys.last.dup)].
|
100
|
+
expect(req.params[ascii_8bit(@form_params.keys.first.dup)]).to eq(ascii_8bit(@form_params[@form_params.keys.first]))
|
101
|
+
expect(req.params[ascii_8bit(@form_params.keys.last.dup)]).to eq(ascii_8bit(@form_params[@form_params.keys.last]))
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
@@ -119,10 +119,10 @@ describe Jpmobile::Rack::ParamsFilter do
|
|
119
119
|
|
120
120
|
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::ParamsFilter.new(UnitApplication.new)).call(res)
|
121
121
|
req = Rack::Request.new(res[1])
|
122
|
-
req.params.size.
|
122
|
+
expect(req.params.size).to eq(2)
|
123
123
|
|
124
|
-
req.params["hoge"].
|
125
|
-
req.params["foo"].
|
124
|
+
expect(req.params["hoge"]).to eq(ascii_8bit("\356\230\276"))
|
125
|
+
expect(req.params["foo"]).to eq(ascii_8bit("\356\231\200"))
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -140,10 +140,10 @@ describe Jpmobile::Rack::ParamsFilter do
|
|
140
140
|
|
141
141
|
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::ParamsFilter.new(UnitApplication.new)).call(res)
|
142
142
|
req = Rack::Request.new(res[1])
|
143
|
-
req.params.size.
|
143
|
+
expect(req.params.size).to eq(2)
|
144
144
|
|
145
|
-
req.params["hoge"].
|
146
|
-
req.params["foo"].
|
145
|
+
expect(req.params["hoge"]).to eq(ascii_8bit("\356\222\201"))
|
146
|
+
expect(req.params["foo"]).to eq(ascii_8bit("\356\224\242"))
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
@@ -161,10 +161,10 @@ describe Jpmobile::Rack::ParamsFilter do
|
|
161
161
|
|
162
162
|
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::ParamsFilter.new(UnitApplication.new)).call(res)
|
163
163
|
req = Rack::Request.new(res[1])
|
164
|
-
req.params.size.
|
164
|
+
expect(req.params.size).to eq(2)
|
165
165
|
|
166
|
-
req.params["hoge"].
|
167
|
-
req.params["foo"].
|
166
|
+
expect(req.params["hoge"]).to eq(ascii_8bit("\xef\x80\x81"))
|
167
|
+
expect(req.params["foo"]).to eq(ascii_8bit("\xef\x88\x9c"))
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
@@ -184,9 +184,9 @@ describe Jpmobile::Rack::ParamsFilter do
|
|
184
184
|
|
185
185
|
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::ParamsFilter.new(UnitApplication.new)).call(res)
|
186
186
|
req = Rack::Request.new(res[1])
|
187
|
-
req.params.size.
|
187
|
+
expect(req.params.size).to eq(1)
|
188
188
|
|
189
|
-
req.params["foo"].
|
189
|
+
expect(req.params["foo"]).to eq(ascii_8bit(token))
|
190
190
|
end
|
191
191
|
end
|
192
192
|
end
|
@@ -205,9 +205,9 @@ describe Jpmobile::Rack::ParamsFilter do
|
|
205
205
|
|
206
206
|
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::ParamsFilter.new(UnitApplication.new)).call(res)
|
207
207
|
req = Rack::Request.new(res[1])
|
208
|
-
req.params.size.
|
208
|
+
expect(req.params.size).to eq(0)
|
209
209
|
|
210
|
-
req.body.read.
|
210
|
+
expect(req.body.read).to eq(form_string)
|
211
211
|
end
|
212
212
|
end
|
213
213
|
end
|
@@ -226,9 +226,9 @@ describe Jpmobile::Rack::ParamsFilter do
|
|
226
226
|
|
227
227
|
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::ParamsFilter.new(UnitApplication.new)).call(res)
|
228
228
|
req = Rack::Request.new(res[1])
|
229
|
-
req.params.size.
|
229
|
+
expect(req.params.size).to eq(0)
|
230
230
|
|
231
|
-
req.body.read.
|
231
|
+
expect(req.body.read).to eq(form_string)
|
232
232
|
end
|
233
233
|
end
|
234
234
|
end
|
@@ -11,14 +11,14 @@ describe Jpmobile::Rack::MobileCarrier, "softbank" do
|
|
11
11
|
'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1")
|
12
12
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
13
13
|
|
14
|
-
env['rack.jpmobile'].class.
|
15
|
-
env['rack.jpmobile'].position.
|
16
|
-
env['rack.jpmobile'].serial_number.
|
17
|
-
env['rack.jpmobile'].ident.
|
18
|
-
env['rack.jpmobile'].ident_device.
|
19
|
-
env['rack.jpmobile'].ident_subscriber.
|
20
|
-
env['rack.jpmobile'].supports_cookie
|
21
|
-
env['rack.jpmobile'].smart_phone
|
14
|
+
expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Softbank)
|
15
|
+
expect(env['rack.jpmobile'].position).to be_nil
|
16
|
+
expect(env['rack.jpmobile'].serial_number).to eq("000000000000000")
|
17
|
+
expect(env['rack.jpmobile'].ident).to eq("000000000000000")
|
18
|
+
expect(env['rack.jpmobile'].ident_device).to eq("000000000000000")
|
19
|
+
expect(env['rack.jpmobile'].ident_subscriber).to be_nil
|
20
|
+
expect(env['rack.jpmobile'].supports_cookie?).to be_truthy
|
21
|
+
expect(env['rack.jpmobile'].smart_phone?).to be_falsey
|
22
22
|
end
|
23
23
|
|
24
24
|
it "X_JPHONE_UID 付きの 910T を判別できること" do
|
@@ -28,12 +28,12 @@ describe Jpmobile::Rack::MobileCarrier, "softbank" do
|
|
28
28
|
"HTTP_X_JPHONE_UID" => "aaaaaaaaaaaaaaaa")
|
29
29
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
30
30
|
|
31
|
-
env['rack.jpmobile'].serial_number.
|
32
|
-
env['rack.jpmobile'].x_jphone_uid.
|
33
|
-
env['rack.jpmobile'].ident.
|
34
|
-
env['rack.jpmobile'].ident_device.
|
35
|
-
env['rack.jpmobile'].ident_subscriber.
|
36
|
-
env['rack.jpmobile'].supports_cookie
|
31
|
+
expect(env['rack.jpmobile'].serial_number).to eq("000000000000000")
|
32
|
+
expect(env['rack.jpmobile'].x_jphone_uid).to eq("aaaaaaaaaaaaaaaa")
|
33
|
+
expect(env['rack.jpmobile'].ident).to eq("aaaaaaaaaaaaaaaa")
|
34
|
+
expect(env['rack.jpmobile'].ident_device).to eq("000000000000000")
|
35
|
+
expect(env['rack.jpmobile'].ident_subscriber).to eq("aaaaaaaaaaaaaaaa")
|
36
|
+
expect(env['rack.jpmobile'].supports_cookie?).to be_truthy
|
37
37
|
end
|
38
38
|
|
39
39
|
it "V903T を判別できること" do
|
@@ -42,10 +42,10 @@ describe Jpmobile::Rack::MobileCarrier, "softbank" do
|
|
42
42
|
'HTTP_USER_AGENT' => "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0")
|
43
43
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
44
44
|
|
45
|
-
env['rack.jpmobile'].class.
|
46
|
-
env['rack.jpmobile'].position.
|
47
|
-
env['rack.jpmobile'].ident.
|
48
|
-
env['rack.jpmobile'].supports_cookie
|
45
|
+
expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Vodafone)
|
46
|
+
expect(env['rack.jpmobile'].position).to be_nil
|
47
|
+
expect(env['rack.jpmobile'].ident).to be_nil
|
48
|
+
expect(env['rack.jpmobile'].supports_cookie?).to be_truthy
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -57,11 +57,11 @@ describe Jpmobile::Rack::MobileCarrier, "softbank" do
|
|
57
57
|
"QUERY_STRING" => "pos=N43.3.18.42E141.21.1.88&geo=wgs84&x-acr=1")
|
58
58
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
59
59
|
|
60
|
-
env['rack.jpmobile'].position.lat.
|
61
|
-
env['rack.jpmobile'].position.lon.
|
62
|
-
env['rack.jpmobile'].position.options['pos'].
|
63
|
-
env['rack.jpmobile'].position.options['geo'].
|
64
|
-
env['rack.jpmobile'].position.options['x-acr'].
|
60
|
+
expect(env['rack.jpmobile'].position.lat).to be_within(1e-7).of(43.05511667)
|
61
|
+
expect(env['rack.jpmobile'].position.lon).to be_within(1e-7).of(141.3505222)
|
62
|
+
expect(env['rack.jpmobile'].position.options['pos']).to eq("N43.3.18.42E141.21.1.88")
|
63
|
+
expect(env['rack.jpmobile'].position.options['geo']).to eq("wgs84")
|
64
|
+
expect(env['rack.jpmobile'].position.options['x-acr']).to eq("1")
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -73,7 +73,7 @@ describe Jpmobile::Rack::MobileCarrier, "softbank" do
|
|
73
73
|
"REMOTE_ADDR"=>"210.146.7.199")
|
74
74
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
75
75
|
|
76
|
-
env['rack.jpmobile'].valid_ip
|
76
|
+
expect(env['rack.jpmobile'].valid_ip?).to be_truthy
|
77
77
|
end
|
78
78
|
|
79
79
|
it "正しくないIPアドレス空間からのアクセスを判断できること" do
|
@@ -83,7 +83,7 @@ describe Jpmobile::Rack::MobileCarrier, "softbank" do
|
|
83
83
|
"REMOTE_ADDR"=>"127.0.0.1")
|
84
84
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
85
85
|
|
86
|
-
env['rack.jpmobile'].valid_ip
|
86
|
+
expect(env['rack.jpmobile'].valid_ip?).to be_falsey
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -96,12 +96,12 @@ describe Jpmobile::Rack::MobileCarrier, "softbank" do
|
|
96
96
|
"HTTP_X_JPHONE_COLOR"=>"C262144")
|
97
97
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
98
98
|
|
99
|
-
env['rack.jpmobile'].display.width.
|
100
|
-
env['rack.jpmobile'].display.height.
|
101
|
-
env['rack.jpmobile'].display.physical_width.
|
102
|
-
env['rack.jpmobile'].display.physical_height.
|
103
|
-
env['rack.jpmobile'].display.color
|
104
|
-
env['rack.jpmobile'].display.colors.
|
99
|
+
expect(env['rack.jpmobile'].display.width).to eq(240)
|
100
|
+
expect(env['rack.jpmobile'].display.height).to eq(320)
|
101
|
+
expect(env['rack.jpmobile'].display.physical_width).to eq(240)
|
102
|
+
expect(env['rack.jpmobile'].display.physical_height).to eq(320)
|
103
|
+
expect(env['rack.jpmobile'].display.color?).to be_truthy
|
104
|
+
expect(env['rack.jpmobile'].display.colors).to eq(262144)
|
105
105
|
end
|
106
106
|
|
107
107
|
it "端末の画面情報が渡ってない場合に正しく動作すること" do
|
@@ -110,14 +110,14 @@ describe Jpmobile::Rack::MobileCarrier, "softbank" do
|
|
110
110
|
'HTTP_USER_AGENT' => "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0")
|
111
111
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
112
112
|
|
113
|
-
env['rack.jpmobile'].display.width.
|
114
|
-
env['rack.jpmobile'].display.height.
|
115
|
-
env['rack.jpmobile'].display.browser_width.
|
116
|
-
env['rack.jpmobile'].display.browser_height.
|
117
|
-
env['rack.jpmobile'].display.physical_width.
|
118
|
-
env['rack.jpmobile'].display.physical_height.
|
119
|
-
env['rack.jpmobile'].display.color
|
120
|
-
env['rack.jpmobile'].display.colors.
|
113
|
+
expect(env['rack.jpmobile'].display.width).to be_nil
|
114
|
+
expect(env['rack.jpmobile'].display.height).to be_nil
|
115
|
+
expect(env['rack.jpmobile'].display.browser_width).to be_nil
|
116
|
+
expect(env['rack.jpmobile'].display.browser_height).to be_nil
|
117
|
+
expect(env['rack.jpmobile'].display.physical_width).to be_nil
|
118
|
+
expect(env['rack.jpmobile'].display.physical_height).to be_nil
|
119
|
+
expect(env['rack.jpmobile'].display.color?).to be_nil
|
120
|
+
expect(env['rack.jpmobile'].display.colors).to be_nil
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
@@ -11,10 +11,10 @@ describe Jpmobile::Rack::MobileCarrier, "willcom" do
|
|
11
11
|
'HTTP_USER_AGENT' => "Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0")
|
12
12
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
13
13
|
|
14
|
-
env['rack.jpmobile'].class.
|
15
|
-
env['rack.jpmobile'].position.
|
16
|
-
env['rack.jpmobile'].ident.
|
17
|
-
env['rack.jpmobile'].supports_cookie
|
14
|
+
expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Willcom)
|
15
|
+
expect(env['rack.jpmobile'].position).to be_nil
|
16
|
+
expect(env['rack.jpmobile'].ident).to be_nil
|
17
|
+
expect(env['rack.jpmobile'].supports_cookie?).to be_truthy
|
18
18
|
end
|
19
19
|
|
20
20
|
it "AH-H3001V が判別できること" do
|
@@ -23,10 +23,10 @@ describe Jpmobile::Rack::MobileCarrier, "willcom" do
|
|
23
23
|
'HTTP_USER_AGENT' => "Mozilla/3.0(DDIPOCKET;KYOCERA/AH-K3001V/1.8.2.71.000000/0.1/C100) Opera 7.0")
|
24
24
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
25
25
|
|
26
|
-
env['rack.jpmobile'].class.
|
27
|
-
env['rack.jpmobile'].position.
|
28
|
-
env['rack.jpmobile'].ident.
|
29
|
-
env['rack.jpmobile'].supports_cookie
|
26
|
+
expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Ddipocket)
|
27
|
+
expect(env['rack.jpmobile'].position).to be_nil
|
28
|
+
expect(env['rack.jpmobile'].ident).to be_nil
|
29
|
+
expect(env['rack.jpmobile'].supports_cookie?).to be_truthy
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -38,8 +38,8 @@ describe Jpmobile::Rack::MobileCarrier, "willcom" do
|
|
38
38
|
"QUERY_STRING" => "pos=N43.04.34.049E141.21.03.279")
|
39
39
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
40
40
|
|
41
|
-
env['rack.jpmobile'].position.lat.
|
42
|
-
env['rack.jpmobile'].position.lon.
|
41
|
+
expect(env['rack.jpmobile'].position.lat).to be_within(1e-4).of(43.078568)
|
42
|
+
expect(env['rack.jpmobile'].position.lon).to be_within(1e-4).of(141.347223)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -51,7 +51,7 @@ describe Jpmobile::Rack::MobileCarrier, "willcom" do
|
|
51
51
|
"REMOTE_ADDR" => "61.198.142.1")
|
52
52
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
53
53
|
|
54
|
-
env['rack.jpmobile'].valid_ip
|
54
|
+
expect(env['rack.jpmobile'].valid_ip?).to be_truthy
|
55
55
|
end
|
56
56
|
|
57
57
|
it "正しくないIPアドレス空間からのアクセスを判断できること" do
|
@@ -61,7 +61,7 @@ describe Jpmobile::Rack::MobileCarrier, "willcom" do
|
|
61
61
|
"REMOTE_ADDR" => "127.0.0.1")
|
62
62
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
63
63
|
|
64
|
-
env['rack.jpmobile'].valid_ip
|
64
|
+
expect(env['rack.jpmobile'].valid_ip?).to be_falsey
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -11,10 +11,10 @@ describe Jpmobile::Rack::MobileCarrier, "Windows Phone" do
|
|
11
11
|
'HTTP_USER_AGENT' => 'Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1 T-01A_6.5; Windows Phone 6.5)')
|
12
12
|
env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
13
13
|
|
14
|
-
env['rack.jpmobile'].class.
|
15
|
-
env['rack.jpmobile'].position.
|
16
|
-
env['rack.jpmobile'].smart_phone
|
17
|
-
env['rack.jpmobile'].supports_cookie
|
14
|
+
expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::WindowsPhone)
|
15
|
+
expect(env['rack.jpmobile'].position).to be_nil
|
16
|
+
expect(env['rack.jpmobile'].smart_phone?).to be_truthy
|
17
|
+
expect(env['rack.jpmobile'].supports_cookie?).to be_truthy
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -34,7 +34,7 @@ describe "decorated mails" do
|
|
34
34
|
|
35
35
|
it "top level content-type should be 'multipart/mixed'" do
|
36
36
|
@mail.rearrange!
|
37
|
-
@mail.content_type.
|
37
|
+
expect(@mail.content_type).to match('multipart/mixed')
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -52,7 +52,7 @@ describe "decorated mails" do
|
|
52
52
|
|
53
53
|
it "top level content-type should be 'multipart/mixed'" do
|
54
54
|
@mail.rearrange!
|
55
|
-
@mail.content_type.
|
55
|
+
expect(@mail.content_type).to match('multipart/mixed')
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -70,7 +70,7 @@ describe "decorated mails" do
|
|
70
70
|
|
71
71
|
it "top level content-type should be 'multipart/mixed'" do
|
72
72
|
@mail.rearrange!
|
73
|
-
@mail.content_type.
|
73
|
+
expect(@mail.content_type).to match('multipart/mixed')
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
data/spec/unit/email_spec.rb
CHANGED
@@ -22,7 +22,7 @@ describe 'Jpmobile::Email' do
|
|
22
22
|
].each do |email_addr, carrier|
|
23
23
|
it "#detect should return #{carrier} when take #{email_addr} as EmailAddr" do
|
24
24
|
Jpmobile::Email.japanese_mail_address_regexp = nil
|
25
|
-
Jpmobile::Email.detect(email_addr).
|
25
|
+
expect(Jpmobile::Email.detect(email_addr)).to eq(carrier)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -50,28 +50,28 @@ describe 'Jpmobile::Email' do
|
|
50
50
|
].each do |line, carrier|
|
51
51
|
it "#detect_from_mail_header should return #{carrier} when take mail header #{line}}" do
|
52
52
|
Jpmobile::Email.japanese_mail_address_regexp = nil
|
53
|
-
Jpmobile::Email.detect_from_mail_header(line).
|
53
|
+
expect(Jpmobile::Email.detect_from_mail_header(line)).to eq(carrier)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
describe "japanese_mail_address_regexp" do
|
58
58
|
it "#detect_from_mail_header should return Jpmobile::Mobile::AbstractMobile when hoge.jp" do
|
59
59
|
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp[^a-zA-Z\.\-]/)
|
60
|
-
Jpmobile::Email.detect_from_mail_header('From: Hoge Fuga <fuga@hoge.jp>').
|
60
|
+
expect(Jpmobile::Email.detect_from_mail_header('From: Hoge Fuga <fuga@hoge.jp>')).to eq(Jpmobile::Mobile::AbstractMobile)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "convertable?" do
|
65
65
|
it "return true when text/plain; charset=iso-2022-jp" do
|
66
|
-
Jpmobile::Email.convertable?('text/plain; charset=iso-2022-jp').
|
66
|
+
expect(Jpmobile::Email.convertable?('text/plain; charset=iso-2022-jp')).to be_truthy
|
67
67
|
end
|
68
68
|
|
69
69
|
it "return true when text/html; charset=shift_jis" do
|
70
|
-
Jpmobile::Email.convertable?('text/html; charset=shift_jis').
|
70
|
+
expect(Jpmobile::Email.convertable?('text/html; charset=shift_jis')).to be_truthy
|
71
71
|
end
|
72
72
|
|
73
73
|
it "return nil when image/jpeg; name=\"20098calendar01.jpg\"" do
|
74
|
-
Jpmobile::Email.convertable?('image/jpeg; name="20098calendar01.jpg"').
|
74
|
+
expect(Jpmobile::Email.convertable?('image/jpeg; name="20098calendar01.jpg"')).to be_nil
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
data/spec/unit/emoticon_spec.rb
CHANGED
@@ -7,127 +7,127 @@ describe Jpmobile::Emoticon do
|
|
7
7
|
describe "unicodecr_to_external" do
|
8
8
|
context "should convert unicodecr to docomo encoding" do
|
9
9
|
it "when no options" do
|
10
|
-
Jpmobile::Emoticon::unicodecr_to_external("").
|
10
|
+
expect(Jpmobile::Emoticon::unicodecr_to_external("")).to eq(sjis("\xf8\x9f"))
|
11
11
|
end
|
12
12
|
|
13
13
|
it "in multiple convertion" do
|
14
|
-
Jpmobile::Emoticon::unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, true).
|
14
|
+
expect(Jpmobile::Emoticon::unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, true)).to eq(sjis("\xf8\x9f\xf8\xa0"))
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
context "should convert unicodecr to au encoding" do
|
19
19
|
it "when no options" do
|
20
|
-
Jpmobile::Emoticon::unicodecr_to_external("").
|
20
|
+
expect(Jpmobile::Emoticon::unicodecr_to_external("")).to eq(sjis("\xf6\x59"))
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
context "should convert unicodecr to softbank encoding" do
|
25
25
|
it "when no opptions" do
|
26
|
-
Jpmobile::Emoticon::unicodecr_to_external("").
|
26
|
+
expect(Jpmobile::Emoticon::unicodecr_to_external("")).to eq([0xe001].pack('U'))
|
27
27
|
end
|
28
28
|
|
29
29
|
it "in multiple convertion" do
|
30
|
-
Jpmobile::Emoticon::unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, true).
|
30
|
+
expect(Jpmobile::Emoticon::unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, true)).to eq([0xe04a, 0xe049].pack('U*'))
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should convert docomo unicodecr to Unicode 6.0 emoticon' do
|
35
|
-
Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false).
|
35
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq([0x2600].pack('U'))
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should convert au unicodecr to Unicode 6.0 emoticon' do
|
39
|
-
Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false).
|
39
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq([0x26C5].pack('U'))
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should convert Softbank unicodecr to Unicode 6.0 emoticon' do
|
43
|
-
Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false).
|
43
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq([0x1F466].pack('U'))
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'should not convert 〓' do
|
47
|
-
Jpmobile::Emoticon.unicodecr_to_external("〓", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false).
|
47
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external("〓", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq('〓')
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'should convert docomo unicodecr to Google emoticon' do
|
51
|
-
Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false).
|
51
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq([0xFE000].pack('U'))
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'should convert au unicodecr to Google emoticon' do
|
55
|
-
Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false).
|
55
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq([0xFE00F].pack('U'))
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'should convert Softbank unicodecr to Google emoticon' do
|
59
|
-
Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false).
|
59
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq([0xFE19B].pack('U'))
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should not convert 〓' do
|
63
|
-
Jpmobile::Emoticon.unicodecr_to_external("〓", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false).
|
63
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external("〓", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq('〓')
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "unicodecr_to_utf8" do
|
68
68
|
it "should convert unicodecr to internal utf8 encoding" do
|
69
69
|
# docomo codepoint
|
70
|
-
Jpmobile::Emoticon::unicodecr_to_utf8("").
|
70
|
+
expect(Jpmobile::Emoticon::unicodecr_to_utf8("")).to eq(utf8("\356\230\276"))
|
71
71
|
# au codepoint
|
72
|
-
Jpmobile::Emoticon::unicodecr_to_utf8("").
|
72
|
+
expect(Jpmobile::Emoticon::unicodecr_to_utf8("")).to eq(utf8("\356\222\201"))
|
73
73
|
# softbank codepoint
|
74
|
-
Jpmobile::Emoticon::unicodecr_to_utf8("").
|
74
|
+
expect(Jpmobile::Emoticon::unicodecr_to_utf8("")).to eq(utf8("\xef\x80\x81"))
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
describe "utf8_to_unicodecr" do
|
79
79
|
it "should convert utf8 encoding to unicodecr" do
|
80
80
|
# docomo codepoint
|
81
|
-
Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\230\276")).
|
81
|
+
expect(Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\230\276"))).to eq("")
|
82
82
|
# au codepoint
|
83
|
-
Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\222\201")).
|
83
|
+
expect(Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\222\201"))).to eq("")
|
84
84
|
# softbank codepoint
|
85
|
-
Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\xef\x80\x81")).
|
85
|
+
expect(Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\xef\x80\x81"))).to eq("")
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
89
|
describe "external_to_unicodecr" do
|
90
90
|
it "should convert docomo encoding to unicodecr" do
|
91
|
-
Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\xf8\x9f")).
|
91
|
+
expect(Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\xf8\x9f"))).to eq("")
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should convert au encoding to unicodecr" do
|
95
|
-
Jpmobile::Emoticon::external_to_unicodecr_au(sjis("\xf6\x59")).
|
95
|
+
expect(Jpmobile::Emoticon::external_to_unicodecr_au(sjis("\xf6\x59"))).to eq("")
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should convert softbank encoding to unicodecr" do
|
99
|
-
Jpmobile::Emoticon::external_to_unicodecr_softbank([0xe001].pack('U')).
|
99
|
+
expect(Jpmobile::Emoticon::external_to_unicodecr_softbank([0xe001].pack('U'))).to eq("")
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should not convert docomo encoding of koukai-sjis emoticons to unicodecr" do
|
103
|
-
Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\x8c\xf6\x8a\x4a")).
|
103
|
+
expect(Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\x8c\xf6\x8a\x4a"))).to eq(sjis("\x8c\xf6\x8a\x4a"))
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'at iPhone emoticon' do
|
107
107
|
it 'should convert iPhone Unicode emoticon to SoftBank emoticon' do
|
108
|
-
Jpmobile::Emoticon::external_to_unicodecr_unicode60("\342\230\200").
|
108
|
+
expect(Jpmobile::Emoticon::external_to_unicodecr_unicode60("\342\230\200")).to eq("")
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'should convert iPhone Unicode emoticon to multi SoftBank emoticons' do
|
112
|
-
Jpmobile::Emoticon::external_to_unicodecr_unicode60("\342\233\205").
|
112
|
+
expect(Jpmobile::Emoticon::external_to_unicodecr_unicode60("\342\233\205")).to eq(",")
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'should not convert 〓' do
|
116
|
-
Jpmobile::Emoticon::external_to_unicodecr_unicode60('〓').
|
116
|
+
expect(Jpmobile::Emoticon::external_to_unicodecr_unicode60('〓')).to eq("〓")
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
context 'at Android emoticon' do
|
121
121
|
it 'should convert Android Google Unicode emoticon to Docomo emoticon' do
|
122
|
-
Jpmobile::Emoticon::external_to_unicodecr_google("\363\276\200\200").
|
122
|
+
expect(Jpmobile::Emoticon::external_to_unicodecr_google("\363\276\200\200")).to eq("")
|
123
123
|
end
|
124
124
|
|
125
125
|
it 'should convert Android Google Unicode emoticon to multi Docomo emoticon' do
|
126
|
-
Jpmobile::Emoticon::external_to_unicodecr_google("\363\276\200\217").
|
126
|
+
expect(Jpmobile::Emoticon::external_to_unicodecr_google("\363\276\200\217")).to eq("")
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'should not convert 〓' do
|
130
|
-
Jpmobile::Emoticon::external_to_unicodecr_google('〓').
|
130
|
+
expect(Jpmobile::Emoticon::external_to_unicodecr_google('〓')).to eq("〓")
|
131
131
|
end
|
132
132
|
end
|
133
133
|
end
|
@@ -135,19 +135,19 @@ describe Jpmobile::Emoticon do
|
|
135
135
|
context "for email" do
|
136
136
|
describe "au" do
|
137
137
|
it "should not convert 助助 that does not contain emoticons" do
|
138
|
-
Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("助助")).
|
138
|
+
expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("助助"))).not_to match(/e484/i)
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should not convert exterior of 2byte Kanji-code" do
|
142
|
-
Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("abcd=uしから=uずんば=u")).
|
142
|
+
expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("abcd=uしから=uずんば=u"))).not_to match(/e484/i)
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should not convert ascii string to unicodecr" do
|
146
|
-
Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("-------=_NextPart_15793_72254_63179")).
|
146
|
+
expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("-------=_NextPart_15793_72254_63179"))).not_to match(/e5c2/i)
|
147
147
|
end
|
148
148
|
|
149
149
|
it "should not include extra JIS escape sequence between Kanji-code and emoticon" do
|
150
|
-
Jpmobile::Emoticon.unicodecr_to_au_email(utf8_to_jis("掲示板")).
|
150
|
+
expect(Jpmobile::Emoticon.unicodecr_to_au_email(utf8_to_jis("掲示板"))).to eq(Jpmobile::Util.ascii_8bit("\x1b\x24\x42\x75\x3a\x37\x47\x3C\x28\x48\x44\x1b\x28\x42"))
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|