jpmobile 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -3
  3. data/.rubocop.yml +123 -0
  4. data/CONTRIBUTING.md +16 -14
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +198 -0
  7. data/README.md +409 -0
  8. data/Rakefile +9 -9
  9. data/circle.yml +14 -0
  10. data/jpmobile.gemspec +9 -10
  11. data/lib/jpmobile.rb +6 -5
  12. data/lib/jpmobile/datum_conv.rb +35 -35
  13. data/lib/jpmobile/docomo_guid.rb +7 -8
  14. data/lib/jpmobile/email.rb +12 -12
  15. data/lib/jpmobile/emoticon.rb +85 -76
  16. data/lib/jpmobile/emoticon/au.rb +1284 -1284
  17. data/lib/jpmobile/emoticon/conversion_table.rb +3905 -3906
  18. data/lib/jpmobile/emoticon/docomo.rb +252 -252
  19. data/lib/jpmobile/emoticon/google.rb +9 -9
  20. data/lib/jpmobile/emoticon/softbank.rb +471 -471
  21. data/lib/jpmobile/emoticon/unicode.rb +9 -9
  22. data/lib/jpmobile/emoticon/z_combine.rb +20 -23
  23. data/lib/jpmobile/encoding.rb +1 -1
  24. data/lib/jpmobile/fallback_view_selector.rb +2 -3
  25. data/lib/jpmobile/filter.rb +44 -47
  26. data/lib/jpmobile/helpers.rb +38 -38
  27. data/lib/jpmobile/hook_action_view.rb +7 -7
  28. data/lib/jpmobile/hook_test_request.rb +0 -1
  29. data/lib/jpmobile/lookup_context.rb +1 -2
  30. data/lib/jpmobile/mail.rb +156 -134
  31. data/lib/jpmobile/mailer.rb +4 -4
  32. data/lib/jpmobile/mobile/abstract_mobile.rb +62 -36
  33. data/lib/jpmobile/mobile/android.rb +0 -1
  34. data/lib/jpmobile/mobile/android_tablet.rb +0 -1
  35. data/lib/jpmobile/mobile/au.rb +40 -28
  36. data/lib/jpmobile/mobile/black_berry.rb +0 -1
  37. data/lib/jpmobile/mobile/ddipocket.rb +1 -2
  38. data/lib/jpmobile/mobile/docomo.rb +47 -36
  39. data/lib/jpmobile/mobile/emobile.rb +1 -2
  40. data/lib/jpmobile/mobile/google_emoticon.rb +1 -1
  41. data/lib/jpmobile/mobile/ipad.rb +0 -1
  42. data/lib/jpmobile/mobile/iphone.rb +0 -1
  43. data/lib/jpmobile/mobile/smart_phone.rb +0 -1
  44. data/lib/jpmobile/mobile/softbank.rb +24 -20
  45. data/lib/jpmobile/mobile/tablet.rb +0 -1
  46. data/lib/jpmobile/mobile/unicode_emoticon.rb +15 -15
  47. data/lib/jpmobile/mobile/vodafone.rb +0 -1
  48. data/lib/jpmobile/mobile/willcom.rb +7 -7
  49. data/lib/jpmobile/mobile/windows_phone.rb +0 -1
  50. data/lib/jpmobile/path_set.rb +1 -1
  51. data/lib/jpmobile/position.rb +30 -14
  52. data/lib/jpmobile/rack/filter.rb +4 -4
  53. data/lib/jpmobile/rack/mobile_carrier.rb +0 -1
  54. data/lib/jpmobile/rack/params_filter.rb +7 -6
  55. data/lib/jpmobile/rails.rb +3 -4
  56. data/lib/jpmobile/request_with_mobile.rb +9 -6
  57. data/lib/jpmobile/resolver.rb +23 -17
  58. data/lib/jpmobile/session/active_record_store.rb +7 -9
  59. data/lib/jpmobile/session/mem_cache_store.rb +7 -9
  60. data/lib/jpmobile/sinatra.rb +1 -1
  61. data/lib/jpmobile/trans_sid.rb +15 -20
  62. data/lib/jpmobile/util.rb +61 -77
  63. data/lib/jpmobile/version.rb +1 -1
  64. data/lib/tasks/jpmobile_tasks.rake +35 -28
  65. data/spec/rack/jpmobile/android_spec.rb +5 -5
  66. data/spec/rack/jpmobile/au_spec.rb +74 -59
  67. data/spec/rack/jpmobile/black_berry_spec.rb +5 -5
  68. data/spec/rack/jpmobile/docomo_spec.rb +77 -64
  69. data/spec/rack/jpmobile/emoticon_spec.rb +137 -121
  70. data/spec/rack/jpmobile/filter_spec.rb +149 -128
  71. data/spec/rack/jpmobile/iphone_spec.rb +9 -8
  72. data/spec/rack/jpmobile/mobile_by_ua_spec.rb +22 -21
  73. data/spec/rack/jpmobile/params_filter_spec.rb +104 -96
  74. data/spec/rack/jpmobile/softbank_spec.rb +49 -42
  75. data/spec/rack/jpmobile/willcom_spec.rb +22 -18
  76. data/spec/rack/jpmobile/windows_phone.rb +5 -5
  77. data/spec/rack_helper.rb +9 -8
  78. data/spec/spec_helper.rb +5 -6
  79. data/spec/unit/decorated_mail_spec.rb +8 -9
  80. data/spec/unit/email_spec.rb +44 -44
  81. data/spec/unit/emoticon_spec.rb +57 -58
  82. data/spec/unit/encoding_spec.rb +35 -36
  83. data/spec/unit/is_carrier_spec.rb +49 -49
  84. data/spec/unit/mail_spec.rb +153 -143
  85. data/spec/unit/mobile/iphone_spec.rb +6 -7
  86. data/spec/unit/receive_mail_spec.rb +172 -173
  87. data/spec/unit/spec_helper.rb +6 -6
  88. data/spec/unit/util_spec.rb +125 -46
  89. data/spec/unit/valid_ip_spec.rb +35 -35
  90. data/spec/unit/variants_spec.rb +18 -19
  91. data/test/rails/overrides/Gemfile +54 -0
  92. data/test/rails/overrides/Gemfile.jpmobile +1 -2
  93. data/test/rails/overrides/app/controllers/admin/top_controller.rb +1 -1
  94. data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +1 -1
  95. data/test/rails/overrides/app/controllers/filter_controller_base.rb +14 -6
  96. data/test/rails/overrides/app/controllers/hankaku_input_filter_controller.rb +1 -1
  97. data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
  98. data/test/rails/overrides/app/controllers/template_path_controller.rb +1 -2
  99. data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -10
  100. data/test/rails/overrides/app/controllers/trans_sid_metal_controller.rb +0 -1
  101. data/test/rails/overrides/app/mailers/decorated_mailer.rb +3 -4
  102. data/test/rails/overrides/app/mailers/mobile_mailer.rb +5 -6
  103. data/test/rails/overrides/app/mailers/normal_mailer.rb +2 -3
  104. data/test/rails/overrides/autotest/discover.rb +2 -2
  105. data/test/rails/overrides/config/initializers/jpmobile_generator.rb +2 -2
  106. data/test/rails/overrides/config/routes.rb +95 -2
  107. data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +2 -2
  108. data/test/rails/overrides/db/migrate/20100824062306_create_users.rb +1 -1
  109. data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +24 -25
  110. data/test/rails/overrides/spec/controllers/helpers_spec.rb +88 -88
  111. data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +9 -9
  112. data/test/rails/overrides/spec/controllers/template_path_spec.rb +19 -19
  113. data/test/rails/overrides/spec/features/admin/top_spec.rb +7 -7
  114. data/test/rails/overrides/spec/features/filter_spec.rb +101 -102
  115. data/test/rails/overrides/spec/helpers/helpers_spec.rb +4 -4
  116. data/test/rails/overrides/spec/mailers/decorated_mailer_spec.rb +12 -12
  117. data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +209 -194
  118. data/test/rails/overrides/spec/mailers/normal_mailer_spec.rb +10 -10
  119. data/test/rails/overrides/spec/rails_helper.rb +1 -1
  120. data/test/rails/overrides/spec/requests/docomo_spec.rb +13 -13
  121. data/test/rails/overrides/spec/requests/emobile_spec.rb +19 -19
  122. data/test/rails/overrides/spec/requests/pc_spec.rb +6 -6
  123. data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +6 -6
  124. data/test/rails/overrides/spec/requests/template_path_spec.rb +60 -60
  125. data/test/rails/overrides/spec/requests/trans_sid_spec.rb +89 -89
  126. data/test/sinatra/test/filter_test.rb +10 -11
  127. data/tools/e4u_conv.rb +0 -1
  128. metadata +18 -14
  129. data/README +0 -0
  130. data/README.rdoc +0 -308
@@ -1,11 +1,10 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
3
2
 
4
3
  describe Jpmobile::Mobile::Iphone do
5
4
  describe 'iOS 4.0' do
6
- it "unicode_emoticon? should be false" do
5
+ it 'unicode_emoticon? should be false' do
7
6
  request = double('request')
8
- allow(request).to receive(:user_agent) {'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_4 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8K2 Safari/6533.18.5'}
7
+ allow(request).to receive(:user_agent) { 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_4 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8K2 Safari/6533.18.5' }
9
8
 
10
9
  mobile = Jpmobile::Mobile::Iphone.new({}, request)
11
10
  expect(mobile.unicode_emoticon?).to be_falsey
@@ -13,9 +12,9 @@ describe Jpmobile::Mobile::Iphone do
13
12
  end
14
13
 
15
14
  describe 'iOS 5.0' do
16
- it "unicode_emoticon? should be true" do
15
+ it 'unicode_emoticon? should be true' do
17
16
  request = double('request')
18
- allow(request).to receive(:user_agent) {'Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3'}
17
+ allow(request).to receive(:user_agent) { 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3' }
19
18
 
20
19
  mobile = Jpmobile::Mobile::Iphone.new({}, request)
21
20
  expect(mobile.unicode_emoticon?).to be_truthy
@@ -23,9 +22,9 @@ describe Jpmobile::Mobile::Iphone do
23
22
  end
24
23
 
25
24
  describe 'iOS 6.0' do
26
- it "unicode_emoticon? should be true" do
25
+ it 'unicode_emoticon? should be true' do
27
26
  request = double('request')
28
- allow(request).to receive(:user_agent) {'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25'}
27
+ allow(request).to receive(:user_agent) { 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25' }
29
28
 
30
29
  mobile = Jpmobile::Mobile::Iphone.new({}, request)
31
30
  expect(mobile.unicode_emoticon?).to be_truthy
@@ -1,322 +1,321 @@
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 "Jpmobile::Mail#receive" do
5
+ describe 'Jpmobile::Mail#receive' do
7
6
  include Jpmobile::Util
8
7
 
9
8
  before(:each) do
10
- @to = "info@jpmobile-rails.org"
9
+ @to = 'info@jpmobile-rails.org'
11
10
  Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp[^a-zA-Z\.\-]/)
12
11
  end
13
12
 
14
- describe "PC mail" do
13
+ describe 'PC mail' do
15
14
  before(:each) do
16
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/pc-mail-single.eml")).read)
15
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/pc-mail-single.eml')).read)
17
16
  end
18
17
 
19
- it "subject should be parsed correctly" do
20
- expect(@mail.subject).to eq("タイトルの長いメールの場合の対処を実装するためのテストケースとしてのメールに含まれている件名であるサブジェクト部分")
18
+ it 'subject should be parsed correctly' do
19
+ expect(@mail.subject).to eq('タイトルの長いメールの場合の対処を実装するためのテストケースとしてのメールに含まれている件名であるサブジェクト部分')
21
20
  end
22
21
 
23
- it "body should be parsed correctly" do
22
+ it 'body should be parsed correctly' do
24
23
  expect(@mail.body.to_s).to eq("本文です\n\n")
25
24
  end
26
25
 
27
- context "to_s" do
28
- it "should have subject which is same as original" do
29
- expect(ascii_8bit(@mail.to_s)).to match("GyRCJT8lJCVIJWskTkQ5JCQlYSE8JWskTj5s")
26
+ context 'to_s' do
27
+ it 'should have subject which is same as original' do
28
+ expect(ascii_8bit(@mail.to_s)).to match('GyRCJT8lJCVIJWskTkQ5JCQlYSE8JWskTj5s')
30
29
  end
31
30
 
32
- it "should have body which is same as original" do
33
- expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis("本文です")))))
31
+ it 'should have body which is same as original' do
32
+ expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis('本文です')))))
34
33
  end
35
34
  end
36
35
 
37
- context "modify and to_s" do
38
- it "should encode subject correctly" do
39
- @mail.subject = "大江戸"
40
- expect(ascii_8bit(@mail.to_s)).to match("GyRCQmc5PjhNGyhC")
36
+ context 'modify and to_s' do
37
+ it 'should encode subject correctly' do
38
+ @mail.subject = '大江戸'
39
+ expect(ascii_8bit(@mail.to_s)).to match('GyRCQmc5PjhNGyhC')
41
40
  end
42
41
 
43
- it "should encode body correctly" do
44
- @mail.body = "会議が開催"
45
- expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis("会議が開催")))))
42
+ it 'should encode body correctly' do
43
+ @mail.body = '会議が開催'
44
+ expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis('会議が開催')))))
46
45
  end
47
46
  end
48
47
  end
49
48
 
50
- describe "multipart" do
51
- describe "PC mail" do
49
+ describe 'multipart' do
50
+ describe 'PC mail' do
52
51
  before(:each) do
53
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/pc-mail-multi.eml")).read)
52
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/pc-mail-multi.eml')).read)
54
53
  end
55
54
 
56
- it "subject should be parsed correctly" do
57
- expect(@mail.subject).to eq("タイトルの長いメールの場合の対処を実装するためのテストケースとしてのメールに含まれている件名であるサブジェクト部分")
55
+ it 'subject should be parsed correctly' do
56
+ expect(@mail.subject).to eq('タイトルの長いメールの場合の対処を実装するためのテストケースとしてのメールに含まれている件名であるサブジェクト部分')
58
57
  end
59
58
 
60
- it "body should be parsed correctly" do
59
+ it 'body should be parsed correctly' do
61
60
  expect(@mail.body.parts.size).to eq(2)
62
61
  expect(@mail.body.parts.first.body.to_s).to eq("本文です\n\n")
63
62
  end
64
63
 
65
- it "should encode correctly" do
64
+ it 'should encode correctly' do
66
65
  expect(ascii_8bit(@mail.to_s)).to match(/GyRCJT8lJCVIJWskTkQ5JCQlYSE8JWskTj5s/)
67
66
  end
68
67
  end
69
68
 
70
- describe "PC mail without subject" do
69
+ describe 'PC mail without subject' do
71
70
  before(:each) do
72
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/pc-mail-attached-without-subject.eml")).read)
71
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/pc-mail-attached-without-subject.eml')).read)
73
72
  end
74
73
 
75
- it "body should be parsed correctly" do
74
+ it 'body should be parsed correctly' do
76
75
  expect(@mail.body.parts.size).to eq(2)
77
76
  expect(@mail.body.parts.first.body.to_s).to eq("本文です\n\n")
78
77
  end
79
78
 
80
- it "should encode correctly" do
79
+ it 'should encode correctly' do
81
80
  expect(ascii_8bit(@mail.to_s)).to match(/GODlhAQABAIAAAAAAAP/)
82
81
  end
83
82
  end
84
83
 
85
- describe "Docomo" do
86
- context "with sjis decomail" do
84
+ describe 'Docomo' do
85
+ context 'with sjis decomail' do
87
86
  before(:each) do
88
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/docomo-gmail-sjis.eml")).read)
87
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/docomo-gmail-sjis.eml')).read)
89
88
  end
90
89
 
91
- it "subject should be parsed correctly" do
92
- expect(@mail.subject).to eq("テスト")
90
+ it 'subject should be parsed correctly' do
91
+ expect(@mail.subject).to eq('テスト')
93
92
  end
94
93
 
95
- it "body should be parsed correctly" do
94
+ it 'body should be parsed correctly' do
96
95
  expect(@mail.body.parts.size).to eq(1)
97
- @mail.body.parts.first.parts.size == 2
98
- expect(@mail.body.parts.first.parts.first.body).to match("テストです")
99
- expect(@mail.body.parts.first.parts.last.body.raw_source).to match("テストです")
96
+ expect(@mail.body.parts.first.parts.size).to eq(2)
97
+ expect(@mail.body.parts.first.parts.first.body).to match('テストです')
98
+ expect(@mail.body.parts.first.parts.last.body.raw_source).to match('テストです')
100
99
  end
101
100
 
102
- it "should encode correctly" do
103
- expect(@mail.to_s).to match(Regexp.escape("g2WDWINn+ZE"))
101
+ it 'should encode correctly' do
102
+ expect(@mail.to_s).to match(Regexp.escape('g2WDWINn+ZE'))
104
103
  end
105
104
 
106
- it "does not cause double-conversion on reparsing" do
105
+ it 'does not cause double-conversion on reparsing' do
107
106
  @reparsed = Mail.new(@mail.to_s)
108
- expect(@reparsed.to_s).to match(Regexp.escape("g2WDWINn+ZE"))
109
- expect(@reparsed.body.parts.first.parts.first.body).to match("テストです")
107
+ expect(@reparsed.to_s).to match(Regexp.escape('g2WDWINn+ZE'))
108
+ expect(@reparsed.body.parts.first.parts.first.body).to match('テストです')
110
109
  end
111
110
  end
112
111
 
113
- context "with jis decomail" do
112
+ context 'with jis decomail' do
114
113
  before(:each) do
115
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/docomo-decomail.eml")).read)
114
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/docomo-decomail.eml')).read)
116
115
  end
117
116
 
118
- it "does not contain charset within multipart Content-Type" do
117
+ it 'does not contain charset within multipart Content-Type' do
119
118
  expect(@mail.to_s.scan(/Content-Type:\s+multipart(?:.+;\r\n)*.+[^;]\r\n/)).
120
- to satisfy{|matches| matches.all?{|type| !type.include?('charset')}}
119
+ to satisfy { |matches| matches.all? { |type| !type.include?('charset') } }
121
120
  end
122
121
 
123
- it "does not cause double-conversion on reparsing" do
122
+ it 'does not cause double-conversion on reparsing' do
124
123
  @reparsed = Mail.new(@mail.to_s)
125
- expect(@reparsed.to_s).to match(Regexp.escape("g2WDWINn"))
126
- expect(@reparsed.parts.first.parts.first.parts.first.body.decoded).to match("テストです")
124
+ expect(@reparsed.to_s).to match(Regexp.escape('g2WDWINn'))
125
+ expect(@reparsed.parts.first.parts.first.parts.first.body.decoded).to match('テストです')
127
126
  end
128
127
  end
129
128
  end
130
129
 
131
- describe "Au" do
130
+ describe 'Au' do
132
131
  before(:each) do
133
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/au-decomail.eml")).read)
132
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/au-decomail.eml')).read)
134
133
  end
135
134
 
136
- it "subject should be parsed correctly" do
137
- expect(@mail.subject).to eq("テスト")
135
+ it 'subject should be parsed correctly' do
136
+ expect(@mail.subject).to eq('テスト')
138
137
  end
139
138
 
140
- it "body should be parsed correctly" do
139
+ it 'body should be parsed correctly' do
141
140
  expect(@mail.body.parts.size).to eq(1)
142
- @mail.body.parts.first.parts.size == 1
143
- expect(@mail.body.parts.first.parts.first.body.to_s).to match("テストです")
144
- expect(@mail.body.parts.first.parts.last.body.raw_source).to match("テストです")
141
+ expect(@mail.body.parts.first.parts.size).to eq(2)
142
+ expect(@mail.body.parts.first.parts.first.body.to_s).to match('テストです')
143
+ expect(@mail.body.parts.first.parts.last.body.raw_source).to match('テストです')
145
144
  end
146
145
 
147
- it "should encode correctly" do
148
- expect(ascii_8bit(@mail.to_s)).to match(Regexp.escape("GyRCJUYlOSVIdk8bKEI="))
146
+ it 'should encode correctly' do
147
+ expect(ascii_8bit(@mail.to_s)).to match(Regexp.escape('GyRCJUYlOSVIdk8bKEI='))
149
148
  end
150
149
  end
151
150
 
152
- describe "Softbank" do
153
- context "Shift_JIS" do
151
+ describe 'Softbank' do
152
+ context 'Shift_JIS' do
154
153
  before(:each) do
155
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-sjis.eml")).read)
154
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-sjis.eml')).read)
156
155
  end
157
156
 
158
- it "subject should be parsed correctly" do
159
- expect(@mail.subject).to eq("テスト")
157
+ it 'subject should be parsed correctly' do
158
+ expect(@mail.subject).to eq('テスト')
160
159
  end
161
160
 
162
- it "body should be parsed correctly" do
161
+ it 'body should be parsed correctly' do
163
162
  expect(@mail.body.parts.size).to eq(2)
164
- expect(@mail.body.parts.first.body.to_s).to eq("テストです")
163
+ expect(@mail.body.parts.first.body.to_s).to eq('テストです')
165
164
  end
166
165
 
167
- it "should encode correctly" do
168
- expect(@mail.to_s).to match(Regexp.escape("g2WDWINn98H3w/fB"))
166
+ it 'should encode correctly' do
167
+ expect(@mail.to_s).to match(Regexp.escape('g2WDWINn98H3w/fB'))
169
168
  end
170
169
  end
171
170
 
172
- context "UTF-8" do
171
+ context 'UTF-8' do
173
172
  before(:each) do
174
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-utf8.eml")).read)
173
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-utf8.eml')).read)
175
174
  end
176
175
 
177
- it "subject should be parsed correctly" do
178
- expect(@mail.subject).to eq("テストです")
176
+ it 'subject should be parsed correctly' do
177
+ expect(@mail.subject).to eq('テストです')
179
178
  end
180
179
 
181
- it "body should be parsed correctly" do
180
+ it 'body should be parsed correctly' do
182
181
  expect(@mail.body.parts.size).to eq(2)
183
- expect(@mail.body.parts.first.body.raw_source).to eq("テストです")
182
+ expect(@mail.body.parts.first.body.raw_source).to eq('テストです')
184
183
  end
185
184
 
186
- it "should encode correctly to Shift_JIS" do
187
- expect(@mail.to_s).to match(Regexp.escape("g2WDWINngsWCt/fB"))
185
+ it 'should encode correctly to Shift_JIS' do
186
+ expect(@mail.to_s).to match(Regexp.escape('g2WDWINngsWCt/fB'))
188
187
  end
189
188
  end
190
189
  end
191
190
 
192
191
  context 'bounced mail' do
193
192
  it 'should parse sub-part charset correctly' do
194
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/bounce_with_utf8_part.eml")).read)
193
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/bounce_with_utf8_part.eml')).read)
195
194
  expect(@mail.parts.first.charset).to match(/iso-2022-jp/i)
196
195
  expect(@mail.parts.last.charset).to match(/utf-8/i)
197
196
  end
198
197
  end
199
198
  end
200
199
 
201
- describe "Docomo" do
200
+ describe 'Docomo' do
202
201
  before(:each) do
203
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/docomo-emoji.eml")).read)
202
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/docomo-emoji.eml')).read)
204
203
  end
205
204
 
206
- it "subject should be parsed correctly" do
207
- expect(@mail.subject).to eq("題名")
205
+ it 'subject should be parsed correctly' do
206
+ expect(@mail.subject).to eq('題名')
208
207
  end
209
208
 
210
- it "body should be parsed correctly" do
211
- expect(@mail.body.to_s).to eq("本文\nFor docomo\n\n")
209
+ it 'body should be parsed correctly' do
210
+ expect(@mail.body.to_s).to eq("本文\r\nFor docomo\r\n\r\n")
212
211
  end
213
212
 
214
- context "to_s" do
215
- it "should have subject which is same as original" do
216
- expect(@mail.to_s).to match(Regexp.escape("keiWvPjX"))
213
+ context 'to_s' do
214
+ it 'should have subject which is same as original' do
215
+ expect(@mail.to_s).to match(Regexp.escape('keiWvPjX'))
217
216
  end
218
217
 
219
- it "should have body which is same as original" do
220
- expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis("本文")))
218
+ it 'should have body which is same as original' do
219
+ expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis('本文')))
221
220
  end
222
221
  end
223
222
 
224
- context "modify and to_s" do
225
- it "should encode subject correctly" do
226
- @mail.subject = "大江戸"
227
- expect(@mail.to_s).to match(Regexp.escape("keWNXYzL+J8="))
223
+ context 'modify and to_s' do
224
+ it 'should encode subject correctly' do
225
+ @mail.subject = '大江戸'
226
+ expect(@mail.to_s).to match(Regexp.escape('keWNXYzL+J8='))
228
227
  end
229
228
 
230
- it "should encode body correctly" do
231
- @mail.body = "会議が開催"
229
+ it 'should encode body correctly' do
230
+ @mail.body = '会議が開催'
232
231
  expect(@mail.to_s).to match(sjis_regexp(sjis("\x89\xEF\x8Bc\x82\xAA\x8AJ\x8D\xC3\xF8\xA7")))
233
232
  end
234
233
  end
235
234
 
236
- context "JIS mail" do
235
+ context 'JIS mail' do
237
236
  before(:each) do
238
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/docomo-jis.eml")).read)
237
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/docomo-jis.eml')).read)
239
238
  end
240
239
 
241
- it "subject should be parsed correctly" do
242
- expect(@mail.subject).to eq("テスト")
240
+ it 'subject should be parsed correctly' do
241
+ expect(@mail.subject).to eq('テスト')
243
242
  end
244
243
 
245
- it "body should be parsed correctly" do
244
+ it 'body should be parsed correctly' do
246
245
  expect(@mail.body.to_s).to eq("テスト本文\n\n")
247
246
  end
248
247
  end
249
248
  end
250
249
 
251
- describe "Au" do
250
+ describe 'Au' do
252
251
  context 'au-emoji.eml' do
253
252
  before(:each) do
254
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/au-emoji.eml")).read)
253
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/au-emoji.eml')).read)
255
254
  end
256
255
 
257
- it "subject should be parsed correctly" do
258
- expect(@mail.subject).to eq("題名")
256
+ it 'subject should be parsed correctly' do
257
+ expect(@mail.subject).to eq('題名')
259
258
  end
260
259
 
261
- it "body should be parsed correctly" do
260
+ it 'body should be parsed correctly' do
262
261
  expect(@mail.body.to_s).to eq("本文\nFor au\n\n")
263
262
  end
264
263
 
265
- context "to_s" do
266
- it "should have subject which is same as original" do
267
- expect(ascii_8bit(@mail.to_s)).to match(Regexp.escape("GyRCQmpMPnZeGyhC"))
264
+ context 'to_s' do
265
+ it 'should have subject which is same as original' do
266
+ expect(ascii_8bit(@mail.to_s)).to match(Regexp.escape('GyRCQmpMPnZeGyhC'))
268
267
  end
269
268
 
270
- it "should have body which is same as original" do
269
+ it 'should have body which is same as original' do
271
270
  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"))))
272
271
  end
273
272
  end
274
273
 
275
- context "modify and to_s" do
276
- it "should encode subject correctly" do
277
- @mail.subject = "大江戸"
274
+ context 'modify and to_s' do
275
+ it 'should encode subject correctly' do
276
+ @mail.subject = '大江戸'
278
277
  expect(ascii_8bit(@mail.to_s)).to match(/\?GyRCQmc5PjhNdUEbKEI=/)
279
278
  end
280
279
 
281
- it "should encode body correctly" do
282
- @mail.body = "会議が開催"
280
+ it 'should encode body correctly' do
281
+ @mail.body = '会議が開催'
283
282
  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"))))
284
283
  end
285
284
  end
286
285
  end
287
286
 
288
- it "should not be raised when parsing incoming email #41" do
287
+ it 'should not be raised when parsing incoming email #41' do
289
288
  expect {
290
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/au-email.eml")).read)
289
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/au-email.eml')).read)
291
290
  }.not_to raise_error
292
291
  end
293
292
 
294
- it "should not be raised when parsing incoming email #45" do
293
+ it 'should not be raised when parsing incoming email #45' do
295
294
  expect {
296
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/au-decomail2.eml")).read)
295
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/au-decomail2.eml')).read)
297
296
  }.not_to raise_error
298
297
  end
299
298
 
300
- it "should not be raised when parsing incoming email - include kigou" do
299
+ it 'should not be raised when parsing incoming email - include kigou' do
301
300
  expect {
302
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/au-kigou.eml")).read)
301
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/au-kigou.eml')).read)
303
302
  }.not_to raise_error
304
303
  end
305
304
 
306
305
  context 'From au iPhone' do
307
306
  it 'charset should be UTF-8' do
308
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-message.eml")).read)
307
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-message.eml')).read)
309
308
  expect(@mail.mobile).to be_a(Jpmobile::Mobile::Au)
310
309
  expect(@mail.charset).to match(/utf-8/i)
311
310
  end
312
311
 
313
312
  it 'should be encoded correctly' do
314
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-message.eml")).read)
313
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-message.eml')).read)
315
314
  expect(@mail.encoded).to match(Regexp.escape("%[\e$B1`;yL>\e(B]%\e$B$N\e(B%[\e$BJ]8n<TL>\e(B]%"))
316
315
  end
317
316
 
318
317
  it 'should decode cp932-encoded mail correctly' do
319
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-cp932.eml")).read)
318
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-cp932.eml')).read)
320
319
  expect(@mail.subject).to eq 'Re: 【NKSC】test'
321
320
  expect(@mail.body.to_s).to eq 'テストです。㈱'
322
321
  end
@@ -324,145 +323,145 @@ describe "Jpmobile::Mail#receive" do
324
323
 
325
324
  context 'From iPad' do
326
325
  it 'charset should be UTF-8' do
327
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-mail3.eml")).read)
326
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-mail3.eml')).read)
328
327
  expect(@mail.mobile).to be_a(Jpmobile::Mobile::AbstractMobile)
329
328
  expect(@mail.charset).to match(/utf-8/i)
330
329
  end
331
330
 
332
331
  it 'should be encoded correctly' do
333
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-mail3.eml")).read)
332
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-mail3.eml')).read)
334
333
  expect(@mail.encoded).to match(/BK\\J82~9T\$J\$7!2#5#1#2J8;z!2/)
335
334
  end
336
335
  end
337
336
 
338
337
  it 'should not raise when parsing attached email' do
339
338
  expect {
340
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/au-attached.eml")).read)
339
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/au-attached.eml')).read)
341
340
  expect(@mail.encoded).to match('/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAPQAA')
342
341
  }.not_to raise_error
343
342
  end
344
343
  end
345
344
 
346
- describe "Softbank" do
345
+ describe 'Softbank' do
347
346
  before(:each) do
348
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/softbank-emoji.eml")).read)
347
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/softbank-emoji.eml')).read)
349
348
  end
350
349
 
351
- it "subject should be parsed correctly" do
352
- expect(@mail.subject).to eq("題名&#xf03c;")
350
+ it 'subject should be parsed correctly' do
351
+ expect(@mail.subject).to eq('題名&#xf03c;')
353
352
  end
354
353
 
355
- it "body should be parsed correctly" do
356
- expect(@mail.body.to_s).to eq("本文&#xf21c;\nFor softbank\n\n")
354
+ it 'body should be parsed correctly' do
355
+ expect(@mail.body.to_s).to eq("本文&#xf21c;\r\nFor softbank\r\n\r\n")
357
356
  end
358
357
 
359
- context "to_s" do
360
- it "should have subject which is same as original" do
361
- expect(@mail.to_s).to match(sjis_regexp("keiWvPl8"))
358
+ context 'to_s' do
359
+ it 'should have subject which is same as original' do
360
+ expect(@mail.to_s).to match(sjis_regexp('keiWvPl8'))
362
361
  end
363
362
 
364
- it "should have body which is same as original" do
365
- expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis("本文")))
363
+ it 'should have body which is same as original' do
364
+ expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis('本文')))
366
365
  end
367
366
  end
368
367
 
369
- context "modify and to_s" do
370
- it "should encode subject correctly" do
371
- @mail.subject = "大江戸&#xe63e;"
372
- expect(@mail.to_s).to match(Regexp.escape("keWNXYzL+Ys="))
368
+ context 'modify and to_s' do
369
+ it 'should encode subject correctly' do
370
+ @mail.subject = '大江戸&#xe63e;'
371
+ expect(@mail.to_s).to match(Regexp.escape('keWNXYzL+Ys='))
373
372
  end
374
373
 
375
- it "should encode body correctly" do
376
- @mail.body = "会議が開催&#xe646;"
377
- expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis("会議が開催") + sjis("\xf7\xdf")))
374
+ it 'should encode body correctly' do
375
+ @mail.body = '会議が開催&#xe646;'
376
+ expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis('会議が開催') + sjis("\xf7\xdf")))
378
377
  end
379
378
  end
380
379
 
381
- describe "blank-mail" do
380
+ describe 'blank-mail' do
382
381
  before(:each) do
383
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/softbank-blank.eml")).read)
382
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/softbank-blank.eml')).read)
384
383
  end
385
384
 
386
- it "subject should be parsed correctly" do
385
+ it 'subject should be parsed correctly' do
387
386
  expect(@mail.subject).to be_nil
388
387
  end
389
388
 
390
- it "body should be parsed correctly" do
389
+ it 'body should be parsed correctly' do
391
390
  expect(@mail.body.to_s).to be_empty
392
391
  end
393
392
  end
394
393
  end
395
394
 
396
- describe "iPhone" do
397
- context "JIS mail" do
395
+ describe 'iPhone' do
396
+ context 'JIS mail' do
398
397
  before(:each) do
399
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-jis.eml")).read)
398
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-jis.eml')).read)
400
399
  end
401
400
 
402
- it "body should be parsed correctly" do
401
+ it 'body should be parsed correctly' do
403
402
  expect(@mail.body.to_s).to eq("(=゚ω゚)ノ\n\n\n")
404
403
  end
405
404
  end
406
405
 
407
- context "when the mail contains UTF-8 emojis" do
406
+ context 'when the mail contains UTF-8 emojis' do
408
407
  before(:each) do
409
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-unicode-emoji.eml")).read)
408
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-unicode-emoji.eml')).read)
410
409
  end
411
410
 
412
- it "subject should be parsed correctly" do
411
+ it 'subject should be parsed correctly' do
413
412
  expect(@mail.subject).to eq("絵文字\u{1F385}")
414
413
  end
415
414
 
416
- it "body should be parsed correctly" do
415
+ it 'body should be parsed correctly' do
417
416
  expect(@mail.body.to_s).to eq("\u{1F384}\u2763")
418
417
  end
419
418
  end
420
419
 
421
- context "when the mail contains circled-numbers" do
420
+ context 'when the mail contains circled-numbers' do
422
421
  before(:each) do
423
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-circled-numbers-in-jis.eml")).read)
422
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-circled-numbers-in-jis.eml')).read)
424
423
  end
425
424
 
426
- it "subject should be parsed correctly" do
427
- expect(@mail.subject).to eq("テスト①")
425
+ it 'subject should be parsed correctly' do
426
+ expect(@mail.subject).to eq('テスト①')
428
427
  end
429
428
 
430
- it "body should be parsed correctly" do
429
+ it 'body should be parsed correctly' do
431
430
  expect(@mail.body.to_s).to eq("丸数字のテストです②ⅱ\n\n")
432
431
  end
433
432
  end
434
433
  end
435
434
 
436
435
  describe 'bounced mail' do
437
- context "has jp address" do
436
+ context 'has jp address' do
438
437
  before(:each) do
439
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/bounced-jp.eml")).read)
438
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/bounced-jp.eml')).read)
440
439
  end
441
440
 
442
- it "mobile should abstract mobile" do
441
+ it 'mobile should abstract mobile' do
443
442
  expect(@mail.mobile).to be_a Jpmobile::Mobile::AbstractMobile
444
443
  end
445
444
  end
446
445
  end
447
446
 
448
- describe "non-Japanese mail" do
449
- context "us-ascii" do
447
+ describe 'non-Japanese mail' do
448
+ context 'us-ascii' do
450
449
  before(:each) do
451
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/non-jp.eml")).read)
450
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/non-jp.eml')).read)
452
451
  end
453
452
 
454
- it "mobile should be nil" do
453
+ it 'mobile should be nil' do
455
454
  expect(@mail.mobile).to be_nil
456
455
  expect(@mail.parts.first.charset).to eq('us-ascii')
457
456
  end
458
457
  end
459
458
 
460
- context "no From header" do
459
+ context 'no From header' do
461
460
  before(:each) do
462
- @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/no-from.eml")).read)
461
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/no-from.eml')).read)
463
462
  end
464
463
 
465
- it "mobile should be nil" do
464
+ it 'mobile should be nil' do
466
465
  expect(@mail.mobile).to be_nil
467
466
  expect(@mail.parts.first.charset).to eq('iso-8859-1')
468
467
  end