jpmobile 0.1.6 → 1.0.0.pre
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.
- data/README +0 -0
- data/README.rdoc +58 -29
- data/Rakefile +1 -1
- data/VERSION.yml +4 -4
- data/lib/jpmobile.rb +3 -0
- data/lib/jpmobile/email.rb +17 -2
- data/lib/jpmobile/emoticon.rb +87 -23
- data/lib/jpmobile/emoticon/au.rb +644 -0
- data/lib/jpmobile/emoticon/softbank.rb +488 -0
- data/lib/jpmobile/emoticon/z_combine.rb +16 -13
- data/lib/jpmobile/hook_action_controller.rb +1 -13
- data/lib/jpmobile/hook_action_view.rb +3 -62
- data/lib/jpmobile/mail.rb +316 -0
- data/lib/jpmobile/mailer.rb +31 -0
- data/lib/jpmobile/mobile/abstract_mobile.rb +66 -0
- data/lib/jpmobile/mobile/au.rb +25 -2
- data/lib/jpmobile/mobile/docomo.rb +23 -1
- data/lib/jpmobile/mobile/emobile.rb +1 -1
- data/lib/jpmobile/mobile/softbank.rb +33 -1
- data/lib/jpmobile/mobile/vodafone.rb +1 -1
- data/lib/jpmobile/mobile/willcom.rb +1 -1
- data/lib/jpmobile/path_set.rb +40 -0
- data/lib/jpmobile/rails.rb +24 -0
- data/lib/jpmobile/resolver.rb +38 -0
- data/lib/jpmobile/util.rb +223 -14
- data/lib/tasks/jpmobile_tasks.rake +41 -48
- data/spec/rack/jpmobile/emoticon_spec.rb +3 -8
- data/spec/rack/jpmobile/filter_spec.rb +1 -1
- data/spec/rack/jpmobile/params_filter_spec.rb +4 -4
- data/spec/rack_helper.rb +5 -9
- data/spec/unit/detect_by_email_spec.rb +29 -0
- data/spec/unit/emoticon_spec.rb +90 -0
- data/spec/unit/encoding_spec.rb +102 -0
- data/spec/unit/mail_spec.rb +117 -0
- data/spec/unit/receive_mail_spec.rb +289 -0
- data/spec/unit/spec_helper.rb +8 -0
- data/spec/unit/util_spec.rb +5 -0
- data/test/rails/overrides/app/controllers/application_controller.rb +3 -2
- data/test/rails/overrides/app/controllers/template_path_controller.rb +8 -0
- data/test/rails/overrides/app/models/mobile_mailer.rb +19 -0
- data/test/rails/overrides/app/models/normal_mailer.rb +9 -0
- data/test/rails/overrides/spec/models/mobile_mailer_spec.rb +737 -0
- data/test/rails/overrides/spec/models/normal_mailer_spec.rb +34 -0
- data/test/rails/overrides/spec/requests/template_path_spec.rb +13 -7
- data/test/rails/overrides/spec/spec_helper.rb +6 -0
- data/test/rails/rails_root/app/controllers/application_controller.rb +3 -2
- data/test/rails/rails_root/app/controllers/template_path_controller.rb +8 -0
- data/test/rails/rails_root/app/models/mobile_mailer.rb +2 -1
- data/test/rails/rails_root/app/models/normal_mailer.rb +9 -0
- data/test/rails/rails_root/config/initializers/secret_token.rb +1 -1
- data/test/rails/rails_root/spec/models/mobile_mailer_spec.rb +73 -80
- data/test/rails/rails_root/spec/models/normal_mailer_spec.rb +34 -0
- data/test/rails/rails_root/spec/requests/template_path_spec.rb +13 -7
- data/test/rails/rails_root/spec/spec_helper.rb +1 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile.rb +2 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb +7 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_controller.rb +1 -13
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_view.rb +3 -62
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mail.rb +162 -111
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mailer.rb +31 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +34 -3
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/au.rb +2 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/docomo.rb +4 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/softbank.rb +7 -8
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/path_set.rb +40 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/params_filter.rb +1 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb +24 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/resolver.rb +38 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +33 -23
- metadata +43 -14
- data/test/legacy/emoticon_test.rb +0 -63
- data/test/legacy/helper.rb +0 -8
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_mailer.rb +0 -22
@@ -0,0 +1,117 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
3
|
+
require 'mail'
|
4
|
+
require 'jpmobile/mail'
|
5
|
+
|
6
|
+
describe "Jpmobile::Mail" do
|
7
|
+
include Jpmobile::Util
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
@mail = Mail.new
|
11
|
+
@mail.subject = "万葉"
|
12
|
+
@mail.body = "ほげ"
|
13
|
+
@mail.from = "info@jpmobile-rails.org"
|
14
|
+
end
|
15
|
+
|
16
|
+
context "Mail#to" do
|
17
|
+
it "sets multi-tos" do
|
18
|
+
expect{@mail.to = ["a@hoge.com", "b@hoge.com"]}.to_not raise_error
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "AbstractMobile" do
|
23
|
+
before(:each) do
|
24
|
+
@mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
|
25
|
+
@mail.mobile = @mobile
|
26
|
+
@mail.to = "info+to@jpmobile-rails.org"
|
27
|
+
end
|
28
|
+
|
29
|
+
context "to_s" do
|
30
|
+
it "should contain encoded subject" do
|
31
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCS3xNVRsoQg==?=")))
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should contain encoded body" do
|
35
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape(ascii_8bit("\x1b\x24\x42\x24\x5B\x24\x32\e\x28\x42"))))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "Docomo" do
|
41
|
+
before(:each) do
|
42
|
+
@mobile = Jpmobile::Mobile::Docomo.new(nil, nil)
|
43
|
+
@mail.mobile = @mobile
|
44
|
+
@mail.to = "info+to@jpmobile-rails.org"
|
45
|
+
end
|
46
|
+
|
47
|
+
context "to_s" do
|
48
|
+
it "should contain encoded subject" do
|
49
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?lpyXdA==?="))
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should contain encoded body" do
|
53
|
+
@mail.to_s.should match(Regexp.escape(utf8_to_sjis("ほげ")))
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should contains encoded emoticon" do
|
57
|
+
@mail.subject += ""
|
58
|
+
@mail.body = "#{@mail.body}"
|
59
|
+
|
60
|
+
@mail.to_s.should match(Regexp.escape("=?Shift_JIS?B?lpyXdPif?="))
|
61
|
+
@mail.to_s.should match(sjis_regexp("\xF8\x9F"))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "Au" do
|
67
|
+
before(:each) do
|
68
|
+
@mobile = Jpmobile::Mobile::Au.new(nil, nil)
|
69
|
+
@mail.mobile = @mobile
|
70
|
+
@mail.to = "info+to@jpmobile-rails.org"
|
71
|
+
end
|
72
|
+
|
73
|
+
context "to_s" do
|
74
|
+
it "should contain encoded subject" do
|
75
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCS3xNVRsoQg==?=")))
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should contain encoded body" do
|
79
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape(ascii_8bit("\x1b\x24\x42\x24\x5B\x24\x32\e\x28\x42"))))
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should contain encoded emoticon" do
|
83
|
+
@mail.subject += ""
|
84
|
+
@mail.body = "#{@mail.body}"
|
85
|
+
|
86
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCS3xNVRsoQhskQnVBGyhC?=")))
|
87
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape(ascii_8bit("\x1b\x24\x42\x75\x41\x1b\x28\x42"))))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "Softbank" do
|
93
|
+
before(:each) do
|
94
|
+
@mobile = Jpmobile::Mobile::Softbank.new(nil, nil)
|
95
|
+
@mail.mobile = @mobile
|
96
|
+
@mail.to = "info+to@jpmobile-rails.org"
|
97
|
+
end
|
98
|
+
|
99
|
+
context "to_s" do
|
100
|
+
it "should contain encoded subject" do
|
101
|
+
@mail.to_s.should match(Regexp.escape(sjis("=?Shift_JIS?B?lpyXdA==?=")))
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should contain encoded body" do
|
105
|
+
@mail.to_s.should match(Regexp.escape(utf8_to_sjis("ほげ")))
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should contains encoded emoticon" do
|
109
|
+
@mail.subject += ""
|
110
|
+
@mail.body = "#{@mail.body}"
|
111
|
+
|
112
|
+
@mail.to_s.should match(Regexp.escape("=?Shift_JIS?B?lpyXdPmL?="))
|
113
|
+
@mail.to_s.should match(sjis_regexp("\xf9\x8b"))
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,289 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
3
|
+
require 'mail'
|
4
|
+
require 'jpmobile/mail'
|
5
|
+
|
6
|
+
describe "Jpmobile::Mail#receive" do
|
7
|
+
include Jpmobile::Util
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
@to = "info@jpmobile-rails.org"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "PC mail" do
|
14
|
+
before(:each) do
|
15
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/pc-mail-single.eml")).read)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "subject should be parsed correctly" do
|
19
|
+
@mail.subject.should == "タイトルの長いメールの場合の対処を実装するためのテストケースとしてのメールに含まれている件名であるサブジェクト部分"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "body should be parsed correctly" do
|
23
|
+
@mail.body.to_s.should == "本文です"
|
24
|
+
end
|
25
|
+
|
26
|
+
context "to_s" do
|
27
|
+
it "should have subject which is same as original" do
|
28
|
+
ascii_8bit(@mail.to_s).should match("GyRCJT8lJCVIJWskTkQ5JCQlYSE8JWskTj5s")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have body which is same as original" do
|
32
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis("本文です")))))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "modify and to_s" do
|
37
|
+
it "should encode subject correctly" do
|
38
|
+
@mail.subject = "大江戸"
|
39
|
+
ascii_8bit(@mail.to_s).should match("GyRCQmc5PjhNGyhC")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should encode body correctly" do
|
43
|
+
@mail.body = "会議が開催"
|
44
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis("会議が開催")))))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "multipart" do
|
50
|
+
describe "PC mail" do
|
51
|
+
before(:each) do
|
52
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/pc-mail-multi.eml")).read)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "subject should be parsed correctly" do
|
56
|
+
@mail.subject.should == "タイトルの長いメールの場合の対処を実装するためのテストケースとしてのメールに含まれている件名であるサブジェクト部分"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "body should be parsed correctly" do
|
60
|
+
@mail.body.parts.size.should == 2
|
61
|
+
@mail.body.parts.first.body.to_s.should == "本文です"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should encode correctly" do
|
65
|
+
ascii_8bit(@mail.to_s).should match(/GyRCJT8lJCVIJWskTkQ5JCQlYSE8JWskTj5s/)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "Docomo" do
|
70
|
+
before(:each) do
|
71
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/docomo-gmail-sjis.eml")).read)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "subject should be parsed correctly" do
|
75
|
+
@mail.subject.should == "テスト"
|
76
|
+
end
|
77
|
+
|
78
|
+
it "body should be parsed correctly" do
|
79
|
+
@mail.body.parts.size.should == 1
|
80
|
+
@mail.body.parts.first.parts.size == 2
|
81
|
+
@mail.body.parts.first.parts.first.body.should match("テストです")
|
82
|
+
@mail.body.parts.first.parts.last.body.raw_source.should match("テストです")
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should encode correctly" do
|
86
|
+
@mail.to_s.should match(Regexp.escape("g2WDWINn+ZE"))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "Au" do
|
91
|
+
before(:each) do
|
92
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/au-decomail.eml")).read)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "subject should be parsed correctly" do
|
96
|
+
@mail.subject.should == "テスト"
|
97
|
+
end
|
98
|
+
|
99
|
+
it "body should be parsed correctly" do
|
100
|
+
@mail.body.parts.size.should == 1
|
101
|
+
@mail.body.parts.first.parts.size == 1
|
102
|
+
@mail.body.parts.first.parts.first.body.to_s.should match("テストです")
|
103
|
+
@mail.body.parts.first.parts.last.body.raw_source.should match("テストです")
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should encode correctly" do
|
107
|
+
ascii_8bit(@mail.to_s).should match(Regexp.escape("GyRCJUYlOSVIGyhCGyRCdk8bKEI="))
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "Softbank" do
|
112
|
+
context "Shift_JIS" do
|
113
|
+
before(:each) do
|
114
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-sjis.eml")).read)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "subject should be parsed correctly" do
|
118
|
+
@mail.subject.should == "テスト"
|
119
|
+
end
|
120
|
+
|
121
|
+
it "body should be parsed correctly" do
|
122
|
+
@mail.body.parts.size.should == 2
|
123
|
+
@mail.body.parts.first.body.to_s.should == "テストです"
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should encode correctly" do
|
127
|
+
@mail.to_s.should match(Regexp.escape("g2WDWINn98H3w/fB"))
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context "UTF-8" do
|
132
|
+
before(:each) do
|
133
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-utf8.eml")).read)
|
134
|
+
end
|
135
|
+
|
136
|
+
it "subject should be parsed correctly" do
|
137
|
+
@mail.subject.should == "テストです"
|
138
|
+
end
|
139
|
+
|
140
|
+
it "body should be parsed correctly" do
|
141
|
+
@mail.body.parts.size.should == 2
|
142
|
+
@mail.body.parts.first.body.raw_source.should == "テストです"
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should encode correctly to Shift_JIS" do
|
146
|
+
@mail.to_s.should match(Regexp.escape("g2WDWINngsWCt/fB"))
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe "Docomo" do
|
153
|
+
before(:each) do
|
154
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/docomo-emoji.eml")).read)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "subject should be parsed correctly" do
|
158
|
+
@mail.subject.should == "題名"
|
159
|
+
end
|
160
|
+
|
161
|
+
it "body should be parsed correctly" do
|
162
|
+
@mail.body.to_s.should == "本文\nFor docomo"
|
163
|
+
end
|
164
|
+
|
165
|
+
context "to_s" do
|
166
|
+
it "should have subject which is same as original" do
|
167
|
+
@mail.to_s.should match(Regexp.escape("keiWvPjX"))
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should have body which is same as original" do
|
171
|
+
@mail.to_s.should match(sjis_regexp(utf8_to_sjis("本文")))
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context "modify and to_s" do
|
176
|
+
it "should encode subject correctly" do
|
177
|
+
@mail.subject = "大江戸"
|
178
|
+
@mail.to_s.should match(Regexp.escape("keWNXYzL+J8="))
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should encode body correctly" do
|
182
|
+
@mail.body = "会議が開催"
|
183
|
+
@mail.to_s.should match(sjis_regexp(sjis("\x89\xEF\x8Bc\x82\xAA\x8AJ\x8D\xC3\xF8\xA7")))
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe "Au" do
|
189
|
+
before(:each) do
|
190
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/au-emoji.eml")).read)
|
191
|
+
end
|
192
|
+
|
193
|
+
it "subject should be parsed correctly" do
|
194
|
+
@mail.subject.should == "題名"
|
195
|
+
end
|
196
|
+
|
197
|
+
it "body should be parsed correctly" do
|
198
|
+
@mail.body.to_s.should == "本文\nFor au"
|
199
|
+
end
|
200
|
+
|
201
|
+
context "to_s" do
|
202
|
+
it "should have subject which is same as original" do
|
203
|
+
ascii_8bit(@mail.to_s).should match(Regexp.escape("GyRCQmpMPhsoQhskQnZeGyhC"))
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should have body which is same as original" do
|
207
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis("本文")))))
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context "modify and to_s" do
|
212
|
+
it "should encode subject correctly" do
|
213
|
+
@mail.subject = "大江戸"
|
214
|
+
ascii_8bit(@mail.to_s).should match("GyRCQmc5PjhNGyhCGyRCdUEbKEI=")
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should encode body correctly" do
|
218
|
+
@mail.body = "会議が開催"
|
219
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape(ascii_8bit("\x1b\x24\x42\x32\x71\x35\x44\x24\x2C\x33\x2B\x3A\x45\x1b\x28\x42\x1b\x24\x42\x75\x48\x1b\x28\x42"))))
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe "Softbank" do
|
225
|
+
before(:each) do
|
226
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/softbank-emoji.eml")).read)
|
227
|
+
end
|
228
|
+
|
229
|
+
it "subject should be parsed correctly" do
|
230
|
+
@mail.subject.should == "題名"
|
231
|
+
end
|
232
|
+
|
233
|
+
it "body should be parsed correctly" do
|
234
|
+
@mail.body.to_s.should == "本文\nFor softbank"
|
235
|
+
end
|
236
|
+
|
237
|
+
context "to_s" do
|
238
|
+
it "should have subject which is same as original" do
|
239
|
+
@mail.to_s.should match(sjis_regexp("keiWvPl8"))
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should have body which is same as original" do
|
243
|
+
@mail.to_s.should match(sjis_regexp(utf8_to_sjis("本文")))
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
context "modify and to_s" do
|
248
|
+
it "should encode subject correctly" do
|
249
|
+
@mail.subject = "大江戸"
|
250
|
+
@mail.to_s.should match(Regexp.escape("keWNXYzL+Ys="))
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should encode body correctly" do
|
254
|
+
@mail.body = "会議が開催"
|
255
|
+
@mail.to_s.should match(sjis_regexp(utf8_to_sjis("会議が開催") + sjis("\xf7\xdf")))
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
describe "Softbank blank-mail" do
|
261
|
+
before(:each) do
|
262
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/softbank-blank.eml")).read)
|
263
|
+
end
|
264
|
+
|
265
|
+
it "subject should be parsed correctly" do
|
266
|
+
@mail.subject.should be_blank
|
267
|
+
end
|
268
|
+
|
269
|
+
it "body should be parsed correctly" do
|
270
|
+
@mail.body.to_s.should be_blank
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
describe "JIS mail" do
|
275
|
+
context "Docomo" do
|
276
|
+
before(:each) do
|
277
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/docomo-jis.eml")).read)
|
278
|
+
end
|
279
|
+
|
280
|
+
it "subject should be parsed correctly" do
|
281
|
+
@mail.subject.should == "テスト"
|
282
|
+
end
|
283
|
+
|
284
|
+
it "body should be parsed correctly" do
|
285
|
+
@mail.body.to_s.should == "テスト本文"
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
data/spec/unit/spec_helper.rb
CHANGED
@@ -12,3 +12,11 @@ begin
|
|
12
12
|
rescue LoadError
|
13
13
|
puts "Terminal display information test requires jpmobile-terminfo module"
|
14
14
|
end
|
15
|
+
|
16
|
+
RSpec.configure do |c|
|
17
|
+
c.filter_run :focus => true
|
18
|
+
c.run_all_when_everything_filtered = true
|
19
|
+
c.color_enabled = true
|
20
|
+
c.filter_run_excluding :broken => true
|
21
|
+
# c.full_backtrace = true
|
22
|
+
end
|
data/spec/unit/util_spec.rb
CHANGED
@@ -41,4 +41,9 @@ describe Jpmobile::Util, ".deep_apply" do
|
|
41
41
|
it "U+FFE3が0x8150に変換されること" do
|
42
42
|
utf8_to_sjis([0xffe3].pack("U")).should == sjis("\x81\x50")
|
43
43
|
end
|
44
|
+
|
45
|
+
it "jis_string_regexpでISO-2022-JPの文字列がマッチすること" do
|
46
|
+
jis_string_regexp.match(ascii_8bit(utf8_to_jis("abcしからずんばこじをえずdef"))).should_not be_nil
|
47
|
+
jis_to_utf8(jis("\x1b\x24\x42#{$1}\x1b\x28\x42")).should == "しからずんばこじをえず"
|
48
|
+
end
|
44
49
|
end
|