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
@@ -17,32 +17,32 @@ describe "Jpmobile::Mail#receive" do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "subject should be parsed correctly" do
|
20
|
-
@mail.subject.
|
20
|
+
expect(@mail.subject).to eq("タイトルの長いメールの場合の対処を実装するためのテストケースとしてのメールに含まれている件名であるサブジェクト部分")
|
21
21
|
end
|
22
22
|
|
23
23
|
it "body should be parsed correctly" do
|
24
|
-
@mail.body.to_s.
|
24
|
+
expect(@mail.body.to_s).to eq("本文です\n\n")
|
25
25
|
end
|
26
26
|
|
27
27
|
context "to_s" do
|
28
28
|
it "should have subject which is same as original" do
|
29
|
-
ascii_8bit(@mail.to_s).
|
29
|
+
expect(ascii_8bit(@mail.to_s)).to match("GyRCJT8lJCVIJWskTkQ5JCQlYSE8JWskTj5s")
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should have body which is same as original" do
|
33
|
-
ascii_8bit(@mail.to_s).
|
33
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis("本文です")))))
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
context "modify and to_s" do
|
38
38
|
it "should encode subject correctly" do
|
39
39
|
@mail.subject = "大江戸"
|
40
|
-
ascii_8bit(@mail.to_s).
|
40
|
+
expect(ascii_8bit(@mail.to_s)).to match("GyRCQmc5PjhNGyhC")
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should encode body correctly" do
|
44
44
|
@mail.body = "会議が開催"
|
45
|
-
ascii_8bit(@mail.to_s).
|
45
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis("会議が開催")))))
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -54,16 +54,16 @@ describe "Jpmobile::Mail#receive" do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "subject should be parsed correctly" do
|
57
|
-
@mail.subject.
|
57
|
+
expect(@mail.subject).to eq("タイトルの長いメールの場合の対処を実装するためのテストケースとしてのメールに含まれている件名であるサブジェクト部分")
|
58
58
|
end
|
59
59
|
|
60
60
|
it "body should be parsed correctly" do
|
61
|
-
@mail.body.parts.size.
|
62
|
-
@mail.body.parts.first.body.to_s.
|
61
|
+
expect(@mail.body.parts.size).to eq(2)
|
62
|
+
expect(@mail.body.parts.first.body.to_s).to eq("本文です\n\n")
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should encode correctly" do
|
66
|
-
ascii_8bit(@mail.to_s).
|
66
|
+
expect(ascii_8bit(@mail.to_s)).to match(/GyRCJT8lJCVIJWskTkQ5JCQlYSE8JWskTj5s/)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -73,12 +73,12 @@ describe "Jpmobile::Mail#receive" do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it "body should be parsed correctly" do
|
76
|
-
@mail.body.parts.size.
|
77
|
-
@mail.body.parts.first.body.to_s.
|
76
|
+
expect(@mail.body.parts.size).to eq(2)
|
77
|
+
expect(@mail.body.parts.first.body.to_s).to eq("本文です\n\n")
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should encode correctly" do
|
81
|
-
ascii_8bit(@mail.to_s).
|
81
|
+
expect(ascii_8bit(@mail.to_s)).to match(/GODlhAQABAIAAAAAAAP/)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -88,18 +88,18 @@ describe "Jpmobile::Mail#receive" do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
it "subject should be parsed correctly" do
|
91
|
-
@mail.subject.
|
91
|
+
expect(@mail.subject).to eq("テスト")
|
92
92
|
end
|
93
93
|
|
94
94
|
it "body should be parsed correctly" do
|
95
|
-
@mail.body.parts.size.
|
95
|
+
expect(@mail.body.parts.size).to eq(1)
|
96
96
|
@mail.body.parts.first.parts.size == 2
|
97
|
-
@mail.body.parts.first.parts.first.body.
|
98
|
-
@mail.body.parts.first.parts.last.body.raw_source.
|
97
|
+
expect(@mail.body.parts.first.parts.first.body).to match("テストです")
|
98
|
+
expect(@mail.body.parts.first.parts.last.body.raw_source).to match("テストです")
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should encode correctly" do
|
102
|
-
@mail.to_s.
|
102
|
+
expect(@mail.to_s).to match(Regexp.escape("g2WDWINn+ZE"))
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -109,18 +109,18 @@ describe "Jpmobile::Mail#receive" do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it "subject should be parsed correctly" do
|
112
|
-
@mail.subject.
|
112
|
+
expect(@mail.subject).to eq("テスト")
|
113
113
|
end
|
114
114
|
|
115
115
|
it "body should be parsed correctly" do
|
116
|
-
@mail.body.parts.size.
|
116
|
+
expect(@mail.body.parts.size).to eq(1)
|
117
117
|
@mail.body.parts.first.parts.size == 1
|
118
|
-
@mail.body.parts.first.parts.first.body.to_s.
|
119
|
-
@mail.body.parts.first.parts.last.body.raw_source.
|
118
|
+
expect(@mail.body.parts.first.parts.first.body.to_s).to match("テストです")
|
119
|
+
expect(@mail.body.parts.first.parts.last.body.raw_source).to match("テストです")
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should encode correctly" do
|
123
|
-
ascii_8bit(@mail.to_s).
|
123
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.escape("GyRCJUYlOSVIdk8bKEI="))
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -131,16 +131,16 @@ describe "Jpmobile::Mail#receive" do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
it "subject should be parsed correctly" do
|
134
|
-
@mail.subject.
|
134
|
+
expect(@mail.subject).to eq("テスト")
|
135
135
|
end
|
136
136
|
|
137
137
|
it "body should be parsed correctly" do
|
138
|
-
@mail.body.parts.size.
|
139
|
-
@mail.body.parts.first.body.to_s.
|
138
|
+
expect(@mail.body.parts.size).to eq(2)
|
139
|
+
expect(@mail.body.parts.first.body.to_s).to eq("テストです")
|
140
140
|
end
|
141
141
|
|
142
142
|
it "should encode correctly" do
|
143
|
-
@mail.to_s.
|
143
|
+
expect(@mail.to_s).to match(Regexp.escape("g2WDWINn98H3w/fB"))
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -150,16 +150,16 @@ describe "Jpmobile::Mail#receive" do
|
|
150
150
|
end
|
151
151
|
|
152
152
|
it "subject should be parsed correctly" do
|
153
|
-
@mail.subject.
|
153
|
+
expect(@mail.subject).to eq("テストです")
|
154
154
|
end
|
155
155
|
|
156
156
|
it "body should be parsed correctly" do
|
157
|
-
@mail.body.parts.size.
|
158
|
-
@mail.body.parts.first.body.raw_source.
|
157
|
+
expect(@mail.body.parts.size).to eq(2)
|
158
|
+
expect(@mail.body.parts.first.body.raw_source).to eq("テストです")
|
159
159
|
end
|
160
160
|
|
161
161
|
it "should encode correctly to Shift_JIS" do
|
162
|
-
@mail.to_s.
|
162
|
+
expect(@mail.to_s).to match(Regexp.escape("g2WDWINngsWCt/fB"))
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
@@ -167,8 +167,8 @@ describe "Jpmobile::Mail#receive" do
|
|
167
167
|
context 'bounced mail' do
|
168
168
|
it 'should parse sub-part charset correctly' do
|
169
169
|
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/bounce_with_utf8_part.eml")).read)
|
170
|
-
@mail.parts.first.charset.
|
171
|
-
@mail.parts.last.charset.
|
170
|
+
expect(@mail.parts.first.charset).to match(/iso-2022-jp/i)
|
171
|
+
expect(@mail.parts.last.charset).to match(/utf-8/i)
|
172
172
|
end
|
173
173
|
end
|
174
174
|
end
|
@@ -179,32 +179,32 @@ describe "Jpmobile::Mail#receive" do
|
|
179
179
|
end
|
180
180
|
|
181
181
|
it "subject should be parsed correctly" do
|
182
|
-
@mail.subject.
|
182
|
+
expect(@mail.subject).to eq("題名")
|
183
183
|
end
|
184
184
|
|
185
185
|
it "body should be parsed correctly" do
|
186
|
-
@mail.body.to_s.
|
186
|
+
expect(@mail.body.to_s).to eq("本文\nFor docomo\n\n")
|
187
187
|
end
|
188
188
|
|
189
189
|
context "to_s" do
|
190
190
|
it "should have subject which is same as original" do
|
191
|
-
@mail.to_s.
|
191
|
+
expect(@mail.to_s).to match(Regexp.escape("keiWvPjX"))
|
192
192
|
end
|
193
193
|
|
194
194
|
it "should have body which is same as original" do
|
195
|
-
@mail.to_s.
|
195
|
+
expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis("本文")))
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
199
|
context "modify and to_s" do
|
200
200
|
it "should encode subject correctly" do
|
201
201
|
@mail.subject = "大江戸"
|
202
|
-
@mail.to_s.
|
202
|
+
expect(@mail.to_s).to match(Regexp.escape("keWNXYzL+J8="))
|
203
203
|
end
|
204
204
|
|
205
205
|
it "should encode body correctly" do
|
206
206
|
@mail.body = "会議が開催"
|
207
|
-
@mail.to_s.
|
207
|
+
expect(@mail.to_s).to match(sjis_regexp(sjis("\x89\xEF\x8Bc\x82\xAA\x8AJ\x8D\xC3\xF8\xA7")))
|
208
208
|
end
|
209
209
|
end
|
210
210
|
end
|
@@ -216,85 +216,85 @@ describe "Jpmobile::Mail#receive" do
|
|
216
216
|
end
|
217
217
|
|
218
218
|
it "subject should be parsed correctly" do
|
219
|
-
@mail.subject.
|
219
|
+
expect(@mail.subject).to eq("題名")
|
220
220
|
end
|
221
221
|
|
222
222
|
it "body should be parsed correctly" do
|
223
|
-
@mail.body.to_s.
|
223
|
+
expect(@mail.body.to_s).to eq("本文\nFor au\n\n")
|
224
224
|
end
|
225
225
|
|
226
226
|
context "to_s" do
|
227
227
|
it "should have subject which is same as original" do
|
228
|
-
ascii_8bit(@mail.to_s).
|
228
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.escape("GyRCQmpMPnZeGyhC"))
|
229
229
|
end
|
230
230
|
|
231
231
|
it "should have body which is same as original" do
|
232
|
-
ascii_8bit(@mail.to_s).
|
232
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit("\e\x24\x42\x4B\x5C\x4A\x38\x76\x7D\e\x28\x42"))))
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
236
236
|
context "modify and to_s" do
|
237
237
|
it "should encode subject correctly" do
|
238
238
|
@mail.subject = "大江戸"
|
239
|
-
ascii_8bit(@mail.to_s).
|
239
|
+
expect(ascii_8bit(@mail.to_s)).to match(/\?GyRCQmc5PjhNdUEbKEI=/)
|
240
240
|
end
|
241
241
|
|
242
242
|
it "should encode body correctly" do
|
243
243
|
@mail.body = "会議が開催"
|
244
|
-
ascii_8bit(@mail.to_s).
|
244
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit("\x1b\x24\x42\x32\x71\x35\x44\x24\x2C\x33\x2B\x3A\x45\x75\x48\x1b\x28\x42"))))
|
245
245
|
end
|
246
246
|
end
|
247
247
|
end
|
248
248
|
|
249
249
|
it "should not be raised when parsing incoming email #41" do
|
250
|
-
|
250
|
+
expect {
|
251
251
|
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/au-email.eml")).read)
|
252
|
-
}.
|
252
|
+
}.not_to raise_error
|
253
253
|
end
|
254
254
|
|
255
255
|
it "should not be raised when parsing incoming email #45" do
|
256
|
-
|
256
|
+
expect {
|
257
257
|
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/au-decomail2.eml")).read)
|
258
|
-
}.
|
258
|
+
}.not_to raise_error
|
259
259
|
end
|
260
260
|
|
261
261
|
it "should not be raised when parsing incoming email - include kigou" do
|
262
|
-
|
262
|
+
expect {
|
263
263
|
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/au-kigou.eml")).read)
|
264
|
-
}.
|
264
|
+
}.not_to raise_error
|
265
265
|
end
|
266
266
|
|
267
267
|
context 'From au iPhone' do
|
268
268
|
it 'charset should be UTF-8' do
|
269
269
|
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-message.eml")).read)
|
270
|
-
@mail.mobile.
|
271
|
-
@mail.charset.
|
270
|
+
expect(@mail.mobile).to be_a(Jpmobile::Mobile::Au)
|
271
|
+
expect(@mail.charset).to match(/utf-8/i)
|
272
272
|
end
|
273
273
|
|
274
274
|
it 'should be encoded correctly' do
|
275
275
|
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-message.eml")).read)
|
276
|
-
@mail.encoded.
|
276
|
+
expect(@mail.encoded).to match(Regexp.escape("%[\e$B1`;yL>\e(B]%\e$B$N\e(B%[\e$BJ]8n<TL>\e(B]%"))
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
280
280
|
context 'From iPad' do
|
281
281
|
it 'charset should be UTF-8' do
|
282
282
|
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-mail3.eml")).read)
|
283
|
-
@mail.mobile.
|
284
|
-
@mail.charset.
|
283
|
+
expect(@mail.mobile).to be_a(Jpmobile::Mobile::AbstractMobile)
|
284
|
+
expect(@mail.charset).to match(/utf-8/i)
|
285
285
|
end
|
286
286
|
|
287
287
|
it 'should be encoded correctly' do
|
288
288
|
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-mail3.eml")).read)
|
289
|
-
@mail.encoded.
|
289
|
+
expect(@mail.encoded).to match(/BK\\J82~9T\$J\$7!2#5#1#2J8;z!2/)
|
290
290
|
end
|
291
291
|
end
|
292
292
|
|
293
293
|
it 'should not raise when parsing attached email' do
|
294
|
-
|
294
|
+
expect {
|
295
295
|
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/au-attached.eml")).read)
|
296
|
-
@mail.encoded.
|
297
|
-
}.
|
296
|
+
expect(@mail.encoded).to match('/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAPQAA')
|
297
|
+
}.not_to raise_error
|
298
298
|
end
|
299
299
|
end
|
300
300
|
|
@@ -304,32 +304,32 @@ describe "Jpmobile::Mail#receive" do
|
|
304
304
|
end
|
305
305
|
|
306
306
|
it "subject should be parsed correctly" do
|
307
|
-
@mail.subject.
|
307
|
+
expect(@mail.subject).to eq("題名")
|
308
308
|
end
|
309
309
|
|
310
310
|
it "body should be parsed correctly" do
|
311
|
-
@mail.body.to_s.
|
311
|
+
expect(@mail.body.to_s).to eq("本文\nFor softbank\n\n")
|
312
312
|
end
|
313
313
|
|
314
314
|
context "to_s" do
|
315
315
|
it "should have subject which is same as original" do
|
316
|
-
@mail.to_s.
|
316
|
+
expect(@mail.to_s).to match(sjis_regexp("keiWvPl8"))
|
317
317
|
end
|
318
318
|
|
319
319
|
it "should have body which is same as original" do
|
320
|
-
@mail.to_s.
|
320
|
+
expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis("本文")))
|
321
321
|
end
|
322
322
|
end
|
323
323
|
|
324
324
|
context "modify and to_s" do
|
325
325
|
it "should encode subject correctly" do
|
326
326
|
@mail.subject = "大江戸"
|
327
|
-
@mail.to_s.
|
327
|
+
expect(@mail.to_s).to match(Regexp.escape("keWNXYzL+Ys="))
|
328
328
|
end
|
329
329
|
|
330
330
|
it "should encode body correctly" do
|
331
331
|
@mail.body = "会議が開催"
|
332
|
-
@mail.to_s.
|
332
|
+
expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis("会議が開催") + sjis("\xf7\xdf")))
|
333
333
|
end
|
334
334
|
end
|
335
335
|
end
|
@@ -340,11 +340,11 @@ describe "Jpmobile::Mail#receive" do
|
|
340
340
|
end
|
341
341
|
|
342
342
|
it "subject should be parsed correctly" do
|
343
|
-
@mail.subject.
|
343
|
+
expect(@mail.subject).to be_blank
|
344
344
|
end
|
345
345
|
|
346
346
|
it "body should be parsed correctly" do
|
347
|
-
@mail.body.to_s.
|
347
|
+
expect(@mail.body.to_s).to be_blank
|
348
348
|
end
|
349
349
|
end
|
350
350
|
|
@@ -355,11 +355,11 @@ describe "Jpmobile::Mail#receive" do
|
|
355
355
|
end
|
356
356
|
|
357
357
|
it "subject should be parsed correctly" do
|
358
|
-
@mail.subject.
|
358
|
+
expect(@mail.subject).to eq("テスト")
|
359
359
|
end
|
360
360
|
|
361
361
|
it "body should be parsed correctly" do
|
362
|
-
@mail.body.to_s.
|
362
|
+
expect(@mail.body.to_s).to eq("テスト本文\n\n")
|
363
363
|
end
|
364
364
|
end
|
365
365
|
end
|
@@ -371,7 +371,7 @@ describe "Jpmobile::Mail#receive" do
|
|
371
371
|
end
|
372
372
|
|
373
373
|
it "mobile should abstract mobile" do
|
374
|
-
@mail.mobile.
|
374
|
+
expect(@mail.mobile).to be_a Jpmobile::Mobile::AbstractMobile
|
375
375
|
end
|
376
376
|
end
|
377
377
|
end
|
@@ -383,8 +383,8 @@ describe "Jpmobile::Mail#receive" do
|
|
383
383
|
end
|
384
384
|
|
385
385
|
it "mobile should be nil" do
|
386
|
-
@mail.mobile.
|
387
|
-
@mail.parts.first.charset.
|
386
|
+
expect(@mail.mobile).to be_nil
|
387
|
+
expect(@mail.parts.first.charset).to eq('us-ascii')
|
388
388
|
end
|
389
389
|
end
|
390
390
|
|
@@ -394,8 +394,8 @@ describe "Jpmobile::Mail#receive" do
|
|
394
394
|
end
|
395
395
|
|
396
396
|
it "mobile should be nil" do
|
397
|
-
@mail.mobile.
|
398
|
-
@mail.parts.first.charset.
|
397
|
+
expect(@mail.mobile).to be_nil
|
398
|
+
expect(@mail.parts.first.charset).to eq('iso-8859-1')
|
399
399
|
end
|
400
400
|
end
|
401
401
|
end
|
data/spec/unit/util_spec.rb
CHANGED
@@ -7,106 +7,106 @@ describe Jpmobile::Util do
|
|
7
7
|
include Jpmobile::Util
|
8
8
|
|
9
9
|
it 'nilのときはnilを返すこと' do
|
10
|
-
deep_apply(nil) {|obj| obj }.
|
10
|
+
expect(deep_apply(nil) {|obj| obj }).to equal(nil)
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'trueのときはtrueを返すこと' do
|
14
|
-
deep_apply(true) {|obj| obj }.
|
14
|
+
expect(deep_apply(true) {|obj| obj }).to equal(true)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'falseのときはそのまま値を返すこと' do
|
18
|
-
deep_apply(false) {|obj| obj }.
|
18
|
+
expect(deep_apply(false) {|obj| obj }).to equal(false)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'Tempfileのインスタンスのときはそのまま値を返すこと' do
|
22
22
|
temp = Tempfile.new('test')
|
23
|
-
deep_apply(temp) {|obj| obj}.object_id.
|
23
|
+
expect(deep_apply(temp) {|obj| obj}.object_id).to equal(temp.object_id)
|
24
24
|
# 本来 deep_apply(temp) {|obj| obj }.should equal(temp) が通るべきのような。
|
25
25
|
# 参考 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/41720
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'StringIOのインスタンスのときはそのまま値を返すこと' do
|
29
29
|
string_io = StringIO.new('test')
|
30
|
-
deep_apply(string_io) {|obj| obj }.
|
30
|
+
expect(deep_apply(string_io) {|obj| obj }).to equal(string_io)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "utf8_to_sjis で変換できない文字列が含んでいた場合?に変換される" do
|
34
|
-
utf8_to_sjis("اللغة العربية").
|
34
|
+
expect(utf8_to_sjis("اللغة العربية")).to eq(sjis("????? ???????"))
|
35
35
|
end
|
36
36
|
|
37
37
|
it "utf8_to_sjis ですべての改行コードが CRLF に変更されること" do
|
38
|
-
utf8_to_sjis("UTF8\rSAMPLE\nTEXT\r\n").
|
38
|
+
expect(utf8_to_sjis("UTF8\rSAMPLE\nTEXT\r\n")).to eq(sjis("UTF8\r\nSAMPLE\r\nTEXT\r\n"))
|
39
39
|
end
|
40
40
|
|
41
41
|
it "0x8150がU+FFE3に変換されること" do
|
42
|
-
sjis_to_utf8(sjis("\x81\x50")).
|
42
|
+
expect(sjis_to_utf8(sjis("\x81\x50"))).to eq([0xffe3].pack("U"))
|
43
43
|
end
|
44
44
|
|
45
45
|
it "U+FFE3が0x8150に変換されること" do
|
46
|
-
utf8_to_sjis([0xffe3].pack("U")).
|
46
|
+
expect(utf8_to_sjis([0xffe3].pack("U"))).to eq(sjis("\x81\x50"))
|
47
47
|
end
|
48
48
|
|
49
49
|
it "U+203Eが0x8150に変換されること" do
|
50
|
-
utf8_to_sjis([0x203e].pack("U")).
|
50
|
+
expect(utf8_to_sjis([0x203e].pack("U"))).to eq(sjis("\x81\x50"))
|
51
51
|
end
|
52
52
|
|
53
53
|
it "U+2014が0x815Cに変換されること" do
|
54
|
-
utf8_to_sjis([0x2014].pack("U")).
|
54
|
+
expect(utf8_to_sjis([0x2014].pack("U"))).to eq(sjis("\x81\x5C"))
|
55
55
|
end
|
56
56
|
|
57
57
|
it "U+2212が0x817Cに変換されること" do
|
58
|
-
utf8_to_sjis([0x2212].pack("U")).
|
58
|
+
expect(utf8_to_sjis([0x2212].pack("U"))).to eq(sjis("\x81\x7C"))
|
59
59
|
end
|
60
60
|
|
61
61
|
it "jis_string_regexpでISO-2022-JPの文字列がマッチすること" do
|
62
|
-
jis_string_regexp.match(ascii_8bit(utf8_to_jis("abcしからずんばこじをえずdef"))).
|
63
|
-
jis_to_utf8(jis("\x1b\x24\x42#{$1}\x1b\x28\x42")).
|
62
|
+
expect(jis_string_regexp.match(ascii_8bit(utf8_to_jis("abcしからずんばこじをえずdef")))).not_to be_nil
|
63
|
+
expect(jis_to_utf8(jis("\x1b\x24\x42#{$1}\x1b\x28\x42"))).to eq("しからずんばこじをえず")
|
64
64
|
end
|
65
65
|
|
66
66
|
it "sjis_to_utf8 ですべての改行コードが LF に変更されること" do
|
67
|
-
sjis_to_utf8("SJIS\rSAMPLE\nTEXT\r\n").
|
67
|
+
expect(sjis_to_utf8("SJIS\rSAMPLE\nTEXT\r\n")).to eq(utf8("SJIS\nSAMPLE\nTEXT\n"))
|
68
68
|
end
|
69
69
|
|
70
70
|
it "utf8_to_sjis で変換できない文字列が含んでいた場合?に変換される" do
|
71
|
-
utf8_to_jis("اللغة العربية").
|
71
|
+
expect(utf8_to_jis("اللغة العربية")).to eq(jis("????? ???????"))
|
72
72
|
end
|
73
73
|
|
74
74
|
it "utf8_to_jis ですべての改行コードが CRLF に変更されること" do
|
75
|
-
utf8_to_jis("UTF8\rSAMPLE\nTEXT\r\n").
|
75
|
+
expect(utf8_to_jis("UTF8\rSAMPLE\nTEXT\r\n")).to eq(jis("UTF8\r\nSAMPLE\r\nTEXT\r\n"))
|
76
76
|
end
|
77
77
|
|
78
78
|
it "jis_to_utf8 ですべての改行コードが LF に変更されること" do
|
79
|
-
jis_to_utf8("JIS\rSAMPLE\nTEXT\r\n").
|
79
|
+
expect(jis_to_utf8("JIS\rSAMPLE\nTEXT\r\n")).to eq(utf8("JIS\nSAMPLE\nTEXT\n"))
|
80
80
|
end
|
81
81
|
|
82
82
|
it "fold_textでUTF-8の日本語文字列が指定文字数で折り返された配列で返ること" do
|
83
|
-
fold_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15).
|
83
|
+
expect(fold_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15)).to eq([
|
84
84
|
'長い日本語の題名で折り返される',
|
85
85
|
'かようにするには事前に分割して',
|
86
86
|
'いないとダメなことがわかりまし',
|
87
87
|
'たよ'
|
88
|
-
]
|
88
|
+
])
|
89
89
|
end
|
90
90
|
|
91
91
|
it "fold_textでUTF-8の短い文字列は折り返されないこと" do
|
92
|
-
fold_text('短い', 15).
|
92
|
+
expect(fold_text('短い', 15)).to eq(['短い'])
|
93
93
|
end
|
94
94
|
|
95
95
|
it "split_textでUTF-8の日本語文字列が指定文字数で2つに分割されること" do
|
96
|
-
split_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15).
|
96
|
+
expect(split_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15)).to eq([
|
97
97
|
'長い日本語の題名で折り返される',
|
98
98
|
'かようにするには事前に分割していないとダメなことがわかりましたよ'
|
99
|
-
]
|
99
|
+
])
|
100
100
|
end
|
101
101
|
|
102
102
|
it "split_textでnilかblankの場合はnilが返ること" do
|
103
|
-
split_text('', 15).
|
104
|
-
split_text(nil, 15).
|
103
|
+
expect(split_text('', 15)).to be_nil
|
104
|
+
expect(split_text(nil, 15)).to be_nil
|
105
105
|
end
|
106
106
|
|
107
107
|
it "全角チルダがjisに適切に変換されること" do
|
108
|
-
ascii_8bit(utf8_to_jis("\xef\xbd\x9e")).
|
109
|
-
ascii_8bit(encode("\xef\xbd\x9e", "ISO-2022-JP")).
|
108
|
+
expect(ascii_8bit(utf8_to_jis("\xef\xbd\x9e"))).to eq(ascii_8bit("\x1b\x24\x42\x21\x41\x1b\x28\x42"))
|
109
|
+
expect(ascii_8bit(encode("\xef\xbd\x9e", "ISO-2022-JP"))).to eq(ascii_8bit("\x1b\x24\x42\x21\x41\x1b\x28\x42"))
|
110
110
|
end
|
111
111
|
|
112
112
|
describe 'invert_table' do
|
@@ -117,8 +117,8 @@ describe Jpmobile::Util do
|
|
117
117
|
0xFE00B => 0x3013,
|
118
118
|
0xFE010 => 0xE6B3,
|
119
119
|
0xFE038 => 0xE73F})
|
120
|
-
hash[0xE63E].
|
121
|
-
hash[0x3013].
|
120
|
+
expect(hash[0xE63E]).to eq(0xFE009)
|
121
|
+
expect(hash[0x3013]).to eq(0xFE00B)
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'should not raise error when hash has Array keys' do
|
@@ -128,27 +128,27 @@ describe Jpmobile::Util do
|
|
128
128
|
0x1F526 => 0xE6FB,
|
129
129
|
[0x0023, 0x20E3] => 0xE6E0,
|
130
130
|
0x1F354 => 0xE673})
|
131
|
-
hash[0x3013].
|
132
|
-
hash[0xE6FB].
|
131
|
+
expect(hash[0x3013]).to eq([0x1F1E8, 0x1F1F3])
|
132
|
+
expect(hash[0xE6FB]).to eq(0x1F526)
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
describe 'check_charset' do
|
137
137
|
it 'returns true if compatible' do
|
138
138
|
str = 'ABC'.force_encoding('ASCII-8BIT')
|
139
|
-
check_charset(str, 'UTF-8').
|
139
|
+
expect(check_charset(str, 'UTF-8')).to be_truthy
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'returns false if incompatible' do
|
143
143
|
str = '再現'.encode('ISO-2022-JP')
|
144
|
-
check_charset(str, 'UTF-8').
|
144
|
+
expect(check_charset(str, 'UTF-8')).to be_falsey
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
148
|
describe 'correct_encoding' do
|
149
149
|
it 'updates encoding correctly' do
|
150
150
|
str = '再現'.force_encoding('ISO-2022-JP')
|
151
|
-
correct_encoding(str).encoding.
|
151
|
+
expect(correct_encoding(str).encoding).to eq(Encoding::UTF_8)
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
data/spec/unit/valid_ip_spec.rb
CHANGED
@@ -18,7 +18,7 @@ describe 'Jpmobile::Mobile::valid_ip?' do
|
|
18
18
|
[ '117.55.1.254' , :Emobile ],
|
19
19
|
].each do |remote_ip, carrier|
|
20
20
|
it "should be return true if #{remote_ip} is in #{:carrier} address" do
|
21
|
-
Jpmobile::Mobile.const_get(carrier).valid_ip?(remote_ip).
|
21
|
+
expect(Jpmobile::Mobile.const_get(carrier).valid_ip?(remote_ip)).to eq(true)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -45,7 +45,7 @@ describe 'Jpmobile::Mobile::valid_ip?' do
|
|
45
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
|
-
Jpmobile::Mobile.const_get(carrier).valid_ip?(remote_ip).
|
48
|
+
expect(Jpmobile::Mobile.const_get(carrier).valid_ip?(remote_ip)).not_to eq(true)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|