jpmobile 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +227 -0
- data/Rakefile +6 -13
- data/lib/jpmobile/docomo_guid.rb +42 -0
- data/lib/jpmobile/filter.rb +1 -1
- data/lib/jpmobile/helpers.rb +2 -1
- data/lib/jpmobile/hook_action_controller.rb +12 -0
- data/lib/jpmobile/hook_action_view.rb +82 -72
- data/lib/jpmobile/{hook_abstract_request.rb → hook_request.rb} +1 -1
- data/lib/jpmobile/mobile/au.rb +9 -3
- data/lib/jpmobile/mobile/z_display_info_docomo.rb +10 -2
- data/lib/jpmobile/mobile/z_ip_addresses_au.rb +1 -26
- data/lib/jpmobile/mobile/z_ip_addresses_willcom.rb +2 -4
- data/lib/jpmobile/rack/auth.rb +55 -0
- data/lib/jpmobile/rack/combined_logger.rb +54 -0
- data/lib/jpmobile/rack/request.rb +7 -0
- data/lib/jpmobile/rack/trans_sid.rb +14 -0
- data/lib/jpmobile/trans_sid.rb +70 -62
- data/lib/jpmobile/version.rb +1 -1
- data/test/{au_test.rb → legacy/au_test.rb} +0 -0
- data/test/{autoload_test.rb → legacy/autoload_test.rb} +0 -0
- data/test/{docomo_test.rb → legacy/docomo_test.rb} +0 -0
- data/test/{emoticon_functional_test.rb → legacy/emoticon_functional_test.rb} +1 -1
- data/test/{emoticon_test.rb → legacy/emoticon_test.rb} +0 -0
- data/test/{filter_test.rb → legacy/filter_test.rb} +0 -0
- data/test/{helper.rb → legacy/helper.rb} +4 -5
- data/test/{helpers_test.rb → legacy/helpers_test.rb} +1 -1
- data/test/{softbank_test.rb → legacy/softbank_test.rb} +0 -0
- data/test/{willcom_test.rb → legacy/willcom_test.rb} +0 -0
- data/test/rails/overrides/app/controllers/application.rb +5 -0
- data/test/rails/overrides/app/controllers/docomo_guid_controller.rb +13 -0
- data/test/rails/overrides/app/controllers/filter_controller.rb +26 -0
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +5 -0
- data/test/rails/overrides/app/controllers/template_path_controller.rb +6 -0
- data/test/rails/overrides/app/controllers/trans_sid_controller.rb +28 -0
- data/test/rails/overrides/app/views/filter/index.html.erb +0 -0
- data/test/rails/overrides/app/views/hankaku_filter/index.html.erb +0 -0
- data/test/rails/overrides/app/views/template_path/_partial.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_mobile.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_mobile_docomo.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_mobile.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_mobile_docomo.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/partial.html.erb +2 -0
- data/test/rails/overrides/lib/tasks/rspec.rake +165 -0
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +77 -0
- data/test/rails/overrides/spec/controllers/docomo_spec.rb +28 -0
- data/test/rails/overrides/spec/controllers/emobile_spec.rb +35 -0
- data/test/rails/overrides/spec/controllers/filter_spec.rb +157 -0
- data/test/rails/overrides/spec/controllers/pc_spec.rb +11 -0
- data/test/rails/overrides/spec/controllers/softbank_emulator_spec.rb +40 -0
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +115 -0
- data/test/rails/overrides/spec/controllers/trans_sid_spec.rb +98 -0
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +13 -0
- data/test/rails/overrides/spec/rcov.opts +2 -0
- data/test/rails/overrides/spec/rspec.rake +165 -0
- data/test/rails/overrides/spec/spec.opts +4 -0
- data/test/rails/overrides/spec/spec_helper.rb +47 -0
- data/test/rails/rails_root/README +256 -0
- data/test/rails/rails_root/Rakefile +10 -0
- data/test/rails/rails_root/app/controllers/application.rb +5 -0
- data/test/rails/rails_root/app/controllers/docomo_guid_controller.rb +13 -0
- data/test/rails/rails_root/app/controllers/filter_controller.rb +26 -0
- data/test/rails/rails_root/app/controllers/mobile_spec_controller.rb +5 -0
- data/test/rails/rails_root/app/controllers/template_path_controller.rb +6 -0
- data/test/rails/rails_root/app/controllers/trans_sid_controller.rb +26 -0
- data/test/rails/rails_root/app/helpers/application_helper.rb +3 -0
- data/test/rails/rails_root/app/views/template_path/index.html.erb +1 -0
- data/test/rails/rails_root/app/views/template_path/index_mobile.html.erb +1 -0
- data/test/rails/rails_root/app/views/template_path/index_mobile_docomo.html.erb +1 -0
- data/test/rails/rails_root/config/boot.rb +109 -0
- data/test/rails/rails_root/config/database.yml +22 -0
- data/test/rails/rails_root/config/environment.rb +75 -0
- data/test/rails/rails_root/config/environments/development.rb +17 -0
- data/test/rails/rails_root/config/environments/production.rb +24 -0
- data/test/rails/rails_root/config/environments/test.rb +22 -0
- data/test/rails/rails_root/config/initializers/inflections.rb +10 -0
- data/test/rails/rails_root/config/initializers/mime_types.rb +5 -0
- data/test/rails/rails_root/config/initializers/new_rails_defaults.rb +17 -0
- data/test/rails/rails_root/config/locales/en.yml +5 -0
- data/test/rails/rails_root/config/routes.rb +43 -0
- data/test/rails/rails_root/db/development.sqlite3 +0 -0
- data/test/rails/rails_root/db/schema.rb +14 -0
- data/test/rails/rails_root/db/test.sqlite3 +0 -0
- data/test/rails/rails_root/doc/README_FOR_APP +5 -0
- data/test/rails/rails_root/lib/tasks/rspec.rake +165 -0
- data/test/rails/rails_root/log/development.log +38 -0
- data/test/rails/rails_root/log/production.log +0 -0
- data/test/rails/rails_root/log/server.log +0 -0
- data/test/rails/rails_root/log/test.log +401 -0
- data/test/rails/rails_root/public/404.html +30 -0
- data/test/rails/rails_root/public/422.html +30 -0
- data/test/rails/rails_root/public/500.html +33 -0
- data/test/rails/rails_root/public/dispatch.cgi +10 -0
- data/test/rails/rails_root/public/dispatch.fcgi +24 -0
- data/test/rails/rails_root/public/dispatch.rb +10 -0
- data/test/rails/rails_root/public/favicon.ico +0 -0
- data/test/rails/rails_root/public/images/rails.png +0 -0
- data/test/rails/rails_root/public/index.html +274 -0
- data/test/rails/rails_root/public/javascripts/application.js +2 -0
- data/test/rails/rails_root/public/javascripts/controls.js +963 -0
- data/test/rails/rails_root/public/javascripts/dragdrop.js +973 -0
- data/test/rails/rails_root/public/javascripts/effects.js +1128 -0
- data/test/rails/rails_root/public/javascripts/prototype.js +4320 -0
- data/test/rails/rails_root/public/robots.txt +5 -0
- data/test/rails/rails_root/script/about +4 -0
- data/test/rails/rails_root/script/console +3 -0
- data/test/rails/rails_root/script/dbconsole +3 -0
- data/test/rails/rails_root/script/destroy +3 -0
- data/test/rails/rails_root/script/generate +3 -0
- data/test/rails/rails_root/script/performance/benchmarker +3 -0
- data/test/rails/rails_root/script/performance/profiler +3 -0
- data/test/rails/rails_root/script/performance/request +3 -0
- data/test/rails/rails_root/script/plugin +3 -0
- data/test/rails/rails_root/script/process/inspector +3 -0
- data/test/rails/rails_root/script/process/reaper +3 -0
- data/test/rails/rails_root/script/process/spawner +3 -0
- data/test/rails/rails_root/script/runner +3 -0
- data/test/rails/rails_root/script/server +3 -0
- data/test/rails/rails_root/spec/controllers/docomo_guid_spec.rb +77 -0
- data/test/rails/rails_root/spec/controllers/docomo_spec.rb +28 -0
- data/test/rails/rails_root/spec/controllers/emobile_spec.rb +35 -0
- data/test/rails/rails_root/spec/controllers/filter_spec.rb +157 -0
- data/test/rails/rails_root/spec/controllers/pc_spec.rb +11 -0
- data/test/rails/rails_root/spec/controllers/softbank_emulator_spec.rb +40 -0
- data/test/rails/rails_root/spec/controllers/template_path_spec.rb +85 -0
- data/test/rails/rails_root/spec/controllers/trans_sid_spec.rb +96 -0
- data/test/rails/rails_root/spec/helpers/helpers_spec.rb +13 -0
- data/test/rails/rails_root/spec/rcov.opts +2 -0
- data/test/rails/rails_root/spec/rspec.rake +165 -0
- data/test/rails/rails_root/spec/spec.opts +4 -0
- data/test/rails/rails_root/spec/spec_helper.rb +47 -0
- data/test/rails/rails_root/test/performance/browsing_test.rb +9 -0
- data/test/rails/rails_root/test/test_helper.rb +38 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/CHANGELOG +7 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/MIT-LICENSE +7 -0
- data/{README → test/rails/rails_root/vendor/plugins/jpmobile/README.rdoc} +15 -17
- data/test/rails/rails_root/vendor/plugins/jpmobile/Rakefile +116 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/init.rb +3 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/install.rb +1 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile.rb +42 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/datum_conv.rb +72 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/docomo_guid.rb +42 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/email.rb +19 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb +123 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/au.rb +1287 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/conversion_table.rb +3908 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/docomo.rb +255 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/softbank.rb +477 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/z_combine.rb +20 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/filter.rb +173 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/helpers.rb +185 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_controller.rb +11 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_view.rb +142 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_request.rb +13 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +73 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/au.rb +97 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/display.rb +33 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/docomo.rb +97 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/emobile.rb +17 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/softbank.rb +110 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/willcom.rb +39 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_display_info_docomo.rb +688 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_au.rb +22 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_docomo.rb +12 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_emobile.rb +10 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_softbank.rb +17 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_willcom.rb +117 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/position.rb +67 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/request_with_mobile.rb +44 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/trans_sid.rb +105 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +21 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/version.rb +9 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/spec.opts +6 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/spec_helper.rb +36 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/detect_by_email_spec.rb +31 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/detect_by_ua_spec.rb +42 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/is_carrier_spec.rb +93 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/spec_helper.rb +5 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/util_spec.rb +28 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/valid_ip_spec.rb +60 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tasks/jpmobile_tasks.rake +59 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/emoji/genregexp.rb +47 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_au_emoticon_table.rb +34 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_docomo_emoticon_table.rb +34 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_emoticon_conversion_table.rb +107 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_softbank_emoticon_table.rb +32 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/list_gps_unsupported_au.rb +23 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/update_display_info_docomo.rb +45 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/update_ip_addresses_au.rb +29 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/update_ip_addresses_willcom.rb +17 -0
- data/tools/update_ip_addresses_au.rb +15 -5
- metadata +188 -22
data/lib/jpmobile/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -4,7 +4,7 @@ require 'action_controller'
|
|
4
4
|
require 'rack'
|
5
5
|
|
6
6
|
RAILS_ENV = "test"
|
7
|
-
require File.dirname(__FILE__)+'
|
7
|
+
require File.dirname(__FILE__)+'/../../lib/jpmobile'
|
8
8
|
|
9
9
|
# ActionPackのTestのためのrequire
|
10
10
|
action_pack_full_path = Gem.cache.search('actionpack').sort_by { |g| g.version.version }.last
|
@@ -20,17 +20,16 @@ end
|
|
20
20
|
|
21
21
|
def request_with_ua(user_agent, env={})
|
22
22
|
fake_cgi = FakeCgi.new(user_agent, env)
|
23
|
-
[
|
24
|
-
ActionController::CgiRequest.new(fake_cgi),
|
23
|
+
[
|
25
24
|
Rack::Request.new(
|
26
25
|
Rack::MockRequest.env_for('http://www.example.jp', fake_cgi.env_table)
|
27
|
-
).extend(Jpmobile::RequestWithMobile)
|
26
|
+
).extend(Jpmobile::RequestWithMobile)
|
28
27
|
]
|
29
28
|
end
|
30
29
|
|
31
30
|
## add helper methods to rails testing framework
|
32
31
|
module ActionController
|
33
|
-
class TestRequest <
|
32
|
+
class TestRequest < Request
|
34
33
|
attr_accessor :user_agent
|
35
34
|
end
|
36
35
|
end
|
@@ -208,7 +208,7 @@ class HelpersTest < Test::Unit::TestCase
|
|
208
208
|
results = []
|
209
209
|
(Hpricot(str)/:a).each do |link|
|
210
210
|
path, query = link["href"].split(/\?/, 2)
|
211
|
-
params = query.nil? ? nil :
|
211
|
+
params = query.nil? ? nil : Rack::Utils.parse_query(query)
|
212
212
|
results << [link.inner_html, link.attributes, path, params]
|
213
213
|
end
|
214
214
|
return results
|
File without changes
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class DocomoGuidBaseController < ApplicationController
|
2
|
+
def link
|
3
|
+
render :inline=>%{<%= link_to "linkto" %>}
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class DocomoGuidAlwaysController < DocomoGuidBaseController
|
8
|
+
docomo_guid :always
|
9
|
+
end
|
10
|
+
|
11
|
+
class DocomoGuidDocomoController < DocomoGuidBaseController
|
12
|
+
docomo_guid :docomo
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class FilterControllerBase < ApplicationController
|
2
|
+
def abracadabra_utf8
|
3
|
+
render :text => "アブラカダブラ"
|
4
|
+
end
|
5
|
+
def abracadabra_xhtml_utf8
|
6
|
+
response.content_type = "application/xhtml+xml"
|
7
|
+
render :text => "アブラカダブラ"
|
8
|
+
end
|
9
|
+
def index
|
10
|
+
@q = params[:q]
|
11
|
+
end
|
12
|
+
def empty
|
13
|
+
render :text => ""
|
14
|
+
end
|
15
|
+
def rawdata
|
16
|
+
send_data "アブラカダブラ", :type => 'application/octet-stream'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class FilterController < FilterControllerBase
|
21
|
+
mobile_filter
|
22
|
+
end
|
23
|
+
|
24
|
+
class HankakuFilterController < FilterControllerBase
|
25
|
+
mobile_filter :hankaku => true
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class TransSidBaseController < ApplicationController
|
2
|
+
ActionController::Base.session_options[:key] = '_session_id'
|
3
|
+
def form
|
4
|
+
render :inline=>%{<% form_tag do %>Hello<% end %>}
|
5
|
+
end
|
6
|
+
def link
|
7
|
+
render :inline=>%{<%= link_to "linkto" %>}
|
8
|
+
end
|
9
|
+
def redirect
|
10
|
+
redirect_to('/')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class TransSidAlwaysController < TransSidBaseController
|
15
|
+
trans_sid :always
|
16
|
+
end
|
17
|
+
|
18
|
+
class TransSidNoneController < TransSidBaseController
|
19
|
+
trans_sid :none
|
20
|
+
end
|
21
|
+
|
22
|
+
class TransSidMobileController < TransSidBaseController
|
23
|
+
trans_sid :mobile
|
24
|
+
end
|
25
|
+
|
26
|
+
class TransSidAlwaysAndSessionOffController < TransSidBaseController
|
27
|
+
trans_sid :always
|
28
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<h2>_partial.html.erb</h2>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h2>_partial_mobile.html.erb</h2>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h2>_partial_mobile_docomo.html.erb</h2>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>index.html.erb<h1>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>index_mobile.html.erb</h1>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>index_mobile_docomo.html.erb</h1>
|
@@ -0,0 +1,165 @@
|
|
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
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "docomo_guid が起動しないとき", :shared => true do
|
4
|
+
it "で link_to の自動書き換えが行われない" do
|
5
|
+
get :link
|
6
|
+
response.body.should =~ %r{^<a href="/.+?/link">linkto</a>$}
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "docomo_guid が起動するとき", :shared => true do
|
11
|
+
it "で link_to の自動書き換えが行われる" do
|
12
|
+
get :link
|
13
|
+
response.body.should =~ %r{^<a href="/.+?/link\?guid=ON">linkto</a>$}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe DocomoGuidBaseController, "という docomo_guid が有効になっていないコントローラ" do
|
18
|
+
controller_name :docomo_guid_base
|
19
|
+
it "の docomo_guid_mode は nil" do
|
20
|
+
controller.docomo_guid_mode.should be_nil
|
21
|
+
end
|
22
|
+
it_should_behave_like "docomo_guid が起動しないとき"
|
23
|
+
end
|
24
|
+
|
25
|
+
describe DocomoGuidAlwaysController, "という docomo_guid :always が指定されているコントローラ" do
|
26
|
+
controller_name :docomo_guid_always
|
27
|
+
it "の trans_sid_mode は :always" do
|
28
|
+
controller.docomo_guid_mode.should == :always
|
29
|
+
end
|
30
|
+
it_should_behave_like "docomo_guid が起動するとき"
|
31
|
+
end
|
32
|
+
|
33
|
+
describe DocomoGuidDocomoController, "という docomo_guid :docomo が指定されているコントローラ" do
|
34
|
+
controller_name :docomo_guid_docomo
|
35
|
+
it "の docomo_guid_mode は :docomo" do
|
36
|
+
controller.docomo_guid_mode.should == :docomo
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def describe_mobile_with_ua(user_agent, &block)
|
41
|
+
describe("trans_sid :docomo が指定されているコントローラに #{user_agent} からアクセスしたとき") do
|
42
|
+
controller_name :docomo_guid_docomo
|
43
|
+
before do
|
44
|
+
request.user_agent = user_agent
|
45
|
+
end
|
46
|
+
instance_eval(&block)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe_mobile_with_ua "DoCoMo/2.0 SH902i(c100;TB;W24H12)" do
|
51
|
+
it_should_behave_like "docomo_guid が起動するとき"
|
52
|
+
end
|
53
|
+
|
54
|
+
describe_mobile_with_ua "J-PHONE/3.0/V301D" do
|
55
|
+
it_should_behave_like "docomo_guid が起動しないとき"
|
56
|
+
end
|
57
|
+
|
58
|
+
describe_mobile_with_ua "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0" do
|
59
|
+
it_should_behave_like "docomo_guid が起動しないとき"
|
60
|
+
end
|
61
|
+
|
62
|
+
describe_mobile_with_ua "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1" do
|
63
|
+
it_should_behave_like "docomo_guid が起動しないとき"
|
64
|
+
end
|
65
|
+
|
66
|
+
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
|
67
|
+
it_should_behave_like "docomo_guid が起動しないとき"
|
68
|
+
end
|
69
|
+
|
70
|
+
describe_mobile_with_ua "DoCoMo/1.0/N505i/c20/TB/W20H10 (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)" do
|
71
|
+
it_should_behave_like "docomo_guid が起動しないとき"
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
describe_mobile_with_ua "DoCoMo/2.0/SO502i (compatible; Y!J-SRD/1.0; http://help.yahoo.co.jp/help/jp/search/indexing/indexing-27.html)" do
|
76
|
+
it_should_behave_like "docomo_guid が起動しないとき"
|
77
|
+
end
|