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/encoding_spec.rb
CHANGED
@@ -1,101 +1,100 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
3
2
|
|
4
|
-
describe
|
3
|
+
describe 'Jpmobile::Mobile' do
|
5
4
|
include Jpmobile::Util
|
6
5
|
|
7
|
-
describe
|
6
|
+
describe 'AbstractMobile' do
|
8
7
|
before(:each) do
|
9
8
|
@mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
|
10
9
|
end
|
11
10
|
|
12
|
-
context
|
13
|
-
it
|
14
|
-
expect(@mobile.to_mail_subject(
|
11
|
+
context 'to_mail_subject' do
|
12
|
+
it 'should convert string to ISO-2022-JP B-Encoding when string contains Japanese' do
|
13
|
+
expect(@mobile.to_mail_subject('ほげ')).to eq('=?ISO-2022-JP?B?GyRCJFskMhsoQg==?=')
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
18
|
-
context
|
19
|
-
it
|
20
|
-
expect(@mobile.to_mail_body(
|
17
|
+
context 'to_mail_body' do
|
18
|
+
it 'should convert string to ISO-2022-JP when string contains Japanese' do
|
19
|
+
expect(@mobile.to_mail_body('ほげ')).to eq(utf8_to_jis('ほげ'))
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
|
-
describe
|
24
|
+
describe 'Docomo' do
|
26
25
|
before(:each) do
|
27
26
|
@mobile = Jpmobile::Mobile::Docomo.new(nil, nil)
|
28
27
|
end
|
29
28
|
|
30
|
-
context
|
31
|
-
it
|
32
|
-
expect(@mobile.to_mail_subject(
|
29
|
+
context 'to_mail_subject' do
|
30
|
+
it 'should convert string to Shift_JIS B-Encoding when string contains Japanese' do
|
31
|
+
expect(@mobile.to_mail_subject('ほげ')).to eq('=?Shift_JIS?B?gtmCsA==?=')
|
33
32
|
end
|
34
33
|
|
35
34
|
it "should convert emoticon  to \xf8\x9f in B-Encoding" do
|
36
|
-
expect(@mobile.to_mail_subject(
|
35
|
+
expect(@mobile.to_mail_subject('ほげ')).to eq('=?Shift_JIS?B?gtmCsPif?=')
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
|
-
context
|
41
|
-
it
|
42
|
-
expect(@mobile.to_mail_body(
|
39
|
+
context 'to_mail_body' do
|
40
|
+
it 'should convert string to Shift_JIS when string contains Japanese' do
|
41
|
+
expect(@mobile.to_mail_body('ほげ')).to eq(utf8_to_sjis('ほげ'))
|
43
42
|
end
|
44
43
|
|
45
44
|
it "should convert emoticon  to \xf8\x9f" do
|
46
|
-
expect(@mobile.to_mail_body(
|
45
|
+
expect(@mobile.to_mail_body('ほげ')).to eq(utf8_to_sjis('ほげ') + sjis("\xf8\x9f"))
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
describe
|
50
|
+
describe 'Au' do
|
52
51
|
before(:each) do
|
53
52
|
@mobile = Jpmobile::Mobile::Au.new(nil, nil)
|
54
53
|
end
|
55
54
|
|
56
|
-
context
|
57
|
-
it
|
58
|
-
expect(@mobile.to_mail_subject(
|
55
|
+
context 'to_mail_subject' do
|
56
|
+
it 'should convert string to ISO-2022-JP B-Encoding when string contains Japanese' do
|
57
|
+
expect(@mobile.to_mail_subject('ほげ')).to eq('=?ISO-2022-JP?B?GyRCJFskMhsoQg==?=')
|
59
58
|
end
|
60
59
|
|
61
60
|
it "should convert emoticon  to \x75\x41 in B-Encoding" do
|
62
|
-
expect(@mobile.to_mail_subject(
|
61
|
+
expect(@mobile.to_mail_subject('ほげ')).to eq('=?ISO-2022-JP?B?GyRCJFskMnVBGyhC?=')
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
|
-
context
|
67
|
-
it
|
68
|
-
expect(@mobile.to_mail_body(
|
65
|
+
context 'to_mail_body' do
|
66
|
+
it 'should convert string to ISO-2022-JP when string contains Japanese' do
|
67
|
+
expect(@mobile.to_mail_body('ほげ')).to eq(utf8_to_jis('ほげ'))
|
69
68
|
end
|
70
69
|
|
71
70
|
it "should convert emoticon  to \x75\x41" do
|
72
|
-
expect(ascii_8bit(@mobile.to_mail_body(
|
71
|
+
expect(ascii_8bit(@mobile.to_mail_body('ほげ'))).to eq(ascii_8bit(jis("\e\x24\x42\x24\x5B\x24\x32\x75\x41\x1b\x28\x42")))
|
73
72
|
end
|
74
73
|
end
|
75
74
|
end
|
76
75
|
|
77
|
-
describe
|
76
|
+
describe 'Softbank' do
|
78
77
|
before(:each) do
|
79
78
|
@mobile = Jpmobile::Mobile::Softbank.new(nil, nil)
|
80
79
|
end
|
81
80
|
|
82
|
-
context
|
83
|
-
it
|
84
|
-
expect(@mobile.to_mail_subject(
|
81
|
+
context 'to_mail_subject' do
|
82
|
+
it 'should convert string to Shift_JIS B-Encoding when string contains Japanese' do
|
83
|
+
expect(@mobile.to_mail_subject('ほげ')).to eq('=?Shift_JIS?B?gtmCsA==?=')
|
85
84
|
end
|
86
85
|
|
87
86
|
it "should convert emoticon  to \xf9\x8b in B-Encoding" do
|
88
|
-
expect(@mobile.to_mail_subject(
|
87
|
+
expect(@mobile.to_mail_subject('ほげ')).to eq('=?Shift_JIS?B?gtmCsPmL?=')
|
89
88
|
end
|
90
89
|
end
|
91
90
|
|
92
|
-
context
|
93
|
-
it
|
94
|
-
expect(@mobile.to_mail_body(
|
91
|
+
context 'to_mail_body' do
|
92
|
+
it 'should convert string to Shift_JIS when string contains Japanese' do
|
93
|
+
expect(@mobile.to_mail_body('ほげ')).to eq(utf8_to_sjis('ほげ'))
|
95
94
|
end
|
96
95
|
|
97
96
|
it "should convert emoticon  to \xf9\x8b" do
|
98
|
-
expect(@mobile.to_mail_body(
|
97
|
+
expect(@mobile.to_mail_body('ほげ')).to eq(utf8_to_sjis('ほげ') + sjis("\xf9\x8b"))
|
99
98
|
end
|
100
99
|
end
|
101
100
|
end
|
@@ -2,61 +2,61 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
|
2
2
|
|
3
3
|
describe 'Jpmobile::Mobile' do
|
4
4
|
[
|
5
|
-
[
|
6
|
-
[
|
7
|
-
[
|
8
|
-
[
|
9
|
-
[
|
10
|
-
[
|
11
|
-
[
|
5
|
+
[%w[Docomo docomo], true],
|
6
|
+
[%w[Docomo au], false],
|
7
|
+
[%w[Docomo softbank], false],
|
8
|
+
[%w[Docomo vodafone], false],
|
9
|
+
[%w[Docomo emobile], false],
|
10
|
+
[%w[Docomo willcom], false],
|
11
|
+
[%w[Docomo ddipocket], false],
|
12
12
|
|
13
|
-
[
|
14
|
-
[
|
15
|
-
[
|
16
|
-
[
|
17
|
-
[
|
18
|
-
[
|
19
|
-
[
|
13
|
+
[%w[Au docomo], false],
|
14
|
+
[%w[Au au], true],
|
15
|
+
[%w[Au softbank], false],
|
16
|
+
[%w[Au vodafone], false],
|
17
|
+
[%w[Au emobile], false],
|
18
|
+
[%w[Au willcom], false],
|
19
|
+
[%w[Au ddipocket], false],
|
20
20
|
|
21
|
-
[
|
22
|
-
[
|
23
|
-
[
|
24
|
-
[
|
25
|
-
[
|
26
|
-
[
|
27
|
-
[
|
21
|
+
[%w[Softbank docomo], false],
|
22
|
+
[%w[Softbank au], false],
|
23
|
+
[%w[Softbank softbank], true],
|
24
|
+
[%w[Softbank vodafone], false],
|
25
|
+
[%w[Softbank emobile], false],
|
26
|
+
[%w[Softbank willcom], false],
|
27
|
+
[%w[Softbank ddipocket], false],
|
28
28
|
|
29
|
-
[
|
30
|
-
[
|
31
|
-
[
|
32
|
-
[
|
33
|
-
[
|
34
|
-
[
|
35
|
-
[
|
29
|
+
[%w[Vodafone docomo], false],
|
30
|
+
[%w[Vodafone au], false],
|
31
|
+
[%w[Vodafone softbank], true],
|
32
|
+
[%w[Vodafone vodafone], true],
|
33
|
+
[%w[Vodafone emobile], false],
|
34
|
+
[%w[Vodafone willcom], false],
|
35
|
+
[%w[Vodafone ddipocket], false],
|
36
36
|
|
37
|
-
[
|
38
|
-
[
|
39
|
-
[
|
40
|
-
[
|
41
|
-
[
|
42
|
-
[
|
43
|
-
[
|
37
|
+
[%w[Emobile docomo], false],
|
38
|
+
[%w[Emobile au], false],
|
39
|
+
[%w[Emobile softbank], false],
|
40
|
+
[%w[Emobile vodafone], false],
|
41
|
+
[%w[Emobile emobile], true],
|
42
|
+
[%w[Emobile willcom], false],
|
43
|
+
[%w[Emobile ddipocket], false],
|
44
44
|
|
45
|
-
[
|
46
|
-
[
|
47
|
-
[
|
48
|
-
[
|
49
|
-
[
|
50
|
-
[
|
51
|
-
[
|
45
|
+
[%w[Willcom docomo], false],
|
46
|
+
[%w[Willcom au], false],
|
47
|
+
[%w[Willcom softbank], false],
|
48
|
+
[%w[Willcom vodafone], false],
|
49
|
+
[%w[Willcom emobile], false],
|
50
|
+
[%w[Willcom willcom], true],
|
51
|
+
[%w[Willcom ddipocket], false],
|
52
52
|
|
53
|
-
[
|
54
|
-
[
|
55
|
-
[
|
56
|
-
[
|
57
|
-
[
|
58
|
-
[
|
59
|
-
[
|
53
|
+
[%w[Ddipocket docomo], false],
|
54
|
+
[%w[Ddipocket au], false],
|
55
|
+
[%w[Ddipocket softbank], false],
|
56
|
+
[%w[Ddipocket vodafone], false],
|
57
|
+
[%w[Ddipocket emobile], false],
|
58
|
+
[%w[Ddipocket willcom], true],
|
59
|
+
[%w[Ddipocket ddipocket], true],
|
60
60
|
].each do |carrier, expected|
|
61
61
|
it "#{carrier.first}##{carrier.last}? should be return #{expected}" do
|
62
62
|
expect(Jpmobile::Mobile.const_get(carrier.first).new({}, {}).__send__("#{carrier.last}?")).to eq(expected)
|
data/spec/unit/mail_spec.rb
CHANGED
@@ -1,294 +1,294 @@
|
|
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
|
-
describe
|
5
|
+
describe 'Jpmobile::Mail' do
|
7
6
|
include Jpmobile::Util
|
8
7
|
|
9
8
|
before(:each) do
|
10
9
|
@mail = Mail.new
|
11
|
-
@mail.subject =
|
12
|
-
@mail.body =
|
13
|
-
@mail.from =
|
10
|
+
@mail.subject = '万葉'
|
11
|
+
@mail.body = 'ほげ'
|
12
|
+
@mail.from = 'ちはやふる <info@jpmobile-rails.org>'
|
14
13
|
end
|
15
14
|
|
16
|
-
context
|
17
|
-
it
|
18
|
-
expect{@mail.to = [
|
15
|
+
context 'Mail#to' do
|
16
|
+
it 'sets multi-tos' do
|
17
|
+
expect { @mail.to = ['a@hoge.com', 'b@hoge.com'] }.to_not raise_error
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
|
-
describe
|
21
|
+
describe 'Non-mobile' do
|
23
22
|
before(:each) do
|
24
23
|
@mail = Mail.new do
|
25
|
-
subject
|
26
|
-
from
|
24
|
+
subject '万葉'
|
25
|
+
from 'ちはやふる <info@jpmobile-rails.org>'
|
27
26
|
end
|
28
27
|
end
|
29
|
-
context
|
28
|
+
context 'has multipart body' do
|
30
29
|
before(:each) do
|
31
|
-
@mail.parts << Mail::Part.new { body
|
32
|
-
@mail.parts << Mail::Part.new { body
|
33
|
-
@mail.parts.each{|p| p.charset =
|
30
|
+
@mail.parts << Mail::Part.new { body 'ほげ' }
|
31
|
+
@mail.parts << Mail::Part.new { body 'ほげほげ' }
|
32
|
+
@mail.parts.each { |p| p.charset = 'ISO-2022-JP' }
|
34
33
|
end
|
35
|
-
context
|
36
|
-
subject
|
34
|
+
context 'to_s' do
|
35
|
+
subject do
|
37
36
|
Mail.new ascii_8bit(@mail.to_s)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
subject.parts[
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should be able to decode bodies' do
|
40
|
+
expect(subject.parts[0].body.to_s).to eq(ascii_8bit('ほげ'))
|
41
|
+
expect(subject.parts[1].body.to_s).to eq(ascii_8bit('ほげほげ'))
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
describe
|
47
|
+
describe 'AbstractMobile' do
|
48
48
|
before(:each) do
|
49
49
|
@mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
|
50
50
|
@mail.mobile = @mobile
|
51
|
-
@mail.to =
|
51
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
52
52
|
end
|
53
53
|
|
54
|
-
context
|
55
|
-
it
|
56
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
54
|
+
context 'to_s' do
|
55
|
+
it 'should contain encoded subject' do
|
56
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCS3xNVRsoQg==?=')))
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
59
|
+
it 'should contain encoded body' do
|
60
60
|
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit("\x1b\x24\x42\x24\x5B\x24\x32\e\x28\x42"))))
|
61
61
|
end
|
62
62
|
|
63
|
-
it
|
64
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(
|
63
|
+
it 'should contain encoded from' do
|
64
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit('=?ISO-2022-JP?B?GyRCJEEkTyRkJFUkaxsoQg==?='))))
|
65
65
|
end
|
66
66
|
|
67
|
-
it
|
68
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(
|
67
|
+
it 'should contain encoded to' do
|
68
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit('=?ISO-2022-JP?B?GyRCJGAkOSRhJFUkNSRbJDsbKEI=?='))))
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
72
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(
|
71
|
+
it 'should contain correct Content-Type:' do
|
72
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit('charset=ISO-2022-JP'))))
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
describe
|
77
|
+
describe 'Docomo' do
|
78
78
|
before(:each) do
|
79
79
|
@mobile = Jpmobile::Mobile::Docomo.new(nil, nil)
|
80
80
|
@mail.mobile = @mobile
|
81
|
-
@mail.to =
|
81
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
82
82
|
end
|
83
83
|
|
84
|
-
context
|
85
|
-
it
|
86
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
84
|
+
context 'to_s' do
|
85
|
+
it 'should contain encoded subject' do
|
86
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?lpyXdA==?='))
|
87
87
|
end
|
88
88
|
|
89
|
-
it
|
90
|
-
expect(@mail.to_s).to match(Regexp.escape(utf8_to_sjis(
|
89
|
+
it 'should contain encoded body' do
|
90
|
+
expect(@mail.to_s).to match(Regexp.escape(utf8_to_sjis('ほげ')))
|
91
91
|
end
|
92
92
|
|
93
|
-
it
|
94
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
93
|
+
it 'should contain encoded from' do
|
94
|
+
expect(@mail.to_s).to match(sjis_regexp('gr+CzYLigtOC6Q=='))
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
98
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
97
|
+
it 'should contain encoded to' do
|
98
|
+
expect(@mail.to_s).to match(sjis_regexp('gt6Ct4LfgtOCs4LZgrk='))
|
99
99
|
end
|
100
100
|
|
101
|
-
it
|
102
|
-
@mail.subject +=
|
101
|
+
it 'should contains encoded emoticon' do
|
102
|
+
@mail.subject += ''
|
103
103
|
@mail.body = "#{@mail.body}"
|
104
104
|
|
105
|
-
expect(@mail.to_s).to match(Regexp.escape(
|
105
|
+
expect(@mail.to_s).to match(Regexp.escape('=?Shift_JIS?B?lpyXdPif?='))
|
106
106
|
expect(@mail.to_s).to match(sjis_regexp("\xF8\x9F"))
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
describe
|
111
|
+
describe 'Au' do
|
112
112
|
before(:each) do
|
113
113
|
@mobile = Jpmobile::Mobile::Au.new(nil, nil)
|
114
114
|
@mail.mobile = @mobile
|
115
|
-
@mail.to =
|
115
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
116
116
|
end
|
117
117
|
|
118
|
-
context
|
119
|
-
it
|
120
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
118
|
+
context 'to_s' do
|
119
|
+
it 'should contain encoded subject' do
|
120
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCS3xNVRsoQg==?=')))
|
121
121
|
end
|
122
122
|
|
123
|
-
it
|
123
|
+
it 'should contain encoded body' do
|
124
124
|
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit("\x1b\x24\x42\x24\x5B\x24\x32\e\x28\x42"))))
|
125
125
|
end
|
126
126
|
|
127
|
-
it
|
128
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(
|
127
|
+
it 'should contain encoded from' do
|
128
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit('=?ISO-2022-JP?B?GyRCJEEkTyRkJFUkaxsoQg==?='))))
|
129
129
|
end
|
130
130
|
|
131
|
-
it
|
132
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(
|
131
|
+
it 'should contain encoded to' do
|
132
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit('=?ISO-2022-JP?B?GyRCJGAkOSRhJFUkNSRbJDsbKEI=?='))))
|
133
133
|
end
|
134
134
|
|
135
|
-
it
|
136
|
-
@mail.subject +=
|
135
|
+
it 'should contain encoded emoticon' do
|
136
|
+
@mail.subject += ''
|
137
137
|
@mail.body = "#{@mail.body}"
|
138
138
|
|
139
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
139
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCS3xNVXVBGyhC?=')))
|
140
140
|
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit("\e\x24\x42\x24\x5B\x24\x32\x75\x41\e\x28\x42"))))
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
-
describe
|
145
|
+
describe 'Softbank' do
|
146
146
|
before(:each) do
|
147
147
|
@mobile = Jpmobile::Mobile::Softbank.new(nil, nil)
|
148
148
|
@mail.mobile = @mobile
|
149
|
-
@mail.to =
|
149
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
150
150
|
end
|
151
151
|
|
152
|
-
context
|
153
|
-
it
|
154
|
-
expect(@mail.to_s).to match(Regexp.escape(sjis(
|
152
|
+
context 'to_s' do
|
153
|
+
it 'should contain encoded subject' do
|
154
|
+
expect(@mail.to_s).to match(Regexp.escape(sjis('=?Shift_JIS?B?lpyXdA==?=')))
|
155
155
|
end
|
156
156
|
|
157
|
-
it
|
158
|
-
expect(@mail.to_s).to match(Regexp.escape(utf8_to_sjis(
|
157
|
+
it 'should contain encoded body' do
|
158
|
+
expect(@mail.to_s).to match(Regexp.escape(utf8_to_sjis('ほげ')))
|
159
159
|
end
|
160
160
|
|
161
|
-
it
|
162
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
161
|
+
it 'should contain encoded from' do
|
162
|
+
expect(@mail.to_s).to match(sjis_regexp('gr+CzYLigtOC6Q=='))
|
163
163
|
end
|
164
164
|
|
165
|
-
it
|
166
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
165
|
+
it 'should contain encoded to' do
|
166
|
+
expect(@mail.to_s).to match(sjis_regexp('gt6Ct4LfgtOCs4LZgrk='))
|
167
167
|
end
|
168
168
|
|
169
|
-
it
|
170
|
-
@mail.subject +=
|
169
|
+
it 'should contains encoded emoticon' do
|
170
|
+
@mail.subject += ''
|
171
171
|
@mail.body = "#{@mail.body}"
|
172
172
|
|
173
|
-
expect(@mail.to_s).to match(Regexp.escape(
|
173
|
+
expect(@mail.to_s).to match(Regexp.escape('=?Shift_JIS?B?lpyXdPmL?='))
|
174
174
|
expect(@mail.to_s).to match(sjis_regexp("\xf9\x8b"))
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
|
-
describe
|
179
|
+
describe 'long subject' do
|
180
180
|
before(:each) do
|
181
181
|
@mail = Mail.new
|
182
|
-
@mail.subject =
|
183
|
-
@mail.body =
|
184
|
-
@mail.from =
|
182
|
+
@mail.subject = '弊社採用応募へのお申込み誠にありがとうございますと言いたいところだがそうは簡単には物事は運ばないことを心しておいてもらいたいと苦言を呈する故に弊社は維持しているのです'
|
183
|
+
@mail.body = '株式会社・・'
|
184
|
+
@mail.from = 'info@jpmobile-rails.org'
|
185
185
|
end
|
186
186
|
|
187
|
-
describe
|
187
|
+
describe 'Docomo' do
|
188
188
|
before(:each) do
|
189
189
|
@mobile = Jpmobile::Mobile::Docomo.new(nil, nil)
|
190
190
|
@mail.mobile = @mobile
|
191
|
-
@mail.to =
|
191
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
192
192
|
end
|
193
193
|
|
194
|
-
it
|
195
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
196
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
197
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
198
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
199
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
200
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
194
|
+
it 'should contain encoded subject' do
|
195
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?lb6O0I3Ml3CJnpXlgtaCzIKokFyNnoLdkL2CyYKg?='))
|
196
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?guiCqoLGgqSCsoK0gqKC3IK3gsaMvoKigr2CooLG?='))
|
197
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?grGC64K+gqqCu4Kkgs2KyJJQgsmCzZWojpaCzYle?='))
|
198
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?gs6CyIKigrGCxoLwkFOCtYLEgqiCooLEguCC54Ki?='))
|
199
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?gr2CooLGi+qMvoLwkuaCt4LpjMyCyZW+jtCCzYjb?='))
|
200
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?jp2CtYLEgqKC6YLMgsWCtw==?='))
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
-
describe
|
204
|
+
describe 'Au' do
|
205
205
|
before(:each) do
|
206
206
|
@mobile = Jpmobile::Mobile::Au.new(nil, nil)
|
207
207
|
@mail.mobile = @mobile
|
208
|
-
@mail.to =
|
208
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
209
209
|
end
|
210
210
|
|
211
|
-
it
|
212
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
213
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
214
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
215
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
216
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
217
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
211
|
+
it 'should contain encoded subject' do
|
212
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCSkA8UjpOTVExfkpnJFgkTiQqPz05fiRfQD8kSyQiGyhC?=')))
|
213
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCJGokLCRIJCYkNCQ2JCQkXiQ5JEg4QCQkJD8kJCRIGyhC?=')))
|
214
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCJDMkbSRAJCwkPSQmJE80SkMxJEskT0oqO3YkTzE/GyhC?=')))
|
215
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCJFAkSiQkJDMkSCRyPzQkNyRGJCokJCRGJGIkaSQkGyhC?=')))
|
216
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCJD8kJCRINmw4QCRyRGgkOSRrOE4kS0pAPFIkTzBdGyhC?=')))
|
217
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCO30kNyRGJCQkayROJEckORsoQg==?=')))
|
218
218
|
end
|
219
219
|
end
|
220
220
|
|
221
|
-
describe
|
221
|
+
describe 'Softbank' do
|
222
222
|
before(:each) do
|
223
223
|
@mobile = Jpmobile::Mobile::Softbank.new(nil, nil)
|
224
224
|
@mail.mobile = @mobile
|
225
|
-
@mail.to =
|
225
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
226
226
|
end
|
227
227
|
|
228
|
-
it
|
229
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
230
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
231
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
232
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
233
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
234
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
228
|
+
it 'should contain encoded subject' do
|
229
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?lb6O0I3Ml3CJnpXlgtaCzIKokFyNnoLdkL2CyYKg?='))
|
230
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?guiCqoLGgqSCsoK0gqKC3IK3gsaMvoKigr2CooLG?='))
|
231
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?grGC64K+gqqCu4Kkgs2KyJJQgsmCzZWojpaCzYle?='))
|
232
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?gs6CyIKigrGCxoLwkFOCtYLEgqiCooLEguCC54Ki?='))
|
233
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?gr2CooLGi+qMvoLwkuaCt4LpjMyCyZW+jtCCzYjb?='))
|
234
|
+
expect(@mail.to_s).to match(sjis_regexp('=?Shift_JIS?B?jp2CtYLEgqKC6YLMgsWCtw==?='))
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
238
|
-
describe
|
238
|
+
describe 'AbstractMobile' do
|
239
239
|
before(:each) do
|
240
240
|
@mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
|
241
241
|
@mail.mobile = @mobile
|
242
|
-
@mail.to =
|
242
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
243
243
|
end
|
244
244
|
|
245
|
-
context
|
246
|
-
it
|
247
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
248
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
249
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
250
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
251
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
252
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
245
|
+
context 'to_s' do
|
246
|
+
it 'should contain encoded subject' do
|
247
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCSkA8UjpOTVExfkpnJFgkTiQqPz05fiRfQD8kSyQiGyhC?=')))
|
248
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCJGokLCRIJCYkNCQ2JCQkXiQ5JEg4QCQkJD8kJCRIGyhC?=')))
|
249
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCJDMkbSRAJCwkPSQmJE80SkMxJEskT0oqO3YkTzE/GyhC?=')))
|
250
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCJFAkSiQkJDMkSCRyPzQkNyRGJCokJCRGJGIkaSQkGyhC?=')))
|
251
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCJD8kJCRINmw4QCRyRGgkOSRrOE4kS0pAPFIkTzBdGyhC?=')))
|
252
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCO30kNyRGJCQkayROJEckORsoQg==?=')))
|
253
253
|
end
|
254
254
|
end
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
258
|
-
describe
|
258
|
+
describe 'long subject with half-characters' do
|
259
259
|
before(:each) do
|
260
260
|
@mail = Mail.new
|
261
|
-
@mail.subject =
|
262
|
-
@mail.body =
|
263
|
-
@mail.from =
|
261
|
+
@mail.subject = '西暦2012年09月03日は今日になるわけだが10時16分現在のこの時間ではどうかな'
|
262
|
+
@mail.body = '株式会社・・'
|
263
|
+
@mail.from = 'info@jpmobile-rails.org'
|
264
264
|
end
|
265
265
|
|
266
|
-
describe
|
266
|
+
describe 'AbstractMobile' do
|
267
267
|
before(:each) do
|
268
268
|
@mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
|
269
269
|
@mail.mobile = @mobile
|
270
|
-
@mail.to =
|
270
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
271
271
|
end
|
272
272
|
|
273
|
-
context
|
274
|
-
it
|
275
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
276
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
277
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(
|
273
|
+
context 'to_s' do
|
274
|
+
it 'should contain encoded subject' do
|
275
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCQD5OcRsoQjIwMTIbJEJHLxsoQjA5GyRCN24bKEIwMxskQkZ8JE86IxsoQg==?=')))
|
276
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCRnwkSyRKJGskbyQxJEAkLBsoQjEwGyRCO34bKEIxNhskQkosOD0bKEI=?=')))
|
277
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape('=?ISO-2022-JP?B?GyRCOl8kTiQzJE47fjRWJEckTyRJJCYkKyRKGyhC?=')))
|
278
278
|
end
|
279
279
|
end
|
280
280
|
end
|
281
281
|
end
|
282
282
|
|
283
|
-
context
|
283
|
+
context 'with attachments' do
|
284
284
|
before(:each) do
|
285
285
|
@mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
|
286
286
|
@mail.mobile = @mobile
|
287
|
-
@mail.to =
|
288
|
-
@photo = open(File.join(File.expand_path(File.dirname(__FILE__)),
|
287
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
288
|
+
@photo = open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/photo.jpg')).read
|
289
289
|
end
|
290
290
|
|
291
|
-
it
|
291
|
+
it 'should encodes itself successfully' do
|
292
292
|
@mail.attachments['photo.jpg'] = @photo
|
293
293
|
|
294
294
|
expect {
|
@@ -296,7 +296,7 @@ describe "Jpmobile::Mail" do
|
|
296
296
|
}.not_to raise_error
|
297
297
|
end
|
298
298
|
|
299
|
-
it
|
299
|
+
it 'should encodes itself successfully with an inline attachment' do
|
300
300
|
@mail.attachments.inline['photo.jpg'] = @photo
|
301
301
|
|
302
302
|
expect {
|
@@ -304,7 +304,7 @@ describe "Jpmobile::Mail" do
|
|
304
304
|
}.not_to raise_error
|
305
305
|
end
|
306
306
|
|
307
|
-
it
|
307
|
+
it 'should encodes itself successfully with an UTF-8 filename attachment' do
|
308
308
|
@mail.attachments.inline['日本語のファイル名です.jpg'] = @photo
|
309
309
|
|
310
310
|
expect {
|
@@ -313,36 +313,46 @@ describe "Jpmobile::Mail" do
|
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
316
|
-
context
|
316
|
+
context 'encoding conversion' do
|
317
317
|
before(:each) do
|
318
318
|
@mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
|
319
319
|
@mail.mobile = @mobile
|
320
|
-
@mail.to =
|
321
|
-
@photo = open(File.join(File.expand_path(File.dirname(__FILE__)),
|
320
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
321
|
+
@photo = open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/photo.jpg')).read
|
322
322
|
end
|
323
323
|
|
324
|
-
it
|
324
|
+
it 'wave dash converting correctly' do
|
325
325
|
@mail.body = '10:00〜12:00'
|
326
326
|
|
327
327
|
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit("\x31\x30\x3a\x30\x30\x1b\x24\x42\x21\x41\x1b\x28\x42\x31\x32\x3a\x30\x30"))))
|
328
328
|
end
|
329
329
|
|
330
|
-
it
|
330
|
+
it 'full width tilde converting correctly' do
|
331
331
|
@mail.body = "10:00#{[0xff5e].pack("U")}12:00"
|
332
332
|
|
333
333
|
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit("\x31\x30\x3a\x30\x30\x1b\x24\x42\x21\x41\x1b\x28\x42\x31\x32\x3a\x30\x30"))))
|
334
334
|
end
|
335
335
|
end
|
336
336
|
|
337
|
-
context
|
337
|
+
context 'delivering' do
|
338
338
|
before(:each) do
|
339
339
|
@mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
|
340
340
|
@mail.mobile = @mobile
|
341
|
-
@mail.to =
|
341
|
+
@mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
|
342
342
|
end
|
343
343
|
|
344
|
-
it
|
345
|
-
@mail.delivery_method :smtp,
|
344
|
+
it 'delivers through SMTP' do
|
345
|
+
@mail.delivery_method :smtp,
|
346
|
+
{
|
347
|
+
enable_starttls_auto: false,
|
348
|
+
user_name: ENV['MAILTRAP_USERNAME'],
|
349
|
+
password: ENV['MAILTRAP_PASSWORD'],
|
350
|
+
address: 'smtp.mailtrap.io',
|
351
|
+
domain: 'smtp.mailtrap.io',
|
352
|
+
port: '2525',
|
353
|
+
authentication: :cram_md5,
|
354
|
+
}
|
355
|
+
|
346
356
|
expect {
|
347
357
|
@mail.deliver
|
348
358
|
}.not_to raise_error
|
@@ -354,8 +364,8 @@ describe "Jpmobile::Mail" do
|
|
354
364
|
context 'sending with carrier from' do
|
355
365
|
before do
|
356
366
|
@mail = Mail.new
|
357
|
-
@mail.subject =
|
358
|
-
@mail.to =
|
367
|
+
@mail.subject = '万葉'
|
368
|
+
@mail.to = 'ちはやふる <info@jpmobile-rails.org>'
|
359
369
|
end
|
360
370
|
|
361
371
|
it 'should convert content-transfer-encoding' do
|