jpmobile 1.0.0.pre.4 → 1.0.0.pre.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. data/.rspec +4 -0
  2. data/Gemfile +3 -3
  3. data/VERSION.yml +2 -2
  4. data/jpmobile.gemspec +335 -0
  5. data/lib/jpmobile.rb +0 -1
  6. data/lib/jpmobile/email.rb +47 -21
  7. data/lib/jpmobile/mail.rb +33 -26
  8. data/lib/jpmobile/mailer.rb +2 -0
  9. data/lib/jpmobile/util.rb +3 -3
  10. data/spec/unit/email-fixtures/au-attached.eml +1551 -0
  11. data/spec/unit/email-fixtures/au-decomail.eml +44 -0
  12. data/spec/unit/email-fixtures/au-emoji.eml +19 -0
  13. data/spec/unit/email-fixtures/au-emoji2.eml +45 -0
  14. data/spec/unit/email-fixtures/au-emoji5.eml +24 -0
  15. data/spec/unit/email-fixtures/docomo-emoji.eml +19 -0
  16. data/spec/unit/email-fixtures/docomo-gmail-sjis.eml +45 -0
  17. data/spec/unit/email-fixtures/docomo-jis.eml +20 -0
  18. data/spec/unit/email-fixtures/pc-mail-multi.eml +77 -0
  19. data/spec/unit/email-fixtures/pc-mail-single.eml +29 -0
  20. data/spec/unit/email-fixtures/softbank-blank.eml +20 -0
  21. data/spec/unit/email-fixtures/softbank-emoji-utf8.eml +19 -0
  22. data/spec/unit/email-fixtures/softbank-emoji.eml +19 -0
  23. data/spec/unit/email-fixtures/softbank-gmail-sjis.eml +45 -0
  24. data/spec/unit/email-fixtures/softbank-gmail-utf8.eml +45 -0
  25. data/spec/unit/{detect_by_email_spec.rb → email_spec.rb} +25 -2
  26. data/spec/unit/emoticon_spec.rb +1 -1
  27. data/spec/unit/encoding_spec.rb +1 -1
  28. data/spec/unit/is_carrier_spec.rb +1 -1
  29. data/spec/unit/mail_spec.rb +1 -1
  30. data/spec/unit/receive_mail_spec.rb +26 -1
  31. data/spec/unit/util_spec.rb +1 -1
  32. data/spec/unit/valid_ip_spec.rb +1 -1
  33. data/test/rails/.gitignore +1 -0
  34. data/test/rails/overrides/.rspec +5 -0
  35. data/test/rails/overrides/Gemfile +33 -0
  36. data/test/rails/overrides/app/views/filter/index.html.erb +0 -0
  37. data/test/rails/overrides/app/views/hankaku_filter/index.html.erb +0 -0
  38. data/test/rails/overrides/app/views/hankaku_input_filter/index.html.erb +0 -0
  39. data/test/rails/overrides/app/views/hankaku_input_filter/index_xhtml.html.erb +1 -0
  40. data/test/rails/overrides/app/views/layouts/xhtml.html.erb +12 -0
  41. data/test/rails/overrides/app/views/links/au_gps.html.erb +1 -0
  42. data/test/rails/overrides/app/views/links/au_location.html.erb +1 -0
  43. data/test/rails/overrides/app/views/links/docomo_foma_gps.html.erb +1 -0
  44. data/test/rails/overrides/app/views/links/docomo_openiarea.html.erb +1 -0
  45. data/test/rails/overrides/app/views/links/docomo_utn.html.erb +1 -0
  46. data/test/rails/overrides/app/views/links/link.html.erb +1 -0
  47. data/test/rails/overrides/app/views/links/show_all.html.erb +1 -0
  48. data/test/rails/overrides/app/views/links/softbank_location.html.erb +1 -0
  49. data/test/rails/overrides/app/views/links/willcom_location.html.erb +1 -0
  50. data/test/rails/overrides/app/views/mobile_mailer/multi_message.html.erb +11 -0
  51. data/test/rails/overrides/app/views/mobile_mailer/multi_message.text.erb +2 -0
  52. data/test/rails/overrides/app/views/mobile_mailer/view_selection.html.erb +3 -0
  53. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile.html.erb +3 -0
  54. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_au.html.erb +3 -0
  55. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_docomo.html.erb +3 -0
  56. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_emobile.html.erb +3 -0
  57. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_softbank.html.erb +3 -0
  58. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_vodafone.html.erb +3 -0
  59. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_willcom.html.erb +3 -0
  60. data/test/rails/overrides/app/views/normal_mailer/msg.text.erb +3 -0
  61. data/test/rails/overrides/app/views/template_path/_partial.html.erb +1 -0
  62. data/test/rails/overrides/app/views/template_path/_partial_mobile.html.erb +1 -0
  63. data/test/rails/overrides/app/views/template_path/_partial_mobile_docomo.html.erb +1 -0
  64. data/test/rails/overrides/app/views/template_path/_partial_smart_phone.html.erb +1 -0
  65. data/test/rails/overrides/app/views/template_path/_partial_smart_phone_iphone.html.erb +1 -0
  66. data/test/rails/overrides/app/views/template_path/index.html.erb +1 -0
  67. data/test/rails/overrides/app/views/template_path/index_mobile.html.erb +1 -0
  68. data/test/rails/overrides/app/views/template_path/index_mobile_docomo.html.erb +1 -0
  69. data/test/rails/overrides/app/views/template_path/index_smart_phone.html.erb +1 -0
  70. data/test/rails/overrides/app/views/template_path/index_smart_phone_iphone.html.erb +1 -0
  71. data/test/rails/overrides/app/views/template_path/partial.html.erb +2 -0
  72. data/test/rails/overrides/app/views/template_path/show_mobile.html.erb +1 -0
  73. data/test/rails/overrides/app/views/template_path/show_mobile_docomo.html.erb +1 -0
  74. data/test/rails/overrides/spec/fixtures/mobile_mailer/au-attached.eml +1551 -0
  75. data/test/rails/overrides/spec/fixtures/mobile_mailer/au-decomail.eml +44 -0
  76. data/test/rails/overrides/spec/fixtures/mobile_mailer/au-emoji.eml +19 -0
  77. data/test/rails/overrides/spec/fixtures/mobile_mailer/au-emoji2.eml +45 -0
  78. data/test/rails/overrides/spec/fixtures/mobile_mailer/au-emoji5.eml +24 -0
  79. data/test/rails/overrides/spec/fixtures/mobile_mailer/docomo-emoji.eml +19 -0
  80. data/test/rails/overrides/spec/fixtures/mobile_mailer/docomo-gmail-sjis.eml +45 -0
  81. data/test/rails/overrides/spec/fixtures/mobile_mailer/docomo-jis.eml +20 -0
  82. data/test/rails/overrides/spec/fixtures/mobile_mailer/no-from.eml +78 -0
  83. data/test/rails/overrides/spec/fixtures/mobile_mailer/non-jp.eml +45 -0
  84. data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-blank.eml +20 -0
  85. data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-emoji-utf8.eml +19 -0
  86. data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-emoji.eml +19 -0
  87. data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-sjis.eml +45 -0
  88. data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-utf8.eml +45 -0
  89. data/test/rails/overrides/spec/helpers/helpers_spec.rb +1 -2
  90. data/test/rails/overrides/spec/models/mobile_mailer_spec.rb +37 -1
  91. data/test/rails/overrides/spec/models/normal_mailer_spec.rb +1 -1
  92. data/test/rails/overrides/spec/rcov.opts +2 -0
  93. data/test/rails/overrides/spec/requests/docomo_guid_spec.rb +1 -2
  94. data/test/rails/overrides/spec/requests/docomo_spec.rb +1 -2
  95. data/test/rails/overrides/spec/requests/emobile_spec.rb +1 -2
  96. data/test/rails/overrides/spec/requests/filter_spec.rb +1 -1
  97. data/test/rails/overrides/spec/requests/helpers_spec.rb +1 -1
  98. data/test/rails/overrides/spec/requests/pc_spec.rb +1 -2
  99. data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +1 -2
  100. data/test/rails/overrides/spec/requests/template_path_spec.rb +1 -2
  101. data/test/rails/overrides/spec/requests/trans_sid_spec.rb +1 -2
  102. data/test/rails/overrides/spec/spec_helper.rb +1 -1
  103. metadata +229 -386
  104. data/test/rails/rails_root/app/controllers/application_controller.rb +0 -6
  105. data/test/rails/rails_root/app/controllers/docomo_guid_always_controller.rb +0 -3
  106. data/test/rails/rails_root/app/controllers/docomo_guid_base_controller.rb +0 -5
  107. data/test/rails/rails_root/app/controllers/docomo_guid_docomo_controller.rb +0 -3
  108. data/test/rails/rails_root/app/controllers/filter_controller.rb +0 -3
  109. data/test/rails/rails_root/app/controllers/filter_controller_base.rb +0 -25
  110. data/test/rails/rails_root/app/controllers/hankaku_filter_controller.rb +0 -3
  111. data/test/rails/rails_root/app/controllers/hankaku_input_filter_controller.rb +0 -7
  112. data/test/rails/rails_root/app/controllers/links_controller.rb +0 -28
  113. data/test/rails/rails_root/app/controllers/mobile_spec_controller.rb +0 -5
  114. data/test/rails/rails_root/app/controllers/template_path_controller.rb +0 -17
  115. data/test/rails/rails_root/app/controllers/trans_sid_always_and_session_off_controller.rb +0 -4
  116. data/test/rails/rails_root/app/controllers/trans_sid_always_controller.rb +0 -3
  117. data/test/rails/rails_root/app/controllers/trans_sid_base_controller.rb +0 -40
  118. data/test/rails/rails_root/app/controllers/trans_sid_metal_controller.rb +0 -15
  119. data/test/rails/rails_root/app/controllers/trans_sid_mobile_controller.rb +0 -3
  120. data/test/rails/rails_root/app/controllers/trans_sid_none_controller.rb +0 -3
  121. data/test/rails/rails_root/app/helpers/application_helper.rb +0 -2
  122. data/test/rails/rails_root/app/models/mobile_mailer.rb +0 -19
  123. data/test/rails/rails_root/app/models/normal_mailer.rb +0 -9
  124. data/test/rails/rails_root/app/models/user.rb +0 -2
  125. data/test/rails/rails_root/autotest/discover.rb +0 -2
  126. data/test/rails/rails_root/config/application.rb +0 -42
  127. data/test/rails/rails_root/config/boot.rb +0 -6
  128. data/test/rails/rails_root/config/environment.rb +0 -5
  129. data/test/rails/rails_root/config/environments/development.rb +0 -26
  130. data/test/rails/rails_root/config/environments/production.rb +0 -49
  131. data/test/rails/rails_root/config/environments/test.rb +0 -35
  132. data/test/rails/rails_root/config/initializers/backtrace_silencers.rb +0 -7
  133. data/test/rails/rails_root/config/initializers/inflections.rb +0 -10
  134. data/test/rails/rails_root/config/initializers/jpmobile_generator.rb +0 -2
  135. data/test/rails/rails_root/config/initializers/mime_types.rb +0 -5
  136. data/test/rails/rails_root/config/initializers/secret_token.rb +0 -7
  137. data/test/rails/rails_root/config/initializers/session_store.rb +0 -2
  138. data/test/rails/rails_root/config/routes.rb +0 -7
  139. data/test/rails/rails_root/db/migrate/001_add_sessions_table.rb +0 -16
  140. data/test/rails/rails_root/db/migrate/20100824062306_create_users.rb +0 -13
  141. data/test/rails/rails_root/db/schema.rb +0 -31
  142. data/test/rails/rails_root/db/seeds.rb +0 -7
  143. data/test/rails/rails_root/spec/helpers/helpers_spec.rb +0 -15
  144. data/test/rails/rails_root/spec/models/mobile_mailer_spec.rb +0 -737
  145. data/test/rails/rails_root/spec/models/normal_mailer_spec.rb +0 -34
  146. data/test/rails/rails_root/spec/requests/docomo_guid_spec.rb +0 -102
  147. data/test/rails/rails_root/spec/requests/docomo_spec.rb +0 -33
  148. data/test/rails/rails_root/spec/requests/emobile_spec.rb +0 -53
  149. data/test/rails/rails_root/spec/requests/filter_spec.rb +0 -221
  150. data/test/rails/rails_root/spec/requests/helpers_spec.rb +0 -187
  151. data/test/rails/rails_root/spec/requests/pc_spec.rb +0 -22
  152. data/test/rails/rails_root/spec/requests/softbank_emulator_spec.rb +0 -21
  153. data/test/rails/rails_root/spec/requests/template_path_spec.rb +0 -240
  154. data/test/rails/rails_root/spec/requests/trans_sid_spec.rb +0 -207
  155. data/test/rails/rails_root/spec/spec_helper.rb +0 -38
  156. data/test/rails/rails_root/test/performance/browsing_test.rb +0 -9
  157. data/test/rails/rails_root/test/test_helper.rb +0 -13
  158. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile-ipaddresses.rb +0 -18
  159. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/abstract_ip_addresses.rb +0 -23
  160. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/au.rb +0 -40
  161. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/docomo.rb +0 -22
  162. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/emobile.rb +0 -15
  163. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/softbank.rb +0 -20
  164. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/willcom.rb +0 -158
  165. data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/lib/jpmobile-terminfo.rb +0 -9
  166. data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/lib/jpmobile/mobile/terminfo.rb +0 -62
  167. data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/lib/jpmobile/mobile/terminfo/docomo.rb +0 -739
  168. data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/spec/spec_helper.rb +0 -2
  169. data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/spec/terminfo_spec.rb +0 -54
  170. data/test/rails/rails_root/vendor/plugins/jpmobile/init.rb +0 -3
  171. data/test/rails/rails_root/vendor/plugins/jpmobile/install.rb +0 -1
  172. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile.rb +0 -59
  173. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/datum_conv.rb +0 -72
  174. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/docomo_guid.rb +0 -43
  175. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/email.rb +0 -33
  176. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb +0 -205
  177. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/au.rb +0 -1931
  178. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/conversion_table.rb +0 -3909
  179. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/docomo.rb +0 -255
  180. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/softbank.rb +0 -965
  181. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/z_combine.rb +0 -36
  182. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/encoding.rb +0 -29
  183. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/filter.rb +0 -113
  184. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/helpers.rb +0 -174
  185. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_controller.rb +0 -18
  186. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_dispatch.rb +0 -2
  187. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_view.rb +0 -33
  188. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/lookup_context.rb +0 -2
  189. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mail.rb +0 -330
  190. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mailer.rb +0 -41
  191. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +0 -168
  192. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/android.rb +0 -10
  193. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/au.rb +0 -128
  194. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/ddipocket.rb +0 -12
  195. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/docomo.rb +0 -149
  196. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/emobile.rb +0 -16
  197. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/iphone.rb +0 -26
  198. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/smart_phone.rb +0 -21
  199. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/softbank.rb +0 -91
  200. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/vodafone.rb +0 -17
  201. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/willcom.rb +0 -28
  202. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/windows_phone.rb +0 -10
  203. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/path_set.rb +0 -40
  204. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/position.rb +0 -68
  205. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack.rb +0 -49
  206. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/filter.rb +0 -50
  207. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/mobile_carrier.rb +0 -33
  208. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/params_filter.rb +0 -47
  209. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb +0 -50
  210. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/request_with_mobile.rb +0 -45
  211. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/resolver.rb +0 -38
  212. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/trans_sid.rb +0 -133
  213. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +0 -370
  214. data/test/rails/rails_root/vendor/plugins/jpmobile/tmp/conversion-table.rb +0 -2588
  215. data/test/rails/rails_root/vendor/plugins/jpmobile/tmp/utf8_to_image.rb +0 -1407
  216. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/emoji/genregexp.rb +0 -47
  217. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_au_emoticon_table.rb +0 -34
  218. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_docomo_emoticon_table.rb +0 -33
  219. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_emoticon_conversion_table.rb +0 -107
  220. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_softbank_emoticon_table.rb +0 -31
  221. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/list_gps_unsupported_au.rb +0 -23
  222. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses.rb +0 -18
  223. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/abstract_ip_addresses.rb +0 -23
  224. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/au.rb +0 -40
  225. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/docomo.rb +0 -22
  226. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/emobile.rb +0 -15
  227. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/softbank.rb +0 -20
  228. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/willcom.rb +0 -158
  229. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/lib/jpmobile-terminfo.rb +0 -9
  230. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/lib/jpmobile/mobile/terminfo.rb +0 -62
  231. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/lib/jpmobile/mobile/terminfo/docomo.rb +0 -739
  232. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/spec/spec_helper.rb +0 -2
  233. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/spec/terminfo_spec.rb +0 -54
@@ -1,187 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require File.dirname(__FILE__) + '/../spec_helper'
3
- require 'nokogiri'
4
-
5
- describe Jpmobile::Helpers do
6
- # 文字列 +str+ 中に含まれるリンクについて、
7
- # リンクテキスト、属性のHash、URLのqueryをのぞいた部分、ueryをHashにしたもの
8
- # の3要素からなる配列の配列で返す。
9
- def get_href_and_texts(str)
10
- results = []
11
- (Nokogiri::HTML.parse(str)/"a").each do |link|
12
- path, query = link["href"].split(/\?/, 2)
13
- params = query.nil? ? nil : Rack::Utils.parse_query(query)
14
- results << [link.inner_html, link.attributes, path, params]
15
- end
16
- return results
17
- end
18
-
19
- it "get_position_link_to_がエラー無く終わるか" do
20
- lambda {
21
- get "/links/show_all", {}, {"HTTP_USER_AGENT" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"}
22
- }.should_not raise_error
23
- end
24
-
25
- context "docomo で" do
26
- it "get_position_link_to が正常に表示されること" do
27
- get "/links/link", {}, { "HTTP_USER_AGENT" => "DoCoMo/2.0 SH903i(c100;TB;W24H16)"}
28
- links = get_href_and_texts(body)
29
-
30
- links.size.should == 1
31
- text, attrs, path, params = links.first
32
- text.should == "STRING"
33
- path.should == "http://www.example.com/links/link"
34
- body.should =~ /lcs>/
35
- end
36
-
37
- it "docomo_utn_link_to が正しく出力されること" do
38
- get "/links/docomo_utn", {}, {"HTTP_USER_AGENT" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"}
39
- links = get_href_and_texts(body)
40
-
41
- links.size.should == 1
42
- text, attrs, path, params = links.first
43
- text.should == "STRING"
44
- path.should == "http://www.example.com/links/docomo_utn"
45
- body.should =~ /utn>/
46
- end
47
-
48
- it "オープンiエリア取得用のリンクが正しく出力されること" do
49
- get "/links/docomo_openiarea", {}, {"HTTP_USER_AGENT" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"}
50
- links = get_href_and_texts(body)
51
-
52
- links.size.should == 1
53
- text, attrs, path, params = links.first
54
- text.should == "STRING"
55
- path.should == "http://w1m.docomo.ne.jp/cp/iarea"
56
- params["ecode"].should == "OPENAREACODE"
57
- params["msn"].should == "OPENAREAKEY"
58
- params["posinfo"].should == "1"
59
- params["nl"].should == "http://www.example.com/links/docomo_openiarea"
60
- end
61
-
62
- it "GPS取得用のリンクが正しく出力されること" do
63
- get "/links/docomo_foma_gps", {}, {"HTTP_USER_AGENT" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"}
64
- links = get_href_and_texts(body)
65
-
66
- links.size.should == 1
67
- text, attrs, path, params = links.first
68
- text.should == "STRING"
69
- path.should == "http://www.example.com/links/docomo_foma_gps"
70
- body.should =~ /lcs>/
71
- end
72
- end
73
-
74
- context "au で" do
75
- # get_position_link_to(自動判別), au, location only
76
- def test_get_position_link_to_au_location_only
77
- get "/links/link", {}, {"HTTP_USER_AGENT" => "KDDI-SN26 UP.Browser/6.2.0.6.2 (GUI) MMP/2.0"}
78
- links = get_href_and_texts(body)
79
- assert_equal(1, links.size)
80
- text, attrs, path, params = links.first
81
- assert_equal("STRING", text)
82
- assert_equal("device:location", path)
83
- assert_equal("http://www.example.com/links/link", params["url"])
84
- end
85
-
86
- # get_position_link_to(自動判別), au, gps
87
- def test_get_position_link_to_au_gps
88
- get "/links/link", {}, {"HTTP_USER_AGENT" => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"}
89
- links = get_href_and_texts(body)
90
- assert_equal(1, links.size)
91
- text, attrs, path, params = links.first
92
- assert_equal("STRING", text)
93
- assert_equal("device:gpsone", path)
94
- assert_equal("http://www.example.com/links/link", params["url"])
95
- assert_equal("0", params["number"])
96
- assert_equal("0", params["acry"])
97
- assert_equal("1", params["ver"])
98
- assert_equal("0", params["unit"])
99
- assert_equal("0", params["datum"])
100
- end
101
-
102
- # au簡易位置情報取得用のリンクが正しく出力されるか。
103
- def test_au_location_link_to
104
- get "/links/au_location", {}, {"HTTP_USER_AGENT" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"}
105
- links = get_href_and_texts(body)
106
- assert_equal(1, links.size)
107
- text, attrs, path, params = links.first
108
- assert_equal("STRING", text)
109
- assert_equal("device:location", path)
110
- assert_equal("http://www.example.com/links/au_location", params["url"])
111
- end
112
-
113
- # au GPS位置情報取得用のリンクが正しく出力されるか。
114
- def test_au_gps_link_to
115
- get "/links/au_gps", {}, {"HTTP_USER_AGENT" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"}
116
- links = get_href_and_texts(body)
117
- assert_equal(1, links.size)
118
- text, attrs, path, params = links.first
119
- assert_equal("STRING", text)
120
- assert_equal("device:gpsone", path)
121
- assert_equal("http://www.example.com/links/au_gps", params["url"])
122
- assert_equal("0", params["number"])
123
- assert_equal("0", params["acry"])
124
- assert_equal("1", params["ver"])
125
- assert_equal("0", params["unit"])
126
- assert_equal("0", params["datum"])
127
- end
128
- end
129
-
130
- context "softbank で" do
131
- # get_position_link_to(自動判別), Vodafone
132
- def test_get_position_link_to_vodafone
133
- get "/links/link", {}, {"HTTP_USER_AGENT" => "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0"}
134
- links = get_href_and_texts(body)
135
- assert_equal(1, links.size)
136
- text, attrs, path, params = links.first
137
- assert_equal("STRING", text)
138
- assert_equal("location:auto", path)
139
- end
140
-
141
- # get_position_link_to(自動判別), Softbank
142
- def test_get_position_link_to_softbank
143
- get "/links/link", {}, {"HTTP_USER_AGENT" => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"}
144
- links = get_href_and_texts(body)
145
- assert_equal(1, links.size)
146
- text, attrs, path, params = links.first
147
- assert_equal("STRING", text)
148
- assert_equal("location:auto", path)
149
- end
150
-
151
- # Softbank 3G 位置情報取得用のリンクが正しく出力されるか。
152
- def test_softbank_location_link_to
153
- get "/links/softbank_location", {}, {"HTTP_USER_AGENT" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"}
154
- links = get_href_and_texts(body)
155
- assert_equal(1, links.size)
156
- text, attrs, path, params = links.first
157
- assert_equal("STRING", text)
158
- assert_equal("location:auto", path)
159
- end
160
- end
161
-
162
- context "willcom で" do
163
- # get_position_link_to(自動判別), Willcom
164
- def test_get_position_link_to_willcom
165
- get "/links/link", {}, {"HTTP_USER_AGENT" => "Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0"}
166
- links = get_href_and_texts(body)
167
- assert_equal(1, links.size)
168
- text, attrs, path, params = links.first
169
- assert_equal("STRING", text)
170
- assert_equal("http://location.request/dummy.cgi", path)
171
- assert_equal("http://www.example.com/links/link", params["my"])
172
- assert_equal("$location", params["pos"])
173
- end
174
-
175
- # Willcom 位置情報取得用のリンクが正しく出力されるか。
176
- def test_willcom_location_link_to
177
- get "/links/willcom_location", {}, {"HTTP_USER_AGENT" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"}
178
- links = get_href_and_texts(body)
179
- assert_equal(1, links.size)
180
- text, attrs, path, params = links.first
181
- assert_equal("STRING", text)
182
- assert_equal("http://location.request/dummy.cgi", path)
183
- assert_equal("http://www.example.com/links/willcom_location", params["my"])
184
- assert_equal("$location", params["pos"])
185
- end
186
- end
187
- end
@@ -1,22 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require File.dirname(__FILE__) + '/../spec_helper'
4
-
5
- describe "PCからのアクセスの場合" do
6
- before do
7
- @headers = {
8
- "HTTP_USER_AGENT" => "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)",
9
- }
10
- end
11
-
12
- it "request.mobile は nil であるべき" do
13
- get "/mobile_spec/index", {}, @headers
14
-
15
- request.mobile.should be_nil
16
- end
17
- it "request.mobile? は false であるべき" do
18
- get "/mobile_spec/index", {}, @headers
19
-
20
- request.mobile?.should be_false
21
- end
22
- end
@@ -1,21 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require File.dirname(__FILE__) + '/../spec_helper'
4
-
5
- describe "Softbank Emulator からのアクセスのとき" do
6
- it "request.mobile は Softbank のインスタンスであること" do
7
- get "/mobile_spec/index", {}, {"HTTP_USER_AGENT" => "Semulator"}
8
-
9
- request.mobile.should be_an_instance_of(Jpmobile::Mobile::Softbank)
10
- request.mobile?.should be_true
11
- end
12
- end
13
-
14
- describe "Vodafone Emulator からのアクセスのとき" do
15
- it "request.mobile は Vodafone のインスタンスであること" do
16
- get "/mobile_spec/index", {}, {"HTTP_USER_AGENT" => "Vemulator"}
17
-
18
- request.mobile.should be_an_instance_of(Jpmobile::Mobile::Vodafone)
19
- request.mobile?.should be_true
20
- end
21
- end
@@ -1,240 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require File.dirname(__FILE__) + '/../spec_helper'
4
-
5
- #
6
- # 携帯からのアクセス
7
- #
8
- describe TemplatePathController, "DoCoMo SH902i からのアクセス" do
9
- before do
10
- @user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
11
- end
12
-
13
- it 'テンプレートの探索順が正しいこと' do
14
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
15
-
16
- controller.lookup_context.mobile.should == [ 'mobile_docomo', 'mobile' ]
17
- end
18
- end
19
-
20
- describe TemplatePathController, "au CA32 からのアクセス" do
21
- before do
22
- @user_agent = "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
23
- end
24
- it 'テンプレートの探索順が正しいこと' do
25
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
26
-
27
- controller.lookup_context.mobile.should == [ 'mobile_au', 'mobile' ]
28
- end
29
- end
30
-
31
- describe TemplatePathController, "Vodafone V903T からのアクセス" do
32
- before do
33
- @user_agent = "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0"
34
- end
35
- it 'テンプレートの探索順が正しいこと' do
36
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
37
-
38
- controller.lookup_context.mobile.should == [ 'mobile_vodafone', 'mobile_softbank', 'mobile' ]
39
- end
40
- end
41
-
42
- describe TemplatePathController, "SoftBank 910T からのアクセス" do
43
- before do
44
- @user_agent = "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
45
- end
46
- it 'テンプレートの探索順が正しいこと' do
47
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
48
-
49
- controller.lookup_context.mobile.should == [ 'mobile_softbank', 'mobile' ]
50
- end
51
- end
52
-
53
- describe TemplatePathController, "iPhone からのアクセス" do
54
- before do
55
- @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'
56
- end
57
- it 'テンプレートの探索順が正しいこと' do
58
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
59
-
60
- controller.lookup_context.mobile.should == [ 'smart_phone_iphone', 'smart_phone' ]
61
- end
62
- end
63
-
64
- describe TemplatePathController, "Android からのアクセス" do
65
- before do
66
- @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'
67
- end
68
- it 'テンプレートの探索順が正しいこと' do
69
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
70
-
71
- controller.lookup_context.mobile.should == [ 'smart_phone_android', 'smart_phone' ]
72
- end
73
- end
74
-
75
- describe TemplatePathController, "Windows Phone からのアクセス" do
76
- before do
77
- @user_agent = 'Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1 T-01A_6.5; Windows Phone 6.5)'
78
- end
79
- it 'テンプレートの探索順が正しいこと' do
80
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
81
-
82
- controller.lookup_context.mobile.should == [ 'smart_phone_windows_phone', 'smart_phone' ]
83
- end
84
- end
85
-
86
- describe TemplatePathController, "integrated_views" do
87
- describe "index" do
88
- context "PCからのアクセスの場合" do
89
- before do
90
- @user_agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)"
91
- end
92
- it 'index.html.erbが使用されること' do
93
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
94
-
95
- response.should have_tag("h1", :content => "index.html.erb")
96
- end
97
- end
98
-
99
- context "DoCoMoからのアクセスの場合" do
100
- before do
101
- @user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
102
- end
103
- it 'index_mobile_docomo.html.erbが使用されること' do
104
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
105
-
106
- response.should have_tag("h1", :content => "index_mobile_docomo.html.erb")
107
- end
108
-
109
- it 'show.html.erb がなくとも show_mobile_docomo.html.erbが使用されること' do
110
- get "/template_path/show", {}, { "HTTP_USER_AGENT" => @user_agent}
111
-
112
- response.should have_tag("h1", :content => "show_mobile_docomo.html.erb")
113
- end
114
-
115
- it 'disable_mobile_view! のときには index.html.erb が使用されること' do
116
- get "/template_path/index", {:pc => true}, { "HTTP_USER_AGENT" => @user_agent}
117
-
118
- response.should have_tag("h1", :content => "index.html.erb")
119
- end
120
- end
121
-
122
- context "SoftBankからのアクセスの場合" do
123
- before do
124
- @user_agent = "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
125
- end
126
- it 'index_mobile.html.erbが使用されること' do
127
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
128
-
129
- response.should have_tag("h1", :content => "index_mobile.html.erb")
130
- end
131
-
132
- it 'show.html.erb がなくとも show_mobile.html.erbが使用されること' do
133
- get "/template_path/show", {}, { "HTTP_USER_AGENT" => @user_agent}
134
-
135
- response.should have_tag("h1", :content => "show_mobile.html.erb")
136
- end
137
- end
138
-
139
- context "iPhoneからのアクセスの場合" do
140
- before do
141
- @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'
142
- end
143
- it 'smart_phone_iphone.html.erbが使用されること' do
144
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
145
-
146
- response.should have_tag("h1", :content => "smart_phone_iphone.html.erb")
147
- end
148
- end
149
-
150
- context "Androidからのアクセスの場合" do
151
- before do
152
- @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'
153
- end
154
- it 'smart_phone.html.erbが使用されること' do
155
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
156
-
157
- response.should have_tag("h1", :content => "smart_phone.html.erb")
158
- end
159
- end
160
-
161
- context "Windows Phoneからのアクセスの場合" do
162
- before do
163
- @user_agent = 'Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1 T-01A_6.5; Windows Phone 6.5)'
164
- end
165
- it 'smart_phone.html.erbが使用されること' do
166
- get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
167
-
168
- response.should have_tag("h1", :content => "smart_phone.html.erb")
169
- end
170
- end
171
- end
172
-
173
- context "partial" do
174
- context "PCからのアクセスの場合" do
175
- before do
176
- @user_agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)"
177
- end
178
- it '_partial.html.erbが使用されること' do
179
- get "/template_path/partial", {}, { "HTTP_USER_AGENT" => @user_agent}
180
-
181
- response.should have_tag("h2", :content => "_partial.html.erb")
182
- end
183
- end
184
-
185
- context "DoCoMoからのアクセスの場合" do
186
- before do
187
- @user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
188
- end
189
- it '_partial_mobile_docomo.html.erbが使用されること' do
190
- get "/template_path/partial", {}, { "HTTP_USER_AGENT" => @user_agent}
191
-
192
- response.should have_tag("h2", :content => "_partial_mobile_docomo.html.erb")
193
- end
194
- end
195
-
196
- context "SoftBankからのアクセスの場合" do
197
- before do
198
- @user_agent = "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
199
- end
200
- it '_partial_mobile.html.erbが使用されること' do
201
- get "/template_path/partial", {}, { "HTTP_USER_AGENT" => @user_agent}
202
-
203
- response.should have_tag("h2", :content => "_partial_mobile.html.erb")
204
- end
205
- end
206
-
207
- context "iPhoneからのアクセスの場合" do
208
- before do
209
- @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'
210
- end
211
- it '_partial_smart_phone_iphone.html.erbが使用されること' do
212
- get "/template_path/partial", {}, { "HTTP_USER_AGENT" => @user_agent}
213
-
214
- response.should have_tag("h2", :content => "_partial_smart_phone_iphone.html.erb")
215
- end
216
- end
217
-
218
- context "Androidからのアクセスの場合" do
219
- before do
220
- @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'
221
- end
222
- it '_partial_smart_phone.html.erbが使用されること' do
223
- get "/template_path/partial", {}, { "HTTP_USER_AGENT" => @user_agent}
224
-
225
- response.should have_tag("h2", :content => "_partial_smart_phone.html.erb")
226
- end
227
- end
228
-
229
- context "Windows Phoneからのアクセスの場合" do
230
- before do
231
- @user_agent = 'Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1 T-01A_6.5; Windows Phone 6.5)'
232
- end
233
- it '_partial_smart_phone.html.erbが使用されること' do
234
- get "/template_path/partial", {}, { "HTTP_USER_AGENT" => @user_agent}
235
-
236
- response.should have_tag("h2", :content => "_partial_smart_phone.html.erb")
237
- end
238
- end
239
- end
240
- end