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.
- data/.gitignore +0 -3
- data/{spec/spec.opts → .rspec} +1 -2
- data/README.rdoc +122 -128
- data/Rakefile +23 -101
- data/VERSION.yml +4 -3
- data/jpmobile.gemspec +130 -182
- data/lib/jpmobile.rb +37 -24
- data/lib/jpmobile/docomo_guid.rb +2 -1
- data/lib/jpmobile/email.rb +3 -4
- data/lib/jpmobile/emoticon.rb +2 -6
- data/lib/jpmobile/encoding.rb +29 -0
- data/lib/jpmobile/filter.rb +42 -134
- data/lib/jpmobile/helpers.rb +5 -18
- data/lib/jpmobile/hook_action_controller.rb +24 -16
- data/lib/jpmobile/hook_action_view.rb +28 -89
- data/lib/jpmobile/mobile/abstract_mobile.rb +21 -4
- data/lib/jpmobile/mobile/android.rb +10 -0
- data/lib/jpmobile/mobile/au.rb +28 -3
- data/lib/jpmobile/mobile/ddipocket.rb +12 -0
- data/lib/jpmobile/mobile/display.rb +29 -26
- data/lib/jpmobile/mobile/docomo.rb +38 -12
- data/lib/jpmobile/mobile/iphone.rb +26 -0
- data/lib/jpmobile/mobile/smart_phone.rb +21 -0
- data/lib/jpmobile/mobile/softbank.rb +16 -41
- data/lib/jpmobile/mobile/vodafone.rb +17 -0
- data/lib/jpmobile/mobile/willcom.rb +1 -10
- data/lib/jpmobile/mobile/windows_phone.rb +10 -0
- data/lib/jpmobile/position.rb +4 -3
- data/lib/jpmobile/rack.rb +43 -0
- data/lib/jpmobile/rack/filter.rb +51 -0
- data/lib/jpmobile/rack/mobile_carrier.rb +33 -0
- data/lib/jpmobile/rack/params_filter.rb +47 -0
- data/lib/jpmobile/rails.rb +22 -0
- data/lib/jpmobile/request_with_mobile.rb +8 -12
- data/lib/jpmobile/trans_sid.rb +44 -26
- data/lib/jpmobile/util.rb +68 -0
- data/{tasks → lib/tasks}/jpmobile_tasks.rake +32 -13
- data/spec/rack/jpmobile/android_spec.rb +20 -0
- data/spec/rack/jpmobile/au_spec.rb +206 -0
- data/spec/rack/jpmobile/docomo_spec.rb +237 -0
- data/spec/rack/jpmobile/emoticon_spec.rb +215 -0
- data/spec/rack/jpmobile/filter_spec.rb +181 -0
- data/spec/rack/jpmobile/iphone_spec.rb +32 -0
- data/spec/rack/jpmobile/mobile_by_ua_spec.rb +39 -0
- data/spec/rack/jpmobile/params_filter_spec.rb +193 -0
- data/spec/rack/jpmobile/softbank_spec.rb +123 -0
- data/spec/rack/jpmobile/willcom_spec.rb +67 -0
- data/spec/rack/jpmobile/windows_phone.rb +20 -0
- data/spec/rack_helper.rb +86 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/unit/detect_by_email_spec.rb +21 -27
- data/spec/unit/is_carrier_spec.rb +56 -84
- data/spec/unit/spec_helper.rb +1 -2
- data/spec/unit/util_spec.rb +2 -2
- data/spec/unit/valid_ip_spec.rb +43 -52
- data/test/legacy/autoload_test.rb +1 -3
- data/test/legacy/emoticon_test.rb +5 -6
- data/test/legacy/helper.rb +0 -71
- data/test/rails/overrides/.rspec +5 -0
- data/test/rails/overrides/Gemfile +32 -0
- data/test/rails/overrides/app/controllers/docomo_guid_always_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +5 -0
- data/test/rails/overrides/app/controllers/docomo_guid_docomo_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/filter_controller.rb +0 -34
- data/test/rails/overrides/app/controllers/filter_controller_base.rb +19 -0
- data/test/rails/overrides/app/controllers/hankaku_filter_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/links_controller.rb +28 -0
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/template_path_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/trans_sid_always_and_session_off_controller.rb +4 -0
- data/test/rails/overrides/app/controllers/trans_sid_always_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -0
- data/test/rails/overrides/app/controllers/trans_sid_mobile_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/trans_sid_none_controller.rb +3 -0
- data/test/rails/overrides/app/views/links/au_gps.html.erb +1 -0
- data/test/rails/overrides/app/views/links/au_location.html.erb +1 -0
- data/test/rails/overrides/app/views/links/docomo_foma_gps.html.erb +1 -0
- data/test/rails/overrides/app/views/links/docomo_openiarea.html.erb +1 -0
- data/test/rails/overrides/app/views/links/docomo_utn.html.erb +1 -0
- data/test/rails/overrides/app/views/links/link.html.erb +1 -0
- data/test/rails/overrides/app/views/links/show_all.html.erb +1 -0
- data/test/rails/overrides/app/views/links/softbank_location.html.erb +1 -0
- data/test/rails/overrides/app/views/links/willcom_location.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_smart_phone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_smart_phone_iphone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_smart_phone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_smart_phone_iphone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/show_mobile.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/show_mobile_docomo.html.erb +1 -0
- data/test/rails/overrides/autotest/discover.rb +2 -0
- data/test/rails/overrides/config/initializers/jpmobile_generator.rb +1 -0
- data/test/rails/overrides/config/routes.rb +58 -0
- data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +16 -0
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +2 -2
- data/test/rails/overrides/spec/{controllers → requests}/docomo_guid_spec.rb +37 -14
- data/test/rails/overrides/spec/{controllers → requests}/docomo_spec.rb +11 -8
- data/test/rails/overrides/spec/{controllers → requests}/emobile_spec.rb +24 -8
- data/test/rails/overrides/spec/requests/filter_spec.rb +171 -0
- data/test/rails/overrides/spec/requests/helpers_spec.rb +187 -0
- data/test/rails/overrides/spec/requests/pc_spec.rb +22 -0
- data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +21 -0
- data/test/rails/overrides/spec/requests/template_path_spec.rb +234 -0
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +142 -0
- data/test/rails/overrides/spec/spec_helper.rb +17 -48
- data/test/sinatra/guestbook.rb +40 -0
- data/test/sinatra/test/filter_test.rb +39 -0
- metadata +185 -312
- data/lib/jpmobile/hook_request.rb +0 -5
- data/lib/jpmobile/rack/auth.rb +0 -55
- data/lib/jpmobile/rack/combined_logger.rb +0 -54
- data/lib/jpmobile/rack/request.rb +0 -7
- data/lib/jpmobile/rack/trans_sid.rb +0 -14
- data/lib/jpmobile/version.rb +0 -9
- data/spec/unit/detect_by_ua_spec.rb +0 -40
- data/test/legacy/au_test.rb +0 -173
- data/test/legacy/docomo_test.rb +0 -187
- data/test/legacy/emoticon_functional_test.rb +0 -195
- data/test/legacy/filter_test.rb +0 -34
- data/test/legacy/helpers_test.rb +0 -217
- data/test/legacy/softbank_test.rb +0 -183
- data/test/legacy/willcom_test.rb +0 -56
- data/test/rails/2.3.2/spec/controllers/trans_sid_spec.rb +0 -99
- data/test/rails/overrides/app/controllers/docomo_guid_controller.rb +0 -13
- data/test/rails/overrides/app/controllers/trans_sid_controller.rb +0 -28
- data/test/rails/overrides/lib/tasks/rspec.rake +0 -165
- data/test/rails/overrides/spec/controllers/filter_spec.rb +0 -159
- data/test/rails/overrides/spec/controllers/pc_spec.rb +0 -13
- data/test/rails/overrides/spec/controllers/softbank_emulator_spec.rb +0 -42
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +0 -117
- data/test/rails/overrides/spec/controllers/trans_sid_spec.rb +0 -117
- data/test/rails/overrides/spec/rspec.rake +0 -165
- data/test/rails/overrides/spec/spec.opts +0 -4
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
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 '
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
data/spec/unit/spec_helper.rb
CHANGED
data/spec/unit/util_spec.rb
CHANGED
data/spec/unit/valid_ip_spec.rb
CHANGED
@@ -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
|
-
|
5
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
]
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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 "", Jpmobile::Emoticon::external_to_unicodecr_jphone("\x1b$G!!\x0f")
|
39
|
-
end
|
40
39
|
def test_softbank_cr
|
41
40
|
assert_equal "", 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 "", Jpmobile::Emoticon::external_to_unicodecr_softbank([0xe001].pack('U'))
|
45
44
|
end
|
46
45
|
def test_softbank_cr_webcode
|
47
|
-
assert_equal
|
46
|
+
assert_equal [0xe001].pack('U'), Jpmobile::Emoticon::unicodecr_to_external("")
|
48
47
|
end
|
49
48
|
def test_softbank_cr_utf8
|
50
49
|
assert_equal utf8("\xef\x80\x81"), Jpmobile::Emoticon::unicodecr_to_utf8("")
|
@@ -53,7 +52,7 @@ class SoftbankEmoticonTest < Test::Unit::TestCase
|
|
53
52
|
assert_equal "", Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\xef\x80\x81"))
|
54
53
|
end
|
55
54
|
def test_unicodecr_external_softbank_for_string
|
56
|
-
assert_equal
|
55
|
+
assert_equal [0xe04a, 0xe049].pack('U*'), Jpmobile::Emoticon::unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, true)
|
57
56
|
end
|
58
57
|
end
|
59
58
|
|
data/test/legacy/helper.rb
CHANGED
@@ -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 }
|