jpmobile 0.0.8 → 0.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/.gitignore +0 -3
  2. data/{spec/spec.opts → .rspec} +1 -2
  3. data/README.rdoc +122 -128
  4. data/Rakefile +23 -101
  5. data/VERSION.yml +4 -3
  6. data/jpmobile.gemspec +130 -182
  7. data/lib/jpmobile.rb +37 -24
  8. data/lib/jpmobile/docomo_guid.rb +2 -1
  9. data/lib/jpmobile/email.rb +3 -4
  10. data/lib/jpmobile/emoticon.rb +2 -6
  11. data/lib/jpmobile/encoding.rb +29 -0
  12. data/lib/jpmobile/filter.rb +42 -134
  13. data/lib/jpmobile/helpers.rb +5 -18
  14. data/lib/jpmobile/hook_action_controller.rb +24 -16
  15. data/lib/jpmobile/hook_action_view.rb +28 -89
  16. data/lib/jpmobile/mobile/abstract_mobile.rb +21 -4
  17. data/lib/jpmobile/mobile/android.rb +10 -0
  18. data/lib/jpmobile/mobile/au.rb +28 -3
  19. data/lib/jpmobile/mobile/ddipocket.rb +12 -0
  20. data/lib/jpmobile/mobile/display.rb +29 -26
  21. data/lib/jpmobile/mobile/docomo.rb +38 -12
  22. data/lib/jpmobile/mobile/iphone.rb +26 -0
  23. data/lib/jpmobile/mobile/smart_phone.rb +21 -0
  24. data/lib/jpmobile/mobile/softbank.rb +16 -41
  25. data/lib/jpmobile/mobile/vodafone.rb +17 -0
  26. data/lib/jpmobile/mobile/willcom.rb +1 -10
  27. data/lib/jpmobile/mobile/windows_phone.rb +10 -0
  28. data/lib/jpmobile/position.rb +4 -3
  29. data/lib/jpmobile/rack.rb +43 -0
  30. data/lib/jpmobile/rack/filter.rb +51 -0
  31. data/lib/jpmobile/rack/mobile_carrier.rb +33 -0
  32. data/lib/jpmobile/rack/params_filter.rb +47 -0
  33. data/lib/jpmobile/rails.rb +22 -0
  34. data/lib/jpmobile/request_with_mobile.rb +8 -12
  35. data/lib/jpmobile/trans_sid.rb +44 -26
  36. data/lib/jpmobile/util.rb +68 -0
  37. data/{tasks → lib/tasks}/jpmobile_tasks.rake +32 -13
  38. data/spec/rack/jpmobile/android_spec.rb +20 -0
  39. data/spec/rack/jpmobile/au_spec.rb +206 -0
  40. data/spec/rack/jpmobile/docomo_spec.rb +237 -0
  41. data/spec/rack/jpmobile/emoticon_spec.rb +215 -0
  42. data/spec/rack/jpmobile/filter_spec.rb +181 -0
  43. data/spec/rack/jpmobile/iphone_spec.rb +32 -0
  44. data/spec/rack/jpmobile/mobile_by_ua_spec.rb +39 -0
  45. data/spec/rack/jpmobile/params_filter_spec.rb +193 -0
  46. data/spec/rack/jpmobile/softbank_spec.rb +123 -0
  47. data/spec/rack/jpmobile/willcom_spec.rb +67 -0
  48. data/spec/rack/jpmobile/windows_phone.rb +20 -0
  49. data/spec/rack_helper.rb +86 -0
  50. data/spec/spec_helper.rb +3 -2
  51. data/spec/unit/detect_by_email_spec.rb +21 -27
  52. data/spec/unit/is_carrier_spec.rb +56 -84
  53. data/spec/unit/spec_helper.rb +1 -2
  54. data/spec/unit/util_spec.rb +2 -2
  55. data/spec/unit/valid_ip_spec.rb +43 -52
  56. data/test/legacy/autoload_test.rb +1 -3
  57. data/test/legacy/emoticon_test.rb +5 -6
  58. data/test/legacy/helper.rb +0 -71
  59. data/test/rails/overrides/.rspec +5 -0
  60. data/test/rails/overrides/Gemfile +32 -0
  61. data/test/rails/overrides/app/controllers/docomo_guid_always_controller.rb +3 -0
  62. data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +5 -0
  63. data/test/rails/overrides/app/controllers/docomo_guid_docomo_controller.rb +3 -0
  64. data/test/rails/overrides/app/controllers/filter_controller.rb +0 -34
  65. data/test/rails/overrides/app/controllers/filter_controller_base.rb +19 -0
  66. data/test/rails/overrides/app/controllers/hankaku_filter_controller.rb +3 -0
  67. data/test/rails/overrides/app/controllers/links_controller.rb +28 -0
  68. data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
  69. data/test/rails/overrides/app/controllers/template_path_controller.rb +3 -0
  70. data/test/rails/overrides/app/controllers/trans_sid_always_and_session_off_controller.rb +4 -0
  71. data/test/rails/overrides/app/controllers/trans_sid_always_controller.rb +3 -0
  72. data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -0
  73. data/test/rails/overrides/app/controllers/trans_sid_mobile_controller.rb +3 -0
  74. data/test/rails/overrides/app/controllers/trans_sid_none_controller.rb +3 -0
  75. data/test/rails/overrides/app/views/links/au_gps.html.erb +1 -0
  76. data/test/rails/overrides/app/views/links/au_location.html.erb +1 -0
  77. data/test/rails/overrides/app/views/links/docomo_foma_gps.html.erb +1 -0
  78. data/test/rails/overrides/app/views/links/docomo_openiarea.html.erb +1 -0
  79. data/test/rails/overrides/app/views/links/docomo_utn.html.erb +1 -0
  80. data/test/rails/overrides/app/views/links/link.html.erb +1 -0
  81. data/test/rails/overrides/app/views/links/show_all.html.erb +1 -0
  82. data/test/rails/overrides/app/views/links/softbank_location.html.erb +1 -0
  83. data/test/rails/overrides/app/views/links/willcom_location.html.erb +1 -0
  84. data/test/rails/overrides/app/views/template_path/_partial_smart_phone.html.erb +1 -0
  85. data/test/rails/overrides/app/views/template_path/_partial_smart_phone_iphone.html.erb +1 -0
  86. data/test/rails/overrides/app/views/template_path/index_smart_phone.html.erb +1 -0
  87. data/test/rails/overrides/app/views/template_path/index_smart_phone_iphone.html.erb +1 -0
  88. data/test/rails/overrides/app/views/template_path/show_mobile.html.erb +1 -0
  89. data/test/rails/overrides/app/views/template_path/show_mobile_docomo.html.erb +1 -0
  90. data/test/rails/overrides/autotest/discover.rb +2 -0
  91. data/test/rails/overrides/config/initializers/jpmobile_generator.rb +1 -0
  92. data/test/rails/overrides/config/routes.rb +58 -0
  93. data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +16 -0
  94. data/test/rails/overrides/spec/helpers/helpers_spec.rb +2 -2
  95. data/test/rails/overrides/spec/{controllers → requests}/docomo_guid_spec.rb +37 -14
  96. data/test/rails/overrides/spec/{controllers → requests}/docomo_spec.rb +11 -8
  97. data/test/rails/overrides/spec/{controllers → requests}/emobile_spec.rb +24 -8
  98. data/test/rails/overrides/spec/requests/filter_spec.rb +171 -0
  99. data/test/rails/overrides/spec/requests/helpers_spec.rb +187 -0
  100. data/test/rails/overrides/spec/requests/pc_spec.rb +22 -0
  101. data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +21 -0
  102. data/test/rails/overrides/spec/requests/template_path_spec.rb +234 -0
  103. data/test/rails/overrides/spec/requests/trans_sid_spec.rb +142 -0
  104. data/test/rails/overrides/spec/spec_helper.rb +17 -48
  105. data/test/sinatra/guestbook.rb +40 -0
  106. data/test/sinatra/test/filter_test.rb +39 -0
  107. metadata +185 -312
  108. data/lib/jpmobile/hook_request.rb +0 -5
  109. data/lib/jpmobile/rack/auth.rb +0 -55
  110. data/lib/jpmobile/rack/combined_logger.rb +0 -54
  111. data/lib/jpmobile/rack/request.rb +0 -7
  112. data/lib/jpmobile/rack/trans_sid.rb +0 -14
  113. data/lib/jpmobile/version.rb +0 -9
  114. data/spec/unit/detect_by_ua_spec.rb +0 -40
  115. data/test/legacy/au_test.rb +0 -173
  116. data/test/legacy/docomo_test.rb +0 -187
  117. data/test/legacy/emoticon_functional_test.rb +0 -195
  118. data/test/legacy/filter_test.rb +0 -34
  119. data/test/legacy/helpers_test.rb +0 -217
  120. data/test/legacy/softbank_test.rb +0 -183
  121. data/test/legacy/willcom_test.rb +0 -56
  122. data/test/rails/2.3.2/spec/controllers/trans_sid_spec.rb +0 -99
  123. data/test/rails/overrides/app/controllers/docomo_guid_controller.rb +0 -13
  124. data/test/rails/overrides/app/controllers/trans_sid_controller.rb +0 -28
  125. data/test/rails/overrides/lib/tasks/rspec.rake +0 -165
  126. data/test/rails/overrides/spec/controllers/filter_spec.rb +0 -159
  127. data/test/rails/overrides/spec/controllers/pc_spec.rb +0 -13
  128. data/test/rails/overrides/spec/controllers/softbank_emulator_spec.rb +0 -42
  129. data/test/rails/overrides/spec/controllers/template_path_spec.rb +0 -117
  130. data/test/rails/overrides/spec/controllers/trans_sid_spec.rb +0 -117
  131. data/test/rails/overrides/spec/rspec.rake +0 -165
  132. data/test/rails/overrides/spec/spec.opts +0 -4
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
- unless Spec.const_defined?(:Rails)
1
+ # -*- coding: utf-8 -*-
2
+ unless RSpec.const_defined?(:Rails)
2
3
  dir = File.dirname(__FILE__)
3
4
 
4
5
  # jpmobileの読み込み
@@ -32,5 +33,5 @@ unless Spec.const_defined?(:Rails)
32
33
  map.connect ':controller/:action/:id'
33
34
  end
34
35
 
35
- require 'spec/rails'
36
+ require 'rspec/rails'
36
37
  end
@@ -1,31 +1,25 @@
1
- require File.join(File.dirname(__FILE__), 'spec_helper')
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
2
 
3
3
  describe 'Jpmobile::Email' do
4
-
5
- Spec::Fixture::Base.new self, :email_addr => :carrier do
6
-
7
- it '#detect should return :carrier when take :email_addr as EmailAddr' do |email_addr, carrier|
8
- Jpmobile::Email.detect(email_addr).should == carrier
4
+ [
5
+ ['example@example.ne.jp' , nil ],
6
+ ['test@docomo.ne.jp' , Jpmobile::Mobile::Docomo ],
7
+ ['test@docomo.ne.jp.jp' , nil ],
8
+ ['a(--)l@ezweb.ne.jp' , Jpmobile::Mobile::Au ],
9
+ ['a(--)l@ezweb.ne.jp.jp' , nil ],
10
+ ['dadaea@pdx.ne.jp' , Jpmobile::Mobile::Willcom ],
11
+ ['dadaea@pdx.ne.jp.jp' , nil ],
12
+ ['xxxe@dj.pdx.ne.jp' , Jpmobile::Mobile::Willcom ],
13
+ ['xxxe@dj.pdx.ne.jp.jp' , nil ],
14
+ ['oeeikx@softbank.ne.jp' , Jpmobile::Mobile::Softbank ],
15
+ ['oeeikx@softbank.ne.jp.jp' , nil ],
16
+ ['eaae@disney.ne.jp' , Jpmobile::Mobile::Softbank ],
17
+ ['eaae@disney.ne.jp.jp' , nil ],
18
+ ['iiiaa@r.vodafone.ne.jp' , Jpmobile::Mobile::Vodafone ],
19
+ ['iiiaa@r.vodafone.ne.jp.jp' , nil ],
20
+ ].each do |email_addr, carrier|
21
+ it "#detect should return #{carrier} when take #{email_addr} as EmailAddr" do
22
+ Jpmobile::Email.detect(email_addr).should == carrier
9
23
  end
10
-
11
- set_fixtures([
12
- ['example@example.ne.jp' => nil ],
13
- ['test@docomo.ne.jp' => Jpmobile::Mobile::Docomo ],
14
- ['test@docomo.ne.jp.jp' => nil ],
15
- ['a(--)l@ezweb.ne.jp' => Jpmobile::Mobile::Au ],
16
- ['a(--)l@ezweb.ne.jp.jp' => nil ],
17
- ['dadaea@pdx.ne.jp' => Jpmobile::Mobile::Willcom ],
18
- ['dadaea@pdx.ne.jp.jp' => nil ],
19
- ['xxxe@dj.pdx.ne.jp' => Jpmobile::Mobile::Willcom ],
20
- ['xxxe@dj.pdx.ne.jp.jp' => nil ],
21
- ['oeeikx@softbank.ne.jp' => Jpmobile::Mobile::Softbank ],
22
- ['oeeikx@softbank.ne.jp.jp' => nil ],
23
- ['eaae@disney.ne.jp' => Jpmobile::Mobile::Softbank ],
24
- ['eaae@disney.ne.jp.jp' => nil ],
25
- ['iiiaa@r.vodafone.ne.jp' => Jpmobile::Mobile::Vodafone ],
26
- ['iiiaa@r.vodafone.ne.jp.jp' => nil ],
27
- ['aaaaa.aaaa@jp-h.ne.jp' => Jpmobile::Mobile::Jphone ],
28
- ['aaaaa.aaaa@jp-h.ne.jp.jp' => nil ],
29
- ])
30
- end.run
24
+ end
31
25
  end
@@ -1,93 +1,65 @@
1
- require File.join(File.dirname(__FILE__), 'spec_helper')
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
2
 
3
3
  describe 'Jpmobile::Mobile' do
4
- Spec::Fixture::Base.new self, [ :klass, :carrier ] => :expected do
5
- filters({
6
- :klass => proc {|val| Jpmobile::Mobile.const_get(val) },
7
- :carrier => proc {|val| "#{val}?" },
8
- })
4
+ [
5
+ [ %w[ Docomo docomo ] , true ],
6
+ [ %w[ Docomo au ] , false ],
7
+ [ %w[ Docomo softbank ] , false ],
8
+ [ %w[ Docomo vodafone ] , false ],
9
+ [ %w[ Docomo emobile ] , false ],
10
+ [ %w[ Docomo willcom ] , false ],
11
+ [ %w[ Docomo ddipocket ] , false ],
9
12
 
10
- desc_filters({
11
- :klass => proc {|val| "::#{val.to_s}" },
12
- :carrier => proc {|val| "#{val}?" },
13
- })
13
+ [ %w[ Au docomo ] , false ],
14
+ [ %w[ Au au ] , true ],
15
+ [ %w[ Au softbank ] , false ],
16
+ [ %w[ Au vodafone ] , false ],
17
+ [ %w[ Au emobile ] , false ],
18
+ [ %w[ Au willcom ] , false ],
19
+ [ %w[ Au ddipocket ] , false ],
14
20
 
15
- it ":klass#:carrier should be return :expected" do |input, expected|
16
- input[:klass].new({}).__send__(input[:carrier]).should == expected
17
- end
18
-
19
- set_fixtures([
20
- [ %w[ Docomo docomo ] => true ],
21
- [ %w[ Docomo au ] => false ],
22
- [ %w[ Docomo softbank ] => false ],
23
- [ %w[ Docomo vodafone ] => false ],
24
- [ %w[ Docomo jphone ] => false ],
25
- [ %w[ Docomo emobile ] => false ],
26
- [ %w[ Docomo willcom ] => false ],
27
- [ %w[ Docomo ddipocket ] => false ],
28
-
29
- [ %w[ Au docomo ] => false ],
30
- [ %w[ Au au ] => true ],
31
- [ %w[ Au softbank ] => false ],
32
- [ %w[ Au vodafone ] => false ],
33
- [ %w[ Au jphone ] => false ],
34
- [ %w[ Au emobile ] => false ],
35
- [ %w[ Au willcom ] => false ],
36
- [ %w[ Au ddipocket ] => false ],
21
+ [ %w[ Softbank docomo ] , false ],
22
+ [ %w[ Softbank au ] , false ],
23
+ [ %w[ Softbank softbank ] , true ],
24
+ [ %w[ Softbank vodafone ] , false ],
25
+ [ %w[ Softbank emobile ] , false ],
26
+ [ %w[ Softbank willcom ] , false ],
27
+ [ %w[ Softbank ddipocket ] , false ],
37
28
 
38
- [ %w[ Softbank docomo ] => false ],
39
- [ %w[ Softbank au ] => false ],
40
- [ %w[ Softbank softbank ] => true ],
41
- [ %w[ Softbank vodafone ] => false ],
42
- [ %w[ Softbank jphone ] => false ],
43
- [ %w[ Softbank emobile ] => false ],
44
- [ %w[ Softbank willcom ] => false ],
45
- [ %w[ Softbank ddipocket ] => false ],
29
+ [ %w[ Vodafone docomo ] , false ],
30
+ [ %w[ Vodafone au ] , false ],
31
+ [ %w[ Vodafone softbank ] , true ],
32
+ [ %w[ Vodafone vodafone ] , true ],
33
+ [ %w[ Vodafone emobile ] , false ],
34
+ [ %w[ Vodafone willcom ] , false ],
35
+ [ %w[ Vodafone ddipocket ] , false ],
46
36
 
47
- [ %w[ Vodafone docomo ] => false ],
48
- [ %w[ Vodafone au ] => false ],
49
- [ %w[ Vodafone softbank ] => true ],
50
- [ %w[ Vodafone vodafone ] => true ],
51
- [ %w[ Vodafone jphone ] => false ],
52
- [ %w[ Vodafone emobile ] => false ],
53
- [ %w[ Vodafone willcom ] => false ],
54
- [ %w[ Vodafone ddipocket ] => false ],
37
+ [ %w[ Emobile docomo ] , false ],
38
+ [ %w[ Emobile au ] , false ],
39
+ [ %w[ Emobile softbank ] , false ],
40
+ [ %w[ Emobile vodafone ] , false ],
41
+ [ %w[ Emobile emobile ] , true ],
42
+ [ %w[ Emobile willcom ] , false ],
43
+ [ %w[ Emobile ddipocket ] , false ],
55
44
 
56
- [ %w[ Jphone docomo ] => false ],
57
- [ %w[ Jphone au ] => false ],
58
- [ %w[ Jphone softbank ] => true ],
59
- [ %w[ Jphone vodafone ] => true ],
60
- [ %w[ Jphone jphone ] => true ],
61
- [ %w[ Jphone emobile ] => false ],
62
- [ %w[ Jphone willcom ] => false ],
63
- [ %w[ Jphone ddipocket ] => false ],
45
+ [ %w[ Willcom docomo ] , false ],
46
+ [ %w[ Willcom au ] , false ],
47
+ [ %w[ Willcom softbank ] , false ],
48
+ [ %w[ Willcom vodafone ] , false ],
49
+ [ %w[ Willcom emobile ] , false ],
50
+ [ %w[ Willcom willcom ] , true ],
51
+ [ %w[ Willcom ddipocket ] , false ],
64
52
 
65
- [ %w[ Emobile docomo ] => false ],
66
- [ %w[ Emobile au ] => false ],
67
- [ %w[ Emobile softbank ] => false ],
68
- [ %w[ Emobile vodafone ] => false ],
69
- [ %w[ Emobile jphone ] => false ],
70
- [ %w[ Emobile emobile ] => true ],
71
- [ %w[ Emobile willcom ] => false ],
72
- [ %w[ Emobile ddipocket ] => false ],
73
-
74
- [ %w[ Willcom docomo ] => false ],
75
- [ %w[ Willcom au ] => false ],
76
- [ %w[ Willcom softbank ] => false ],
77
- [ %w[ Willcom vodafone ] => false ],
78
- [ %w[ Willcom jphone ] => false ],
79
- [ %w[ Willcom emobile ] => false ],
80
- [ %w[ Willcom willcom ] => true ],
81
- [ %w[ Willcom ddipocket ] => false ],
82
-
83
- [ %w[ Ddipocket docomo ] => false ],
84
- [ %w[ Ddipocket au ] => false ],
85
- [ %w[ Ddipocket softbank ] => false ],
86
- [ %w[ Ddipocket vodafone ] => false ],
87
- [ %w[ Ddipocket jphone ] => false ],
88
- [ %w[ Ddipocket emobile ] => false ],
89
- [ %w[ Ddipocket willcom ] => true ],
90
- [ %w[ Ddipocket ddipocket ] => true ],
91
- ])
92
- end.run
53
+ [ %w[ Ddipocket docomo ] , false ],
54
+ [ %w[ Ddipocket au ] , false ],
55
+ [ %w[ Ddipocket softbank ] , false ],
56
+ [ %w[ Ddipocket vodafone ] , false ],
57
+ [ %w[ Ddipocket emobile ] , false ],
58
+ [ %w[ Ddipocket willcom ] , true ],
59
+ [ %w[ Ddipocket ddipocket ] , true ],
60
+ ].each do |carrier, expected|
61
+ it "#{carrier.first}##{carrier.last}? should be return #{expected}" do
62
+ Jpmobile::Mobile.const_get(carrier.first).new({}, {}).__send__("#{carrier.last}?").should == expected
63
+ end
64
+ end
93
65
  end
@@ -1,5 +1,4 @@
1
1
  require 'rubygems'
2
- require 'spec'
3
- require 'spec/fixture' # gem rspec-fixture
2
+ require 'rspec'
4
3
  $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib')))
5
4
  require 'jpmobile'
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
-
3
- require File.join(File.dirname(__FILE__), 'spec_helper')
2
+ require 'stringio'
3
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
4
4
 
5
5
  describe Jpmobile::Util, ".deep_apply" do
6
6
  it 'nilのときはnilを返すこと' do
@@ -1,60 +1,51 @@
1
- require File.join(File.dirname(__FILE__), 'spec_helper')
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
2
 
3
3
  describe 'Jpmobile::Mobile::valid_ip?' do
4
- Spec::Fixture::Base.new self, :remote_ip => :carrier do
5
- it 'should be return true if :remote_ip is in :carrier address' do |remote_ip, carrier|
4
+ [
5
+ [ '210.153.84.1' , :Docomo ],
6
+ [ '210.153.84.254' , :Docomo ],
7
+ [ '210.230.128.225' , :Au ],
8
+ [ '210.230.128.238' , :Au ],
9
+ [ '123.108.236.1' , :Softbank ],
10
+ [ '123.108.236.254' , :Softbank ],
11
+ [ '123.108.236.1' , :Vodafone ],
12
+ [ '123.108.236.254' , :Vodafone ],
13
+ [ '61.198.142.1' , :Willcom ],
14
+ [ '61.198.142.254' , :Willcom ],
15
+ [ '61.198.142.1' , :Ddipocket ],
16
+ [ '61.198.142.254' , :Ddipocket ],
17
+ [ '117.55.1.224' , :Emobile ],
18
+ [ '117.55.1.254' , :Emobile ],
19
+ ].each do |remote_ip, carrier|
20
+ it "should be return true if #{remote_ip} is in #{:carrier} address" do
6
21
  Jpmobile::Mobile.const_get(carrier).valid_ip?(remote_ip).should == true
7
22
  end
23
+ end
8
24
 
9
- set_fixtures([
10
- [ '210.153.84.1' => :Docomo ],
11
- [ '210.153.84.254' => :Docomo ],
12
- [ '210.230.128.225' => :Au ],
13
- [ '210.230.128.238' => :Au ],
14
- [ '123.108.236.1' => :Softbank ],
15
- [ '123.108.236.254' => :Softbank ],
16
- [ '123.108.236.1' => :Vodafone ],
17
- [ '123.108.236.254' => :Vodafone ],
18
- [ '123.108.236.1' => :Jphone ],
19
- [ '123.108.236.254' => :Jphone ],
20
- [ '61.198.142.1' => :Willcom ],
21
- [ '61.198.142.254' => :Willcom ],
22
- [ '61.198.142.1' => :Ddipocket ],
23
- [ '61.198.142.254' => :Ddipocket ],
24
- [ '117.55.1.224' => :Emobile ],
25
- [ '117.55.1.254' => :Emobile ],
26
- ])
27
- end.run
28
-
29
- Spec::Fixture::Base.new self, :remote_ip => :carrier do
30
- it 'should not be return true if :remote_ip is in :carrier address' do |remote_ip, carrier|
25
+ [
26
+ [ '127.0.0.1' , :Docomo ],
27
+ [ '210.153.83.1' , :Docomo ],
28
+ [ '210.153.83.254' , :Docomo ],
29
+ [ '127.0.0.1' , :Au ],
30
+ [ '210.169.41.1' , :Au ],
31
+ [ '210.169.41.254' , :Au ],
32
+ [ '127.0.0.1' , :Softbank ],
33
+ [ '123.108.238.1' , :Softbank ],
34
+ [ '123.108.238.254' , :Softbank ],
35
+ [ '127.0.0.1' , :Vodafone ],
36
+ [ '123.108.238.1' , :Vodafone ],
37
+ [ '123.108.238.254' , :Vodafone ],
38
+ [ '127.0.0.1' , :Willcom ],
39
+ [ '61.198.144.1' , :Willcom ],
40
+ [ '61.198.144.254' , :Willcom ],
41
+ [ '127.0.0.1' , :Ddipocket ],
42
+ [ '61.198.144.1' , :Ddipocket ],
43
+ [ '61.198.144.254' , :Ddipocket ],
44
+ [ '127.0.0.1' , :Emobile ],
45
+ [ '117.55.1.223' , :Emobile ],
46
+ ].each do |remote_ip, carrier|
47
+ it 'should not be return true if #{:remote_ip} is in #{carrier} address' do
31
48
  Jpmobile::Mobile.const_get(carrier).valid_ip?(remote_ip).should_not == true
32
49
  end
33
-
34
- set_fixtures([
35
- [ '127.0.0.1' => :Docomo ],
36
- [ '210.153.83.1' => :Docomo ],
37
- [ '210.153.83.254' => :Docomo ],
38
- [ '127.0.0.1' => :Au ],
39
- [ '210.169.41.1' => :Au ],
40
- [ '210.169.41.254' => :Au ],
41
- [ '127.0.0.1' => :Softbank ],
42
- [ '123.108.238.1' => :Softbank ],
43
- [ '123.108.238.254' => :Softbank ],
44
- [ '127.0.0.1' => :Vodafone ],
45
- [ '123.108.238.1' => :Vodafone ],
46
- [ '123.108.238.254' => :Vodafone ],
47
- [ '127.0.0.1' => :Jphone ],
48
- [ '123.108.238.1' => :Jphone ],
49
- [ '123.108.238.254' => :Jphone ],
50
- [ '127.0.0.1' => :Willcom ],
51
- [ '61.198.144.1' => :Willcom ],
52
- [ '61.198.144.254' => :Willcom ],
53
- [ '127.0.0.1' => :Ddipocket ],
54
- [ '61.198.144.1' => :Ddipocket ],
55
- [ '61.198.144.254' => :Ddipocket ],
56
- [ '127.0.0.1' => :Emobile ],
57
- [ '117.55.1.223' => :Emobile ],
58
- ])
59
- end.run
50
+ end
60
51
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__)+'/helper'
1
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
2
2
 
3
3
  module Jpmobile
4
4
  module Mobile
@@ -29,10 +29,8 @@ class TestAutoLoad < Test::Unit::TestCase
29
29
  require 'jpmobile/mobile/softbank'
30
30
  assert_nothing_raised { Jpmobile::Mobile::Softbank::IP_ADDRESSES }
31
31
  assert_nothing_raised { Jpmobile::Mobile::Vodafone::IP_ADDRESSES }
32
- assert_nothing_raised { Jpmobile::Mobile::Jphone::IP_ADDRESSES }
33
32
  assert_kind_of(Array, Jpmobile::Mobile::Softbank::IP_ADDRESSES)
34
33
  assert_kind_of(Array, Jpmobile::Mobile::Vodafone::IP_ADDRESSES)
35
- assert_kind_of(Array, Jpmobile::Mobile::Jphone::IP_ADDRESSES)
36
34
  end
37
35
 
38
36
  def test_ip_addresses_willcom
@@ -1,4 +1,6 @@
1
- require File.dirname(__FILE__)+'/helper'
1
+ require File.expand_path(File.dirname(__FILE__)) + '/helper'
2
+
3
+ include Jpmobile::Util
2
4
 
3
5
  class DocomoEmoticonTest < Test::Unit::TestCase
4
6
  def test_external_unicodecr_docomo
@@ -34,9 +36,6 @@ class AuEmoticonTest < Test::Unit::TestCase
34
36
  end
35
37
 
36
38
  class SoftbankEmoticonTest < Test::Unit::TestCase
37
- def test_jphone_webcode_cr
38
- assert_equal "&#xf001;&#xf001;", Jpmobile::Emoticon::external_to_unicodecr_jphone("\x1b$G!!\x0f")
39
- end
40
39
  def test_softbank_cr
41
40
  assert_equal "&#xf001;", Jpmobile::Emoticon::external_to_unicodecr_softbank([0xe001].pack('U'))
42
41
  end
@@ -44,7 +43,7 @@ class SoftbankEmoticonTest < Test::Unit::TestCase
44
43
  assert_equal "&#xf001;", Jpmobile::Emoticon::external_to_unicodecr_softbank([0xe001].pack('U'))
45
44
  end
46
45
  def test_softbank_cr_webcode
47
- assert_equal "\x1b$G!\x0f", Jpmobile::Emoticon::unicodecr_to_external("&#xf001;")
46
+ assert_equal [0xe001].pack('U'), Jpmobile::Emoticon::unicodecr_to_external("&#xf001;")
48
47
  end
49
48
  def test_softbank_cr_utf8
50
49
  assert_equal utf8("\xef\x80\x81"), Jpmobile::Emoticon::unicodecr_to_utf8("&#xf001;")
@@ -53,7 +52,7 @@ class SoftbankEmoticonTest < Test::Unit::TestCase
53
52
  assert_equal "&#xf001;", Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\xef\x80\x81"))
54
53
  end
55
54
  def test_unicodecr_external_softbank_for_string
56
- assert_equal "\x1b$Gj\x0f\x1b$Gi\x0f", Jpmobile::Emoticon::unicodecr_to_external("&#xE48E;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, true)
55
+ assert_equal [0xe04a, 0xe049].pack('U*'), Jpmobile::Emoticon::unicodecr_to_external("&#xE48E;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, true)
57
56
  end
58
57
  end
59
58
 
@@ -1,79 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
-
3
2
  require 'rubygems'
4
3
  begin
5
4
  gem 'test-unit', '= 1.2.3'
6
5
  rescue Gem::LoadError
7
6
  end
8
7
  require 'test/unit'
9
- action_pack_version = ENV['RAILS_VERSION'] || '2.3.0'
10
- gem 'actionpack', "~> #{action_pack_version}"
11
- require 'action_controller'
12
- require 'rack'
13
-
14
- RAILS_ENV = "test"
15
8
  require File.dirname(__FILE__)+'/../../lib/jpmobile'
16
-
17
- # ActionPackのTestのためのrequire
18
- action_pack_gem = Gem.cache.find_name('actionpack').find do |gem|
19
- gem.version.version >= action_pack_version
20
- end
21
- require File.join(action_pack_gem.full_gem_path,'test/abstract_unit')
22
-
23
- class FakeCgi < CGI
24
- attr_accessor :stdinput, :stdoutput, :env_table
25
- def initialize(user_agent, env={})
26
- self.env_table = {"HTTP_USER_AGENT"=>user_agent,"QUERY_STRING"=>""}.update(env)
27
- super()
28
- end
29
- end
30
-
31
- def request_with_ua(user_agent, env={})
32
- fake_cgi = FakeCgi.new(user_agent, env)
33
- [
34
- Rack::Request.new(
35
- Rack::MockRequest.env_for('http://www.example.jp', fake_cgi.env_table)
36
- ).extend(Jpmobile::RequestWithMobile)
37
- ]
38
- end
39
-
40
- ## add helper methods to rails testing framework
41
- module ActionController
42
- class TestRequest < Request
43
- attr_accessor :user_agent
44
- end
45
- end
46
-
47
- module Jpmobile::TestHelper
48
- def user_agent(str)
49
- @request.user_agent = str
50
- end
51
- def init(c)
52
- @controller = c.new
53
- @controller.logger = Logger.new(nil)
54
- @request = ActionController::TestRequest.new
55
- @response = ActionController::TestResponse.new
56
- @request.host = "www.example.jp"
57
- @request.session.session_id = "mysessionid"
58
- end
59
- def sjis(ascii_8bit)
60
- if ascii_8bit.respond_to?(:force_encoding)
61
- ascii_8bit.force_encoding("Shift_JIS")
62
- end
63
- ascii_8bit
64
- end
65
- def utf8(ascii_8bit)
66
- if ascii_8bit.respond_to?(:force_encoding)
67
- ascii_8bit.force_encoding("utf-8")
68
- end
69
- ascii_8bit
70
- end
71
- def to_sjis(utf8)
72
- if utf8.respond_to?(:encode)
73
- utf8.encode("Shift_JIS")
74
- else
75
- utf8.tosjis
76
- end
77
- end
78
- end
79
- Test::Unit::TestCase.class_eval{ include Jpmobile::TestHelper }