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,149 +1,158 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
3
2
 
4
3
  describe Jpmobile::Filter do
5
4
  include Rack::Test::Methods
6
5
  include Jpmobile::RackHelper
7
6
 
8
- context "漢字コード変換" do
7
+ context '漢字コード変換' do
9
8
  before(:each) do
10
9
  @utf8 = "ゆーてぃーえふえいとの\n日本語〜ですが何か"
11
10
  @sjis = utf8_to_sjis(@utf8)
12
11
  end
13
12
 
14
- context "docomo のとき" do
15
- it "Shift_JIS に変換されること" do
13
+ context 'docomo のとき' do
14
+ it 'Shift_JIS に変換されること' do
16
15
  res = Rack::MockRequest.env_for(
17
- "/",
18
- "REQUEST_METHOD" => "GET",
16
+ '/',
17
+ 'REQUEST_METHOD' => 'GET',
19
18
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
20
- 'Content-Type' => 'text/html; charset=utf-8')
19
+ 'Content-Type' => 'text/html; charset=utf-8'
20
+ )
21
21
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
22
- expect(res[1]['Content-Type']).to eq("text/html; charset=Shift_JIS")
22
+ expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
23
23
  expect(response_body(res)).to eq(@sjis)
24
24
  end
25
25
 
26
- context "Content-Type" do
27
- it "が application/xhtml+xml のときに変換されること" do
26
+ context 'Content-Type' do
27
+ it 'が application/xhtml+xml のときに変換されること' do
28
28
  res = Rack::MockRequest.env_for(
29
- "/",
30
- "REQUEST_METHOD" => "GET",
29
+ '/',
30
+ 'REQUEST_METHOD' => 'GET',
31
31
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
32
- 'Content-Type' => 'application/xhtml+xml; charset=utf-8')
32
+ 'Content-Type' => 'application/xhtml+xml; charset=utf-8'
33
+ )
33
34
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
34
- expect(res[1]['Content-Type']).to eq("application/xhtml+xml; charset=Shift_JIS")
35
+ expect(res[1]['Content-Type']).to eq('application/xhtml+xml; charset=Shift_JIS')
35
36
  expect(response_body(res)).to eq(@sjis)
36
37
  end
37
38
 
38
- it "が application/xml のときに変換されないこと" do
39
+ it 'が application/xml のときに変換されないこと' do
39
40
  res = Rack::MockRequest.env_for(
40
- "/",
41
- "REQUEST_METHOD" => "GET",
41
+ '/',
42
+ 'REQUEST_METHOD' => 'GET',
42
43
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
43
- 'Content-Type' => 'application/xml; charset=utf-8')
44
+ 'Content-Type' => 'application/xml; charset=utf-8'
45
+ )
44
46
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
45
- expect(res[1]['Content-Type']).to eq("application/xml; charset=utf-8")
47
+ expect(res[1]['Content-Type']).to eq('application/xml; charset=utf-8')
46
48
  expect(response_body(res)).to eq(@utf8)
47
49
  end
48
50
 
49
- it "が image/jpeg のときに変換されないこと" do
51
+ it 'が image/jpeg のときに変換されないこと' do
50
52
  res = Rack::MockRequest.env_for(
51
- "/",
52
- "REQUEST_METHOD" => "GET",
53
+ '/',
54
+ 'REQUEST_METHOD' => 'GET',
53
55
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
54
- 'Content-Type' => 'image/jpeg')
56
+ 'Content-Type' => 'image/jpeg'
57
+ )
55
58
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
56
- expect(res[1]['Content-Type']).to eq("image/jpeg")
59
+ expect(res[1]['Content-Type']).to eq('image/jpeg')
57
60
  expect(response_body(res)).to eq(@utf8)
58
61
  end
59
62
 
60
- it "が application/octet-stream のときに変換されないこと" do
63
+ it 'が application/octet-stream のときに変換されないこと' do
61
64
  res = Rack::MockRequest.env_for(
62
- "/",
63
- "REQUEST_METHOD" => "GET",
65
+ '/',
66
+ 'REQUEST_METHOD' => 'GET',
64
67
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
65
- 'Content-Type' => 'application/octet-stream')
68
+ 'Content-Type' => 'application/octet-stream'
69
+ )
66
70
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
67
- expect(res[1]['Content-Type']).to eq("application/octet-stream")
71
+ expect(res[1]['Content-Type']).to eq('application/octet-stream')
68
72
  expect(response_body(res)).to eq(@utf8)
69
73
  end
70
74
 
71
- it "が video/mpeg のときに変換されないこと" do
75
+ it 'が video/mpeg のときに変換されないこと' do
72
76
  res = Rack::MockRequest.env_for(
73
- "/",
74
- "REQUEST_METHOD" => "GET",
77
+ '/',
78
+ 'REQUEST_METHOD' => 'GET',
75
79
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
76
- 'Content-Type' => 'video/mpeg')
80
+ 'Content-Type' => 'video/mpeg'
81
+ )
77
82
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
78
- expect(res[1]['Content-Type']).to eq("video/mpeg")
83
+ expect(res[1]['Content-Type']).to eq('video/mpeg')
79
84
  expect(response_body(res)).to eq(@utf8)
80
85
  end
81
86
  end
82
87
  end
83
88
 
84
- context "au のとき" do
85
- it "Shift_JIS に変換されること" do
89
+ context 'au のとき' do
90
+ it 'Shift_JIS に変換されること' do
86
91
  res = Rack::MockRequest.env_for(
87
- "/",
88
- "REQUEST_METHOD" => "GET",
89
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
90
- 'Content-Type' => 'text/html; charset=utf-8')
92
+ '/',
93
+ 'REQUEST_METHOD' => 'GET',
94
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
95
+ 'Content-Type' => 'text/html; charset=utf-8'
96
+ )
91
97
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
92
- expect(res[1]['Content-Type']).to eq("text/html; charset=Shift_JIS")
98
+ expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
93
99
  expect(response_body(res)).to eq(@sjis)
94
100
  end
95
101
  end
96
102
 
97
- context "softbank のとき" do
98
- it "変換されないこと" do
103
+ context 'softbank のとき' do
104
+ it '変換されないこと' do
99
105
  res = Rack::MockRequest.env_for(
100
- "/",
101
- "REQUEST_METHOD" => "GET",
102
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
103
- 'Content-Type' => 'text/html; charset=utf-8')
106
+ '/',
107
+ 'REQUEST_METHOD' => 'GET',
108
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
109
+ 'Content-Type' => 'text/html; charset=utf-8'
110
+ )
104
111
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
105
- expect(res[1]['Content-Type']).to eq("text/html; charset=utf-8")
112
+ expect(res[1]['Content-Type']).to eq('text/html; charset=utf-8')
106
113
  expect(response_body(res)).to eq(@utf8)
107
114
  end
108
115
  end
109
116
 
110
- it "_snowman が出力されないこと" do
117
+ it '_snowman が出力されないこと' do
111
118
  req = Rack::MockRequest.env_for(
112
- "/",
113
- "REQUEST_METHOD" => "GET",
119
+ '/',
120
+ 'REQUEST_METHOD' => 'GET',
114
121
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
115
- 'Content-Type' => 'text/html; charset=utf-8')
122
+ 'Content-Type' => 'text/html; charset=utf-8'
123
+ )
116
124
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('<input name="utf8" type="hidden" value="&#x2713;" />'))).call(req)
117
- expect(res[1]['Content-Type']).to eq("text/html; charset=Shift_JIS")
118
- expect(response_body(res)).to eq(" ")
125
+ expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
126
+ expect(response_body(res)).to eq(' ')
119
127
 
120
128
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('<input name="utf8" type="hidden" value="&#x2713;">'))).call(req)
121
- expect(res[1]['Content-Type']).to eq("text/html; charset=Shift_JIS")
122
- expect(response_body(res)).to eq(" ")
129
+ expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
130
+ expect(response_body(res)).to eq(' ')
123
131
  end
124
132
 
125
- it "Nokogiri 経由の _snowman が出力されないこと" do
133
+ it 'Nokogiri 経由の _snowman が出力されないこと' do
126
134
  req = Rack::MockRequest.env_for(
127
- "/",
128
- "REQUEST_METHOD" => "GET",
135
+ '/',
136
+ 'REQUEST_METHOD' => 'GET',
129
137
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
130
- 'Content-Type' => 'text/html; charset=utf-8')
138
+ 'Content-Type' => 'text/html; charset=utf-8'
139
+ )
131
140
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new("<input name=\"utf8\" type=\"hidden\" value=\"#{[10003].pack("U")}\" />"))).call(req)
132
- expect(res[1]['Content-Type']).to eq("text/html; charset=Shift_JIS")
133
- expect(response_body(res)).to eq(" ")
141
+ expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
142
+ expect(response_body(res)).to eq(' ')
134
143
 
135
144
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new("<input name=\"utf8\" type=\"hidden\" value=\"#{[10003].pack("U")}\">"))).call(req)
136
- expect(res[1]['Content-Type']).to eq("text/html; charset=Shift_JIS")
137
- expect(response_body(res)).to eq(" ")
145
+ expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
146
+ expect(response_body(res)).to eq(' ')
138
147
  end
139
148
  end
140
149
 
141
- context "絵文字変換" do
150
+ context '絵文字変換' do
142
151
  before(:each) do
143
- @utf8 = "ゆーてぃーえふえいとの日本語ですが何か"
144
- @emoji_docomo_cr = "&#xe64b;"
145
- @emoji_au_cr = "&#xe494;"
146
- @emoji_softbank_cr = "&#xf244;"
152
+ @utf8 = 'ゆーてぃーえふえいとの日本語ですが何か'
153
+ @emoji_docomo_cr = '&#xe64b;'
154
+ @emoji_au_cr = '&#xe494;'
155
+ @emoji_softbank_cr = '&#xf244;'
147
156
  @emoji_docomo_utf8 = utf8([0xe64b].pack('U'))
148
157
  @emoji_au_utf8 = utf8([0xe494].pack('U'))
149
158
  @emoji_softbank_utf8 = utf8([0xf244].pack('U'))
@@ -154,127 +163,139 @@ describe Jpmobile::Filter do
154
163
  @softbank_emoji = utf8("\356\211\204")
155
164
  end
156
165
 
157
- context "docomo のとき" do
158
- it "数値参照絵文字が変換されること" do
166
+ context 'docomo のとき' do
167
+ it '数値参照絵文字が変換されること' do
159
168
  res = Rack::MockRequest.env_for(
160
- "/",
161
- "REQUEST_METHOD" => "GET",
169
+ '/',
170
+ 'REQUEST_METHOD' => 'GET',
162
171
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
163
- 'Content-Type' => 'text/html; charset=utf-8')
172
+ 'Content-Type' => 'text/html; charset=utf-8'
173
+ )
164
174
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_docomo_cr))).call(res)
165
175
  expect(response_body(res)).to eq(@sjis + @docomo_emoji)
166
176
  end
167
177
 
168
- it "docomo のUTF-8絵文字が変換されること" do
178
+ it 'docomo のUTF-8絵文字が変換されること' do
169
179
  res = Rack::MockRequest.env_for(
170
- "/",
171
- "REQUEST_METHOD" => "GET",
180
+ '/',
181
+ 'REQUEST_METHOD' => 'GET',
172
182
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
173
- 'Content-Type' => 'text/html; charset=utf-8')
183
+ 'Content-Type' => 'text/html; charset=utf-8'
184
+ )
174
185
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_docomo_utf8))).call(res)
175
186
  expect(response_body(res)).to eq(@sjis + @docomo_emoji)
176
187
  end
177
188
 
178
- it "au のUTF-8絵文字が変換されること" do
189
+ it 'au のUTF-8絵文字が変換されること' do
179
190
  res = Rack::MockRequest.env_for(
180
- "/",
181
- "REQUEST_METHOD" => "GET",
191
+ '/',
192
+ 'REQUEST_METHOD' => 'GET',
182
193
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
183
- 'Content-Type' => 'text/html; charset=utf-8')
194
+ 'Content-Type' => 'text/html; charset=utf-8'
195
+ )
184
196
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_au_utf8))).call(res)
185
197
  expect(response_body(res)).to eq(@sjis + @docomo_emoji)
186
198
  end
187
199
 
188
- it "softbank のUTF-8絵文字が変換されること" do
200
+ it 'softbank のUTF-8絵文字が変換されること' do
189
201
  res = Rack::MockRequest.env_for(
190
- "/",
191
- "REQUEST_METHOD" => "GET",
202
+ '/',
203
+ 'REQUEST_METHOD' => 'GET',
192
204
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
193
- 'Content-Type' => 'text/html; charset=utf-8')
205
+ 'Content-Type' => 'text/html; charset=utf-8'
206
+ )
194
207
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_softbank_utf8))).call(res)
195
208
  expect(response_body(res)).to eq(@sjis + @docomo_emoji)
196
209
  end
197
210
  end
198
211
 
199
- context "au のとき" do
200
- it "数値参照絵文字が変換されること" do
212
+ context 'au のとき' do
213
+ it '数値参照絵文字が変換されること' do
201
214
  res = Rack::MockRequest.env_for(
202
- "/",
203
- "REQUEST_METHOD" => "GET",
204
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
205
- 'Content-Type' => 'text/html; charset=utf-8')
215
+ '/',
216
+ 'REQUEST_METHOD' => 'GET',
217
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
218
+ 'Content-Type' => 'text/html; charset=utf-8'
219
+ )
206
220
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_au_cr))).call(res)
207
221
  expect(response_body(res)).to eq(@sjis + @au_emoji)
208
222
  end
209
223
 
210
- it "docomo のUTF-8絵文字が変換されること" do
224
+ it 'docomo のUTF-8絵文字が変換されること' do
211
225
  res = Rack::MockRequest.env_for(
212
- "/",
213
- "REQUEST_METHOD" => "GET",
214
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
215
- 'Content-Type' => 'text/html; charset=utf-8')
226
+ '/',
227
+ 'REQUEST_METHOD' => 'GET',
228
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
229
+ 'Content-Type' => 'text/html; charset=utf-8'
230
+ )
216
231
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_docomo_utf8))).call(res)
217
232
  expect(response_body(res)).to eq(@sjis + @au_emoji)
218
233
  end
219
234
 
220
- it "au のUTF-8絵文字が変換されること" do
235
+ it 'au のUTF-8絵文字が変換されること' do
221
236
  res = Rack::MockRequest.env_for(
222
- "/",
223
- "REQUEST_METHOD" => "GET",
224
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
225
- 'Content-Type' => 'text/html; charset=utf-8')
237
+ '/',
238
+ 'REQUEST_METHOD' => 'GET',
239
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
240
+ 'Content-Type' => 'text/html; charset=utf-8'
241
+ )
226
242
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_au_utf8))).call(res)
227
243
  expect(response_body(res)).to eq(@sjis + @au_emoji)
228
244
  end
229
245
 
230
- it "softbank のUTF-8絵文字が変換されること" do
246
+ it 'softbank のUTF-8絵文字が変換されること' do
231
247
  res = Rack::MockRequest.env_for(
232
- "/",
233
- "REQUEST_METHOD" => "GET",
234
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
235
- 'Content-Type' => 'text/html; charset=utf-8')
248
+ '/',
249
+ 'REQUEST_METHOD' => 'GET',
250
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
251
+ 'Content-Type' => 'text/html; charset=utf-8'
252
+ )
236
253
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_softbank_utf8))).call(res)
237
254
  expect(response_body(res)).to eq(@sjis + @au_emoji)
238
255
  end
239
256
  end
240
257
 
241
- context "softbank のとき" do
242
- it "数値参照絵文字が変換されること" do
258
+ context 'softbank のとき' do
259
+ it '数値参照絵文字が変換されること' do
243
260
  res = Rack::MockRequest.env_for(
244
- "/",
245
- "REQUEST_METHOD" => "GET",
246
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
247
- 'Content-Type' => 'text/html; charset=utf-8')
261
+ '/',
262
+ 'REQUEST_METHOD' => 'GET',
263
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
264
+ 'Content-Type' => 'text/html; charset=utf-8'
265
+ )
248
266
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_softbank_cr))).call(res)
249
267
  expect(response_body(res)).to eq(@utf8 + @softbank_emoji)
250
268
  end
251
269
 
252
- it "docomo のUTF-8絵文字が変換されること" do
270
+ it 'docomo のUTF-8絵文字が変換されること' do
253
271
  res = Rack::MockRequest.env_for(
254
- "/",
255
- "REQUEST_METHOD" => "GET",
256
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
257
- 'Content-Type' => 'text/html; charset=utf-8')
272
+ '/',
273
+ 'REQUEST_METHOD' => 'GET',
274
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
275
+ 'Content-Type' => 'text/html; charset=utf-8'
276
+ )
258
277
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_docomo_utf8))).call(res)
259
278
  expect(response_body(res)).to eq(@utf8 + @softbank_emoji)
260
279
  end
261
280
 
262
- it "au のUTF-8絵文字が変換されること" do
281
+ it 'au のUTF-8絵文字が変換されること' do
263
282
  res = Rack::MockRequest.env_for(
264
- "/",
265
- "REQUEST_METHOD" => "GET",
266
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
267
- 'Content-Type' => 'text/html; charset=utf-8')
283
+ '/',
284
+ 'REQUEST_METHOD' => 'GET',
285
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
286
+ 'Content-Type' => 'text/html; charset=utf-8'
287
+ )
268
288
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_au_utf8))).call(res)
269
289
  expect(response_body(res)).to eq(@utf8 + @softbank_emoji)
270
290
  end
271
291
 
272
- it "softbank のUTF-8絵文字が変換されること" do
292
+ it 'softbank のUTF-8絵文字が変換されること' do
273
293
  res = Rack::MockRequest.env_for(
274
- "/",
275
- "REQUEST_METHOD" => "GET",
276
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
277
- 'Content-Type' => 'text/html; charset=utf-8')
294
+ '/',
295
+ 'REQUEST_METHOD' => 'GET',
296
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
297
+ 'Content-Type' => 'text/html; charset=utf-8'
298
+ )
278
299
  res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_softbank_utf8))).call(res)
279
300
  expect(response_body(res)).to eq(@utf8 + @softbank_emoji)
280
301
  end
@@ -1,14 +1,14 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
3
2
 
4
- describe Jpmobile::MobileCarrier, "iphone" do
3
+ describe Jpmobile::MobileCarrier, 'iphone' do
5
4
  include Rack::Test::Methods
6
5
 
7
- context "端末種別で" do
8
- it "iPhone を判別できること" do
6
+ context '端末種別で' do
7
+ it 'iPhone を判別できること' do
9
8
  res = Rack::MockRequest.env_for(
10
9
  'http://jpmobile-rails.org/',
11
- 'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16')
10
+ 'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'
11
+ )
12
12
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
13
13
 
14
14
  expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Iphone)
@@ -18,12 +18,13 @@ describe Jpmobile::MobileCarrier, "iphone" do
18
18
  end
19
19
  end
20
20
 
21
- context "IPアドレス制限で" do
22
- it "Softbank 網からのアクセスでも invalid になること" do
21
+ context 'IPアドレス制限で' do
22
+ it 'Softbank 網からのアクセスでも invalid になること' do
23
23
  res = Rack::MockRequest.env_for(
24
24
  'http://jpmobile-rails.org/',
25
25
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16',
26
- "REMOTE_ADDR"=>"202.179.204.1")
26
+ 'REMOTE_ADDR' => '202.179.204.1'
27
+ )
27
28
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
28
29
 
29
30
  expect(env['rack.jpmobile'].valid_ip?).to be_falsey