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
@@ -1,13 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
-
|
5
|
-
describe "PCからのアクセスの場合", :behaviour_type=>:controller do
|
6
|
-
controller_name :mobile_spec
|
7
|
-
it "request.mobile は nil であるべき" do
|
8
|
-
request.mobile.should be_nil
|
9
|
-
end
|
10
|
-
it "request.mobile? は false であるべき" do
|
11
|
-
request.mobile?.should be_false
|
12
|
-
end
|
13
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
-
|
5
|
-
describe "携帯電話からのアクセス", :shared => true do
|
6
|
-
it "request.mobile? は true であること" do
|
7
|
-
request.mobile?.should be_true
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "Softbank Emulator からのアクセスのとき", :behaviour_type=>:controller do
|
12
|
-
before do
|
13
|
-
request.user_agent = "Semulator"
|
14
|
-
end
|
15
|
-
controller_name :mobile_spec
|
16
|
-
it "request.mobile は Softbank のインスタンスであること" do
|
17
|
-
request.mobile.should be_an_instance_of(Jpmobile::Mobile::Softbank)
|
18
|
-
end
|
19
|
-
it_should_behave_like "携帯電話からのアクセス"
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "Vodafone Emulator からのアクセスのとき", :behaviour_type=>:controller do
|
23
|
-
before do
|
24
|
-
request.user_agent = "Vemulator"
|
25
|
-
end
|
26
|
-
controller_name :mobile_spec
|
27
|
-
it "request.mobile は Vodafone のインスタンスであること" do
|
28
|
-
request.mobile.should be_an_instance_of(Jpmobile::Mobile::Vodafone)
|
29
|
-
end
|
30
|
-
it_should_behave_like "携帯電話からのアクセス"
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "J-PHONE Emulator からのアクセスのとき", :behaviour_type=>:controller do
|
34
|
-
before do
|
35
|
-
request.user_agent = "J-EMULATOR"
|
36
|
-
end
|
37
|
-
controller_name :mobile_spec
|
38
|
-
it "request.mobile は Jphone のインスタンスであること" do
|
39
|
-
request.mobile.should be_an_instance_of(Jpmobile::Mobile::Jphone)
|
40
|
-
end
|
41
|
-
it_should_behave_like "携帯電話からのアクセス"
|
42
|
-
end
|
@@ -1,117 +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
|
-
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
11
|
-
get :index
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'テンプレートの探索順が正しいこと' do
|
15
|
-
response.template.mobile_template_candidates.should == [ 'mobile_docomo', 'mobile' ]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe TemplatePathController, "au CA32 からのアクセス" do
|
20
|
-
before do
|
21
|
-
request.user_agent = "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
|
22
|
-
get :index
|
23
|
-
end
|
24
|
-
it 'テンプレートの探索順が正しいこと' do
|
25
|
-
response.template.mobile_template_candidates.should == [ 'mobile_au', 'mobile' ]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe TemplatePathController, "J-PHONE V401SH からのアクセス" do
|
30
|
-
before do
|
31
|
-
request.user_agent = "J-PHONE/3.0/V401SH"
|
32
|
-
get :index
|
33
|
-
end
|
34
|
-
it 'テンプレートの探索順が正しいこと' do
|
35
|
-
response.template.mobile_template_candidates.should == [ 'mobile_jphone', 'mobile_vodafone', 'mobile_softbank', 'mobile' ]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe TemplatePathController, "Vodafone V903T からのアクセス" do
|
40
|
-
before do
|
41
|
-
request.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"
|
42
|
-
get :index
|
43
|
-
end
|
44
|
-
it 'テンプレートの探索順が正しいこと' do
|
45
|
-
response.template.mobile_template_candidates.should == [ 'mobile_vodafone', 'mobile_softbank', 'mobile' ]
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe TemplatePathController, "SoftBank 910T からのアクセス" do
|
50
|
-
before do
|
51
|
-
request.user_agent = "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
52
|
-
get :index
|
53
|
-
end
|
54
|
-
it 'テンプレートの探索順が正しいこと' do
|
55
|
-
response.template.mobile_template_candidates.should == [ 'mobile_softbank', 'mobile' ]
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe TemplatePathController, "integrated_views" do
|
60
|
-
integrate_views
|
61
|
-
describe "index" do
|
62
|
-
context "PCからのアクセスの場合" do
|
63
|
-
before do
|
64
|
-
get :index
|
65
|
-
end
|
66
|
-
it 'index.html.erbが使用されること' do
|
67
|
-
response.should have_tag("h1", "index.html.erb")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
context "DoCoMoからのアクセスの場合" do
|
71
|
-
before do
|
72
|
-
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
73
|
-
get :index
|
74
|
-
end
|
75
|
-
it 'index_mobile_docomo.html.erbが使用されること' do
|
76
|
-
response.should have_tag("h1", "index_mobile_docomo.html.erb")
|
77
|
-
end
|
78
|
-
end
|
79
|
-
context "SoftBankからのアクセスの場合" do
|
80
|
-
before do
|
81
|
-
request.user_agent = "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
82
|
-
get :index
|
83
|
-
end
|
84
|
-
it 'index_mobile.html.erbが使用されること' do
|
85
|
-
response.should have_tag("h1", "index_mobile.html.erb")
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
describe "partial" do
|
90
|
-
context "PCからのアクセスの場合" do
|
91
|
-
before do
|
92
|
-
get :partial
|
93
|
-
end
|
94
|
-
it '_partial.html.erbが使用されること' do
|
95
|
-
response.should have_tag("h2", "_partial.html.erb")
|
96
|
-
end
|
97
|
-
end
|
98
|
-
context "DoCoMoからのアクセスの場合" do
|
99
|
-
before do
|
100
|
-
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
101
|
-
get :partial
|
102
|
-
end
|
103
|
-
it '_partial_mobile_docomo.html.erbが使用されること' do
|
104
|
-
response.should have_tag("h2", "_partial_mobile_docomo.html.erb")
|
105
|
-
end
|
106
|
-
end
|
107
|
-
context "SoftBankからのアクセスの場合" do
|
108
|
-
before do
|
109
|
-
request.user_agent = "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
110
|
-
get :partial
|
111
|
-
end
|
112
|
-
it '_partial_mobile.html.erbが使用されること' do
|
113
|
-
response.should have_tag("h2", "_partial_mobile.html.erb")
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
@@ -1,117 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
-
|
5
|
-
describe "trans_sid が起動しないとき", :shared => true do
|
6
|
-
it "で link_to の自動書き換えが行われない" do
|
7
|
-
get :link
|
8
|
-
response.body.should =~ %r{^<a href="/.+?/link">linkto</a>$}
|
9
|
-
end
|
10
|
-
it "で form の自動書き換えが行われない" do
|
11
|
-
get :form
|
12
|
-
response.body.should =~ %r{^<form action="/.+?/form" method="post">Hello</form>$}
|
13
|
-
end
|
14
|
-
it "で redirect の自動書き換えが行われない" do
|
15
|
-
get :redirect
|
16
|
-
response.should redirect_to('/')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "trans_sid が起動するとき", :shared => true do
|
21
|
-
before :each do
|
22
|
-
request.session_options[:id] = "mysessionid"
|
23
|
-
end
|
24
|
-
it "で link_to の自動書き換えが行われる" do
|
25
|
-
get :link
|
26
|
-
response.body.should =~ %r{^<a href="/.+?/link\?_session_id=mysessionid">linkto</a>$}
|
27
|
-
end
|
28
|
-
it "で form の自動書き換えが行われる" do
|
29
|
-
get :form
|
30
|
-
response.body.should =~ %r{^<form action="/.+?/form\?_session_id=mysessionid" method="post">Hello<input type="hidden" name="_session_id" value="mysessionid" /></form>$}
|
31
|
-
end
|
32
|
-
it "で redirect の自動書き換えが行われる" do
|
33
|
-
get :redirect
|
34
|
-
response.should redirect_to('/?_session_id=mysessionid')
|
35
|
-
end
|
36
|
-
it "でセッションIDが空のときには有効にならない" do
|
37
|
-
request.session_options[:id] = ""
|
38
|
-
get :link
|
39
|
-
response.body.should =~ %r{^<a href="/.+?/link">linkto</a>$}
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe TransSidBaseController, "という trans_sid が有効になっていないコントローラ" do
|
44
|
-
controller_name :trans_sid_base
|
45
|
-
it "の trans_sid_mode は nil" do
|
46
|
-
controller.trans_sid_mode.should be_nil
|
47
|
-
end
|
48
|
-
it_should_behave_like "trans_sid が起動しないとき"
|
49
|
-
end
|
50
|
-
|
51
|
-
describe TransSidNoneController, "という trans_sid :none が指定されているコントローラ" do
|
52
|
-
controller_name :trans_sid_none
|
53
|
-
it "の trans_sid_mode は :none" do
|
54
|
-
controller.trans_sid_mode.should == :none
|
55
|
-
end
|
56
|
-
it_should_behave_like "trans_sid が起動しないとき"
|
57
|
-
end
|
58
|
-
|
59
|
-
describe TransSidAlwaysController, "という trans_sid :always が指定されているコントローラ" do
|
60
|
-
controller_name :trans_sid_always
|
61
|
-
before :each do
|
62
|
-
request.session_options[:id] = "mysessionid"
|
63
|
-
end
|
64
|
-
it "の trans_sid_mode は :always" do
|
65
|
-
controller.trans_sid_mode.should == :always
|
66
|
-
end
|
67
|
-
it_should_behave_like "trans_sid が起動するとき"
|
68
|
-
end
|
69
|
-
|
70
|
-
describe TransSidMobileController, "という trans_sid :mobile が指定されているコントローラ" do
|
71
|
-
controller_name :trans_sid_mobile
|
72
|
-
it "の trans_sid_mode は :mobile" do
|
73
|
-
controller.trans_sid_mode.should == :mobile
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def describe_mobile_with_ua(user_agent, &block)
|
78
|
-
describe("trans_sid :mobile が指定されているコントローラに #{user_agent} からアクセスしたとき") do
|
79
|
-
controller_name :trans_sid_mobile
|
80
|
-
before do
|
81
|
-
request.user_agent = user_agent
|
82
|
-
end
|
83
|
-
instance_eval(&block)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe TransSidAlwaysController, "という trans_sid :always が指定されているコントローラで reset_session したとき" do
|
88
|
-
controller_name :trans_sid_always
|
89
|
-
before :each do
|
90
|
-
# 擬似的 reset_session
|
91
|
-
request.session_options[:id] = nil
|
92
|
-
end
|
93
|
-
it "の trans_sid_mode は :always" do
|
94
|
-
controller.trans_sid_mode.should == :always
|
95
|
-
end
|
96
|
-
it_should_behave_like "trans_sid が起動しないとき"
|
97
|
-
end
|
98
|
-
|
99
|
-
describe_mobile_with_ua "DoCoMo/2.0 SH902i(c100;TB;W24H12)" do
|
100
|
-
it_should_behave_like "trans_sid が起動するとき"
|
101
|
-
end
|
102
|
-
|
103
|
-
describe_mobile_with_ua "J-PHONE/3.0/V301D" do
|
104
|
-
it_should_behave_like "trans_sid が起動するとき"
|
105
|
-
end
|
106
|
-
|
107
|
-
describe_mobile_with_ua "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0" do
|
108
|
-
it_should_behave_like "trans_sid が起動しないとき"
|
109
|
-
end
|
110
|
-
|
111
|
-
describe_mobile_with_ua "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1" do
|
112
|
-
it_should_behave_like "trans_sid が起動しないとき"
|
113
|
-
end
|
114
|
-
|
115
|
-
describe_mobile_with_ua "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" do
|
116
|
-
it_should_behave_like "trans_sid が起動しないとき"
|
117
|
-
end
|
@@ -1,165 +0,0 @@
|
|
1
|
-
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
|
2
|
-
|
3
|
-
# Don't load rspec if running "rake gems:*"
|
4
|
-
unless ARGV.any? {|a| a =~ /^gems/}
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'spec/rake/spectask'
|
8
|
-
rescue MissingSourceFile
|
9
|
-
module Spec
|
10
|
-
module Rake
|
11
|
-
class SpecTask
|
12
|
-
def initialize(name)
|
13
|
-
task name do
|
14
|
-
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
15
|
-
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
|
16
|
-
|
17
|
-
# ... otherwise, do this:
|
18
|
-
raise <<-MSG
|
19
|
-
|
20
|
-
#{"*" * 80}
|
21
|
-
* You are trying to run an rspec rake task defined in
|
22
|
-
* #{__FILE__},
|
23
|
-
* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
|
24
|
-
#{"*" * 80}
|
25
|
-
MSG
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Rake.application.instance_variable_get('@tasks').delete('default')
|
34
|
-
|
35
|
-
spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
|
36
|
-
task :noop do
|
37
|
-
end
|
38
|
-
|
39
|
-
task :default => :spec
|
40
|
-
task :stats => "spec:statsetup"
|
41
|
-
|
42
|
-
desc "Run all specs in spec directory (excluding plugin specs)"
|
43
|
-
Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
|
44
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
45
|
-
t.spec_files = FileList['spec/**/*/*_spec.rb']
|
46
|
-
end
|
47
|
-
|
48
|
-
namespace :spec do
|
49
|
-
desc "Run all specs in spec directory with RCov (excluding plugin specs)"
|
50
|
-
Spec::Rake::SpecTask.new(:rcov) do |t|
|
51
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
52
|
-
t.spec_files = FileList['spec/**/*/*_spec.rb']
|
53
|
-
t.rcov = true
|
54
|
-
t.rcov_opts = lambda do
|
55
|
-
IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
desc "Print Specdoc for all specs (excluding plugin specs)"
|
60
|
-
Spec::Rake::SpecTask.new(:doc) do |t|
|
61
|
-
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
62
|
-
t.spec_files = FileList['spec/**/*/*_spec.rb']
|
63
|
-
end
|
64
|
-
|
65
|
-
desc "Print Specdoc for all plugin examples"
|
66
|
-
Spec::Rake::SpecTask.new(:plugin_doc) do |t|
|
67
|
-
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
68
|
-
t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*')
|
69
|
-
end
|
70
|
-
|
71
|
-
[:models, :controllers, :views, :helpers, :lib].each do |sub|
|
72
|
-
desc "Run the code examples in spec/#{sub}"
|
73
|
-
Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
|
74
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
75
|
-
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
desc "Run the code examples in vendor/plugins (except RSpec's own)"
|
80
|
-
Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
|
81
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
82
|
-
t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
|
83
|
-
end
|
84
|
-
|
85
|
-
namespace :plugins do
|
86
|
-
desc "Runs the examples for rspec_on_rails"
|
87
|
-
Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
|
88
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
89
|
-
t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*/*_spec.rb']
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
# Setup specs for stats
|
94
|
-
task :statsetup do
|
95
|
-
require 'code_statistics'
|
96
|
-
::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
|
97
|
-
::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
|
98
|
-
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
99
|
-
::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
100
|
-
::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
101
|
-
::STATS_DIRECTORIES << %w(Routing\ specs spec/lib) if File.exist?('spec/routing')
|
102
|
-
::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
103
|
-
::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
104
|
-
::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
105
|
-
::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
106
|
-
::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
107
|
-
::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
|
108
|
-
end
|
109
|
-
|
110
|
-
namespace :db do
|
111
|
-
namespace :fixtures do
|
112
|
-
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
|
113
|
-
task :load => :environment do
|
114
|
-
ActiveRecord::Base.establish_connection(Rails.env)
|
115
|
-
base_dir = File.join(Rails.root, 'spec', 'fixtures')
|
116
|
-
fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
|
117
|
-
|
118
|
-
require 'active_record/fixtures'
|
119
|
-
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
|
120
|
-
Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
namespace :server do
|
127
|
-
daemonized_server_pid = File.expand_path("#{RAILS_ROOT}/tmp/pids/spec_server.pid")
|
128
|
-
|
129
|
-
desc "start spec_server."
|
130
|
-
task :start do
|
131
|
-
if File.exist?(daemonized_server_pid)
|
132
|
-
$stderr.puts "spec_server is already running."
|
133
|
-
else
|
134
|
-
$stderr.puts %Q{Starting up spec_server ...}
|
135
|
-
FileUtils.mkdir_p('tmp/pids') unless test ?d, 'tmp/pids'
|
136
|
-
system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
desc "stop spec_server."
|
141
|
-
task :stop do
|
142
|
-
unless File.exist?(daemonized_server_pid)
|
143
|
-
$stderr.puts "No server running."
|
144
|
-
else
|
145
|
-
$stderr.puts "Shutting down spec_server ..."
|
146
|
-
system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
|
147
|
-
File.delete(daemonized_server_pid)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
desc "restart spec_server."
|
152
|
-
task :restart => [:stop, :start]
|
153
|
-
|
154
|
-
desc "check if spec server is running"
|
155
|
-
task :status do
|
156
|
-
if File.exist?(daemonized_server_pid)
|
157
|
-
$stderr.puts %Q{spec_server is running (PID: #{File.read(daemonized_server_pid).gsub("\n","")})}
|
158
|
-
else
|
159
|
-
$stderr.puts "No server running."
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
end
|