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,7 +1,6 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
3
2
 
4
- describe "絵文字が" do
3
+ describe '絵文字が' do
5
4
  include Rack::Test::Methods
6
5
  include Jpmobile::RackHelper
7
6
  include Jpmobile::Util
@@ -9,40 +8,40 @@ describe "絵文字が" do
9
8
  before(:each) do
10
9
  Jpmobile.config.smart_phone_emoticon_compatibility = true
11
10
 
12
- @docomo_cr = "";
13
- @docomo_utf8 = [0xe63e].pack("U")
14
- @docomo_docomopoint = ""
11
+ @docomo_cr = '';
12
+ @docomo_utf8 = [0xe63e].pack('U')
13
+ @docomo_docomopoint = ''
15
14
 
16
- @au_cr = ""
17
- @au_utf8 = [0xe488].pack("U")
15
+ @au_cr = ''
16
+ @au_utf8 = [0xe488].pack('U')
18
17
 
19
- @softbank_cr = ""
20
- @softbank_utf8 = [0xf04a].pack("U")
18
+ @softbank_cr = ''
19
+ @softbank_utf8 = [0xf04a].pack('U')
21
20
 
22
- @emoticon_yaml = File.join(File.expand_path(File.dirname(__FILE__)), "../../../tmp/emoticon.yml")
23
- @emoticon_images = File.join(File.expand_path(File.dirname(__FILE__)), "../../../tmp/emoticons")
21
+ @emoticon_yaml = File.join(File.expand_path(File.dirname(__FILE__)), '../../../tmp/emoticon.yml')
22
+ @emoticon_images = File.join(File.expand_path(File.dirname(__FILE__)), '../../../tmp/emoticons')
24
23
  end
25
24
 
26
- context "PC のとき" do
25
+ context 'PC のとき' do
27
26
  before(:each) do
28
- @res = Rack::MockRequest.env_for("/", 'Content-Type' => 'text/html; charset=utf-8')
27
+ @res = Rack::MockRequest.env_for('/', 'Content-Type' => 'text/html; charset=utf-8')
29
28
  end
30
29
 
31
- it "docomo 絵文字が変換されないこと" do
30
+ it 'docomo 絵文字が変換されないこと' do
32
31
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)[2]
33
32
  expect(response_body(response)).to eq(@docomo_cr)
34
33
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)[2]
35
34
  expect(response_body(response)).to eq(@docomo_utf8)
36
35
  end
37
36
 
38
- it "au 絵文字が変換されないこと" do
37
+ it 'au 絵文字が変換されないこと' do
39
38
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)[2]
40
39
  expect(response_body(response)).to eq(@au_cr)
41
40
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)[2]
42
41
  expect(response_body(response)).to eq(@au_utf8)
43
42
  end
44
43
 
45
- it "softbank 絵文字が変換されないこと" do
44
+ it 'softbank 絵文字が変換されないこと' do
46
45
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)[2]
47
46
  expect(response_body(response)).to eq(@softbank_cr)
48
47
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)[2]
@@ -50,17 +49,17 @@ describe "絵文字が" do
50
49
  end
51
50
  end
52
51
 
53
- context "PC で絵文字を変換するとき" do
52
+ context 'PC で絵文字を変換するとき' do
54
53
  before(:each) do
55
- unless FileTest.exist?(File.join(File.expand_path(File.dirname(__FILE__)), '../../../tmp/emoticon.yaml')) and
56
- FileTest.directory?(File.join(File.expand_path(File.dirname(__FILE__)), '../../../tmp/emoticons'))
54
+ unless FileTest.exist?(File.join(File.expand_path(File.dirname(__FILE__)), '../../../tmp/emoticon.yaml')) &&
55
+ FileTest.directory?(File.join(File.expand_path(File.dirname(__FILE__)), '../../../tmp/emoticons'))
57
56
  skip "emoticon.yaml and emoticons directory don't exists"
58
57
  end
59
58
 
60
- @res = Rack::MockRequest.env_for("/", 'Content-Type' => 'text/html; charset=utf-8')
59
+ @res = Rack::MockRequest.env_for('/', 'Content-Type' => 'text/html; charset=utf-8')
61
60
 
62
- Jpmobile::Emoticon.pc_emoticon_yaml = "tmp/emoticon.yaml"
63
- Jpmobile::Emoticon.pc_emoticon_image_path = @path = "tmp/emoticons"
61
+ Jpmobile::Emoticon.pc_emoticon_yaml = 'tmp/emoticon.yaml'
62
+ Jpmobile::Emoticon.pc_emoticon_image_path = @path = 'tmp/emoticons'
64
63
  end
65
64
 
66
65
  after(:each) do
@@ -68,56 +67,57 @@ describe "絵文字が" do
68
67
  Jpmobile::Emoticon.pc_emoticon_image_path = nil
69
68
  end
70
69
 
71
- it "Jpmobile::Emoticon.pc_emoticon? がtrueになること" do
70
+ it 'Jpmobile::Emoticon.pc_emoticon? がtrueになること' do
72
71
  expect(Jpmobile::Emoticon.pc_emoticon?).to be_truthy
73
72
  end
74
73
 
75
- it "docomo 絵文字が画像に変換されること" do
74
+ it 'docomo 絵文字が画像に変換されること' do
76
75
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)[2]
77
76
  expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
78
77
  end
79
78
 
80
- it "docomo 絵文字コードが画像に変換されること" do
79
+ it 'docomo 絵文字コードが画像に変換されること' do
81
80
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)[2]
82
81
  expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
83
82
  end
84
83
 
85
- it "au 絵文字が画像に変換されること" do
84
+ it 'au 絵文字が画像に変換されること' do
86
85
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)[2]
87
86
  expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
88
87
  end
89
88
 
90
- it "au 絵文字コードが画像に変換されること" do
89
+ it 'au 絵文字コードが画像に変換されること' do
91
90
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)[2]
92
91
  expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
93
92
  end
94
93
 
95
- it "softbank 絵文字が画像に変換されること" do
94
+ it 'softbank 絵文字が画像に変換されること' do
96
95
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)[2]
97
96
  expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
98
97
  end
99
98
 
100
- it "softbank 絵文字コードが画像に変換されること" do
99
+ it 'softbank 絵文字コードが画像に変換されること' do
101
100
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)[2]
102
101
  expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
103
102
  end
104
103
 
105
- it "Content-Type が変換できないものである場合には変換しないこと" do
106
- @res = Rack::MockRequest.env_for("/", 'Content-Type' => 'image/jpeg')
104
+ it 'Content-Type が変換できないものである場合には変換しないこと' do
105
+ @res = Rack::MockRequest.env_for('/', 'Content-Type' => 'image/jpeg')
107
106
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)[2]
108
107
  expect(response_body(response)).to eq(@softbank_utf8)
109
108
  end
110
109
  end
111
110
 
112
- context "docomo のとき" do
111
+ context 'docomo のとき' do
113
112
  before(:each) do
114
113
  @res = Rack::MockRequest.env_for(
115
- "/",
116
- 'HTTP_USER_AGENT' => "DoCoMo/2.0 SH902i(c100;TB;W24H12)",
117
- 'Content-Type' => 'text/html; charset=utf-8')
114
+ '/',
115
+ 'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH902i(c100;TB;W24H12)',
116
+ 'Content-Type' => 'text/html; charset=utf-8'
117
+ )
118
118
  end
119
119
 
120
- it "docomo 絵文字が変換されること" do
120
+ it 'docomo 絵文字が変換されること' do
121
121
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)[2]
122
122
  expect(response_body(response)).to eq(sjis("\xf8\x9f"))
123
123
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)[2]
@@ -127,28 +127,29 @@ describe "絵文字が" do
127
127
  expect(response_body(response)).to eq(sjis("\xf9\x79"))
128
128
  end
129
129
 
130
- it "au 絵文字が変換されること" do
130
+ it 'au 絵文字が変換されること' do
131
131
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)[2]
132
132
  expect(response_body(response)).to eq(sjis("\xf8\x9f"))
133
133
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)[2]
134
134
  expect(response_body(response)).to eq(sjis("\xf8\x9f"))
135
135
  end
136
136
 
137
- it "softbank 絵文字が変換されること" do
137
+ it 'softbank 絵文字が変換されること' do
138
138
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)[2]
139
139
  expect(response_body(response)).to eq(sjis("\xf8\x9f"))
140
140
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)[2]
141
141
  expect(response_body(response)).to eq(sjis("\xf8\x9f"))
142
142
  end
143
143
 
144
- it "パラメータが変換されること" do
145
- query_string = ascii_8bit("q=" + URI.encode(sjis("\xf8\x9f")))
144
+ it 'パラメータが変換されること' do
145
+ query_string = ascii_8bit('q=' + URI.encode(sjis("\xf8\x9f")))
146
146
 
147
147
  res = Rack::MockRequest.env_for(
148
148
  "/?#{query_string}",
149
- "REQUEST_METHOD" => "GET",
149
+ 'REQUEST_METHOD' => 'GET',
150
150
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
151
- 'Content-Type' => 'text/html; charset=utf-8')
151
+ 'Content-Type' => 'text/html; charset=utf-8'
152
+ )
152
153
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(Jpmobile::Filter.new(RenderParamApp.new))).call(res)
153
154
  req = Rack::Request.new(res[1])
154
155
  expect(req.params['q']).to eq(utf8("\xee\x98\xbe"))
@@ -156,126 +157,132 @@ describe "絵文字が" do
156
157
  end
157
158
  end
158
159
 
159
- context "au のとき" do
160
+ context 'au のとき' do
160
161
  before(:each) do
161
162
  @res = Rack::MockRequest.env_for(
162
- "/",
163
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
164
- 'Content-Type' => 'text/html; charset=utf-8')
163
+ '/',
164
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
165
+ 'Content-Type' => 'text/html; charset=utf-8'
166
+ )
165
167
  end
166
168
 
167
- it "docomo 絵文字が変換されること" do
169
+ it 'docomo 絵文字が変換されること' do
168
170
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)[2]
169
171
  expect(response_body(response)).to eq(sjis("\xf6\x60"))
170
172
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)[2]
171
173
  expect(response_body(response)).to eq(sjis("\xf6\x60"))
172
174
 
173
175
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_docomopoint))).call(@res)[2]
174
- expect(response_body(response)).to eq(utf8_to_sjis("[ドコモポイント]"))
176
+ expect(response_body(response)).to eq(utf8_to_sjis('[ドコモポイント]'))
175
177
  end
176
178
 
177
- it "au 絵文字が変換されること" do
179
+ it 'au 絵文字が変換されること' do
178
180
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)[2]
179
181
  expect(response_body(response)).to eq(sjis("\xf6\x60"))
180
182
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)[2]
181
183
  expect(response_body(response)).to eq(sjis("\xf6\x60"))
182
184
  end
183
185
 
184
- it "softbank 絵文字が変換されること" do
186
+ it 'softbank 絵文字が変換されること' do
185
187
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)[2]
186
188
  expect(response_body(response)).to eq(sjis("\xf6\x60"))
187
189
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)[2]
188
190
  expect(response_body(response)).to eq(sjis("\xf6\x60"))
189
191
  end
190
192
 
191
- it "パラメータが変換されること" do
192
- query_string = ascii_8bit("q=" + URI.encode(sjis("\xf6\x60")))
193
+ it 'パラメータが変換されること' do
194
+ query_string = ascii_8bit('q=' + URI.encode(sjis("\xf6\x60")))
193
195
 
194
196
  res = Rack::MockRequest.env_for(
195
197
  "/?#{query_string}",
196
- "REQUEST_METHOD" => "GET",
197
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
198
- 'Content-Type' => 'text/html; charset=utf-8')
198
+ 'REQUEST_METHOD' => 'GET',
199
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
200
+ 'Content-Type' => 'text/html; charset=utf-8'
201
+ )
199
202
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(Jpmobile::Filter.new(RenderParamApp.new))).call(res)
200
203
  req = Rack::Request.new(res[1])
201
- expect(req.params['q']).to eq([0xe488].pack("U"))
204
+ expect(req.params['q']).to eq([0xe488].pack('U'))
202
205
  expect(response_body(res)).to eq(sjis("\xf6\x60"))
203
206
  end
204
207
  end
205
208
 
206
- context "softbank のとき" do
209
+ context 'softbank のとき' do
207
210
  before(:each) do
208
211
  @res = Rack::MockRequest.env_for(
209
- "/",
210
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
211
- 'Content-Type' => 'text/html; charset=utf-8')
212
+ '/',
213
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
214
+ 'Content-Type' => 'text/html; charset=utf-8'
215
+ )
212
216
  end
213
217
 
214
- it "docomo 絵文字が変換されること" do
218
+ it 'docomo 絵文字が変換されること' do
215
219
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)[2]
216
220
  expect(response_body(response)).to eq([0xe04a].pack('U'))
217
221
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)[2]
218
222
  expect(response_body(response)).to eq([0xe04a].pack('U'))
219
223
 
220
224
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_docomopoint))).call(@res)[2]
221
- expect(response_body(response)).to eq("[ドコモポイント]")
225
+ expect(response_body(response)).to eq('[ドコモポイント]')
222
226
  end
223
227
 
224
- it "au 絵文字が変換されること" do
228
+ it 'au 絵文字が変換されること' do
225
229
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)[2]
226
230
  expect(response_body(response)).to eq([0xe04a].pack('U'))
227
231
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)[2]
228
232
  expect(response_body(response)).to eq([0xe04a].pack('U'))
229
233
  end
230
234
 
231
- it "softbank 絵文字が変換されること" do
235
+ it 'softbank 絵文字が変換されること' do
232
236
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)[2]
233
237
  expect(response_body(response)).to eq([0xe04a].pack('U'))
234
238
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)[2]
235
239
  expect(response_body(response)).to eq([0xe04a].pack('U'))
236
240
  end
237
241
 
238
- it "パラメータが変換されること" do
239
- query_string = "q=" + URI.encode([0xe04A].pack("U"))
242
+ it 'パラメータが変換されること' do
243
+ query_string = 'q=' + URI.encode([0xe04A].pack('U'))
240
244
 
241
245
  res = Rack::MockRequest.env_for(
242
246
  "/?#{query_string}",
243
- "REQUEST_METHOD" => "GET",
244
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
245
- 'Content-Type' => 'text/html; charset=utf-8')
247
+ 'REQUEST_METHOD' => 'GET',
248
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
249
+ 'Content-Type' => 'text/html; charset=utf-8'
250
+ )
246
251
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(Jpmobile::Filter.new(RenderParamApp.new))).call(res)
247
252
  req = Rack::Request.new(res[1])
248
- expect(req.params['q']).to eq([0xf04a].pack("U"))
253
+ expect(req.params['q']).to eq([0xf04a].pack('U'))
249
254
  expect(response_body(res)).to eq([0xe04a].pack('U'))
250
255
  end
251
256
  end
252
257
 
253
- context "Vodafone のとき" do
258
+ context 'Vodafone のとき' do
254
259
  before(:each) do
255
260
  @res = Rack::MockRequest.env_for(
256
- "/",
257
- 'HTTP_USER_AGENT' => "Vodafone/1.0/V705SH/SHJ001/SN000000000000000 Browser/VF-NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
258
- 'Content-Type' => 'text/html; charset=utf-8')
261
+ '/',
262
+ 'HTTP_USER_AGENT' => 'Vodafone/1.0/V705SH/SHJ001/SN000000000000000 Browser/VF-NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
263
+ 'Content-Type' => 'text/html; charset=utf-8'
264
+ )
259
265
  end
260
266
 
261
- it "softbank 絵文字が変換されること" do
267
+ it 'softbank 絵文字が変換されること' do
262
268
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)[2]
263
269
  expect(response_body(response)).to eq([0xe04a].pack('U'))
264
270
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)[2]
265
271
  expect(response_body(response)).to eq([0xe04a].pack('U'))
266
272
  end
267
273
 
268
- it "パラメータが変換されること" do
269
- query_string = "q=" + URI.encode([0xe04A].pack("U"))
274
+ it 'パラメータが変換されること' do
275
+ query_string = 'q=' + URI.encode([0xe04A].pack('U'))
270
276
 
271
277
  res = Rack::MockRequest.env_for(
272
278
  "/?#{query_string}",
273
- "REQUEST_METHOD" => "GET",
274
- 'HTTP_USER_AGENT' => "Vodafone/1.0/V705SH/SHJ001/SN000000000000000 Browser/VF-NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
275
- 'Content-Type' => 'text/html; charset=utf-8')
279
+ 'REQUEST_METHOD' => 'GET',
280
+ 'HTTP_USER_AGENT' => 'Vodafone/1.0/V705SH/SHJ001/SN000000000000000 Browser/VF-NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
281
+ 'Content-Type' => 'text/html; charset=utf-8'
282
+ )
276
283
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(Jpmobile::Filter.new(RenderParamApp.new))).call(res)
277
284
  req = Rack::Request.new(res[1])
278
- expect(req.params['q']).to eq([0xf04a].pack("U"))
285
+ expect(req.params['q']).to eq([0xf04a].pack('U'))
279
286
  expect(response_body(res)).to eq([0xe04a].pack('U'))
280
287
  end
281
288
  end
@@ -284,9 +291,10 @@ describe "絵文字が" do
284
291
  context 'lower iOS 4' do
285
292
  before(:each) do
286
293
  @res = Rack::MockRequest.env_for(
287
- "/",
288
- 'HTTP_USER_AGENT' => "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; ja-jp) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A306 Safari/6531.22.7",
289
- 'Content-Type' => 'text/html; charset=utf-8')
294
+ '/',
295
+ 'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; ja-jp) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A306 Safari/6531.22.7',
296
+ 'Content-Type' => 'text/html; charset=utf-8'
297
+ )
290
298
  end
291
299
 
292
300
  it 'should convert Softbank emoticon' do
@@ -296,17 +304,18 @@ describe "絵文字が" do
296
304
  expect(response_body(response)).to eq([0xe04a].pack('U'))
297
305
  end
298
306
 
299
- it "converts query parameters" do
300
- query_string = "q=" + URI.encode([0xe04A].pack("U"))
307
+ it 'converts query parameters' do
308
+ query_string = 'q=' + URI.encode([0xe04A].pack('U'))
301
309
 
302
310
  res = Rack::MockRequest.env_for(
303
311
  "/?#{query_string}",
304
- "REQUEST_METHOD" => "GET",
305
- 'HTTP_USER_AGENT' => "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; ja-jp) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A306 Safari/6531.22.7",
306
- 'Content-Type' => 'text/html; charset=utf-8')
312
+ 'REQUEST_METHOD' => 'GET',
313
+ 'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; ja-jp) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A306 Safari/6531.22.7',
314
+ 'Content-Type' => 'text/html; charset=utf-8'
315
+ )
307
316
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(Jpmobile::Filter.new(RenderParamApp.new))).call(res)
308
317
  req = Rack::Request.new(res[1])
309
- expect(req.params['q']).to eq([0xf04a].pack("U"))
318
+ expect(req.params['q']).to eq([0xf04a].pack('U'))
310
319
  expect(response_body(res)).to eq([0xe04a].pack('U'))
311
320
  end
312
321
 
@@ -319,31 +328,33 @@ describe "絵文字が" do
319
328
  context 'upper iOS 5' do
320
329
  before(:each) do
321
330
  @res = Rack::MockRequest.env_for(
322
- "/",
323
- 'HTTP_USER_AGENT' => "Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A334 Safari/7534.48.3",
324
- 'Content-Type' => 'text/html; charset=utf-8')
331
+ '/',
332
+ 'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A334 Safari/7534.48.3',
333
+ 'Content-Type' => 'text/html; charset=utf-8'
334
+ )
325
335
  @unicode_single = "\342\230\200"
326
336
  @unicode_multi = "\342\233\205"
327
337
  end
328
338
 
329
- it "should convert Unicode emoticon" do
339
+ it 'should convert Unicode emoticon' do
330
340
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@unicode_single))).call(@res)[2]
331
341
  expect(response_body(response)).to eq([0x2600].pack('U*'))
332
342
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@unicode_multi))).call(@res)[2]
333
343
  expect(response_body(response)).to eq([0x26C5].pack('U*'))
334
344
  end
335
345
 
336
- it "converts query parameters" do
337
- query_string = "q=" + URI.encode(@unicode_multi)
346
+ it 'converts query parameters' do
347
+ query_string = 'q=' + URI.encode(@unicode_multi)
338
348
 
339
349
  res = Rack::MockRequest.env_for(
340
350
  "/?#{query_string}",
341
- "REQUEST_METHOD" => "GET",
342
- 'HTTP_USER_AGENT' => "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; ja-jp) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A306 Safari/6531.22.7",
343
- 'Content-Type' => 'text/html; charset=utf-8')
351
+ 'REQUEST_METHOD' => 'GET',
352
+ 'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; ja-jp) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A306 Safari/6531.22.7',
353
+ 'Content-Type' => 'text/html; charset=utf-8'
354
+ )
344
355
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(Jpmobile::Filter.new(RenderParamApp.new))).call(res)
345
356
  req = Rack::Request.new(res[1])
346
- expect(req.params['q']).to eq([0x26C5].pack("U"))
357
+ expect(req.params['q']).to eq([0x26C5].pack('U'))
347
358
  expect(response_body(res)).to eq([0x26C5].pack('U'))
348
359
  end
349
360
 
@@ -363,30 +374,32 @@ describe "絵文字が" do
363
374
  context 'mobile' do
364
375
  before(:each) do
365
376
  @res = Rack::MockRequest.env_for(
366
- "/",
377
+ '/',
367
378
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Linux; U; Android 1.6; ja-jp; SonyEriccsonSO-01B Build/R1EA018) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1',
368
- 'Content-Type' => 'text/html; charset=utf-8')
379
+ 'Content-Type' => 'text/html; charset=utf-8'
380
+ )
369
381
  end
370
382
 
371
- it "should convert Google emoticon" do
383
+ it 'should convert Google emoticon' do
372
384
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_single))).call(@res)[2]
373
385
  expect(response_body(response)).to eq([0xFE000].pack('U*'))
374
386
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_multi))).call(@res)[2]
375
387
  expect(response_body(response)).to eq([0xFE00F].pack('U*'))
376
388
  end
377
389
 
378
- it "converts query parameters irreversibly" do
379
- query_string = "q=" + URI.encode(@google_multi)
390
+ it 'converts query parameters irreversibly' do
391
+ query_string = 'q=' + URI.encode(@google_multi)
380
392
 
381
393
  res = Rack::MockRequest.env_for(
382
394
  "/?#{query_string}",
383
- "REQUEST_METHOD" => "GET",
395
+ 'REQUEST_METHOD' => 'GET',
384
396
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Linux; U; Android 1.6; ja-jp; SonyEriccsonSO-01B Build/R1EA018) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1',
385
- 'Content-Type' => 'text/html; charset=utf-8')
397
+ 'Content-Type' => 'text/html; charset=utf-8'
398
+ )
386
399
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(Jpmobile::Filter.new(RenderParamApp.new))).call(res)
387
400
  req = Rack::Request.new(res[1])
388
- expect(req.params['q']).to eq([0xe63e, 0xe63f].pack("U*"))
389
- expect(response_body(res)).to eq([0xfe000, 0xfe001].pack("U*"))
401
+ expect(req.params['q']).to eq([0xe63e, 0xe63f].pack('U*'))
402
+ expect(response_body(res)).to eq([0xfe000, 0xfe001].pack('U*'))
390
403
  end
391
404
 
392
405
  it 'should not convert 〓' do
@@ -398,30 +411,32 @@ describe "絵文字が" do
398
411
  context 'tablet' do
399
412
  before(:each) do
400
413
  @res = Rack::MockRequest.env_for(
401
- "/",
414
+ '/',
402
415
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Linux; U; Android 2.2; ja-jp; SC-01C Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
403
- 'Content-Type' => 'text/html; charset=utf-8')
416
+ 'Content-Type' => 'text/html; charset=utf-8'
417
+ )
404
418
  end
405
419
 
406
- it "should convert Google emoticon" do
420
+ it 'should convert Google emoticon' do
407
421
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_single))).call(@res)[2]
408
422
  expect(response_body(response)).to eq([0xFE000].pack('U*'))
409
423
  response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_multi))).call(@res)[2]
410
424
  expect(response_body(response)).to eq([0xFE00F].pack('U*'))
411
425
  end
412
426
 
413
- it "converts query parameters irreversibly" do
414
- query_string = "q=" + URI.encode(@google_multi)
427
+ it 'converts query parameters irreversibly' do
428
+ query_string = 'q=' + URI.encode(@google_multi)
415
429
 
416
430
  res = Rack::MockRequest.env_for(
417
431
  "/?#{query_string}",
418
- "REQUEST_METHOD" => "GET",
432
+ 'REQUEST_METHOD' => 'GET',
419
433
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Linux; U; Android 2.2; ja-jp; SC-01C Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
420
- 'Content-Type' => 'text/html; charset=utf-8')
434
+ 'Content-Type' => 'text/html; charset=utf-8'
435
+ )
421
436
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(Jpmobile::Filter.new(RenderParamApp.new))).call(res)
422
437
  req = Rack::Request.new(res[1])
423
- expect(req.params['q']).to eq([0xe63e, 0xe63f].pack("U*"))
424
- expect(response_body(res)).to eq([0xfe000, 0xfe001].pack("U*"))
438
+ expect(req.params['q']).to eq([0xe63e, 0xe63f].pack('U*'))
439
+ expect(response_body(res)).to eq([0xfe000, 0xfe001].pack('U*'))
425
440
  end
426
441
 
427
442
  it 'should not convert 〓' do
@@ -430,13 +445,14 @@ describe "絵文字が" do
430
445
  end
431
446
 
432
447
  it 'should convert unsupported emoticon to "〓"' do
433
- query_string = "q=" + URI.encode("\xF3\xBE\x93\xA4")
448
+ query_string = 'q=' + URI.encode("\xF3\xBE\x93\xA4")
434
449
 
435
450
  res = Rack::MockRequest.env_for(
436
451
  "/?#{query_string}",
437
- "REQUEST_METHOD" => "GET",
452
+ 'REQUEST_METHOD' => 'GET',
438
453
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Linux; U; Android 2.2; ja-jp; SC-01C Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
439
- 'Content-Type' => 'text/html; charset=utf-8')
454
+ 'Content-Type' => 'text/html; charset=utf-8'
455
+ )
440
456
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(Jpmobile::Filter.new(RenderParamApp.new))).call(res)
441
457
  req = Rack::Request.new(res[1])
442
458
  expect(req.params['q']).to eq('〓')