railties 4.0.0.beta1 → 4.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +120 -27
- data/RDOC_MAIN.rdoc +73 -0
- data/bin/rails +3 -1
- data/lib/rails/api/task.rb +158 -0
- data/lib/rails/app_rails_loader.rb +44 -20
- data/lib/rails/application.rb +55 -32
- data/lib/rails/application/configuration.rb +9 -7
- data/lib/rails/commands.rb +2 -0
- data/lib/rails/commands/console.rb +3 -1
- data/lib/rails/commands/server.rb +6 -2
- data/lib/rails/engine.rb +4 -3
- data/lib/rails/generators/actions.rb +1 -1
- data/lib/rails/generators/app_base.rb +52 -30
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +10 -1
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb +9 -9
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb +1 -2
- data/lib/rails/generators/generated_attribute.rb +4 -0
- data/lib/rails/generators/named_base.rb +2 -1
- data/lib/rails/generators/rails/app/templates/Gemfile +9 -4
- data/lib/rails/generators/rails/app/templates/config.ru +1 -1
- data/lib/rails/generators/rails/app/templates/config/application.rb +3 -2
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +2 -0
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/secret_token.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
- data/lib/rails/generators/rails/app/templates/public/404.html +41 -10
- data/lib/rails/generators/rails/app/templates/public/422.html +42 -10
- data/lib/rails/generators/rails/app/templates/public/500.html +41 -10
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb +1 -1
- data/lib/rails/generators/rails/model/USAGE +16 -10
- data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +9 -5
- data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +0 -3
- data/lib/rails/generators/rails/plugin_new/templates/Gemfile +0 -8
- data/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb +4 -8
- data/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js +13 -0
- data/lib/rails/generators/rails/plugin_new/templates/rails/stylesheets.css +13 -0
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +1 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +1 -1
- data/lib/rails/generators/test_case.rb +6 -211
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml +7 -9
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +5 -1
- data/lib/rails/generators/testing/assertions.rb +121 -0
- data/lib/rails/generators/testing/behaviour.rb +106 -0
- data/lib/rails/generators/testing/setup_and_teardown.rb +18 -0
- data/lib/rails/info.rb +2 -2
- data/lib/rails/tasks/documentation.rake +2 -46
- data/lib/rails/templates/rails/welcome/index.html.erb +1 -1
- data/lib/rails/test_unit/railtie.rb +4 -0
- data/lib/rails/test_unit/sub_test_task.rb +78 -1
- data/lib/rails/test_unit/testing.rake +32 -42
- data/lib/rails/version.rb +3 -3
- metadata +15 -23
- data/lib/rails/generators/rails/app/templates/app/assets/images/rails.png +0 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'active_support/core_ext/class/attribute'
|
2
|
+
require 'active_support/core_ext/module/delegation'
|
3
|
+
require 'active_support/core_ext/hash/reverse_merge'
|
4
|
+
require 'active_support/core_ext/kernel/reporting'
|
5
|
+
require 'active_support/concern'
|
6
|
+
require 'rails/generators'
|
7
|
+
|
8
|
+
module Rails
|
9
|
+
module Generators
|
10
|
+
module Testing
|
11
|
+
module Behaviour
|
12
|
+
extend ActiveSupport::Concern
|
13
|
+
|
14
|
+
included do
|
15
|
+
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
|
16
|
+
|
17
|
+
# Generators frequently change the current path using +FileUtils.cd+.
|
18
|
+
# So we need to store the path at file load and revert back to it after each test.
|
19
|
+
self.current_path = File.expand_path(Dir.pwd)
|
20
|
+
self.default_arguments = []
|
21
|
+
end
|
22
|
+
|
23
|
+
module ClassMethods
|
24
|
+
# Sets which generator should be tested:
|
25
|
+
#
|
26
|
+
# tests AppGenerator
|
27
|
+
def tests(klass)
|
28
|
+
self.generator_class = klass
|
29
|
+
end
|
30
|
+
|
31
|
+
# Sets default arguments on generator invocation. This can be overwritten when
|
32
|
+
# invoking it.
|
33
|
+
#
|
34
|
+
# arguments %w(app_name --skip-active-record)
|
35
|
+
def arguments(array)
|
36
|
+
self.default_arguments = array
|
37
|
+
end
|
38
|
+
|
39
|
+
# Sets the destination of generator files:
|
40
|
+
#
|
41
|
+
# destination File.expand_path("../tmp", File.dirname(__FILE__))
|
42
|
+
def destination(path)
|
43
|
+
self.destination_root = path
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Runs the generator configured for this class. The first argument is an array like
|
48
|
+
# command line arguments:
|
49
|
+
#
|
50
|
+
# class AppGeneratorTest < Rails::Generators::TestCase
|
51
|
+
# tests AppGenerator
|
52
|
+
# destination File.expand_path("../tmp", File.dirname(__FILE__))
|
53
|
+
# teardown :cleanup_destination_root
|
54
|
+
#
|
55
|
+
# test "database.yml is not created when skipping Active Record" do
|
56
|
+
# run_generator %w(myapp --skip-active-record)
|
57
|
+
# assert_no_file "config/database.yml"
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# You can provide a configuration hash as second argument. This method returns the output
|
62
|
+
# printed by the generator.
|
63
|
+
def run_generator(args=self.default_arguments, config={})
|
64
|
+
capture(:stdout) do
|
65
|
+
args += ['--skip-bundle'] unless args.include? '--dev'
|
66
|
+
self.generator_class.start(args, config.reverse_merge(destination_root: destination_root))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Instantiate the generator.
|
71
|
+
def generator(args=self.default_arguments, options={}, config={})
|
72
|
+
@generator ||= self.generator_class.new(args, options, config.reverse_merge(destination_root: destination_root))
|
73
|
+
end
|
74
|
+
|
75
|
+
# Create a Rails::Generators::GeneratedAttribute by supplying the
|
76
|
+
# attribute type and, optionally, the attribute name:
|
77
|
+
#
|
78
|
+
# create_generated_attribute(:string, 'name')
|
79
|
+
def create_generated_attribute(attribute_type, name = 'test', index = nil)
|
80
|
+
Rails::Generators::GeneratedAttribute.parse([name, attribute_type, index].compact.join(':'))
|
81
|
+
end
|
82
|
+
|
83
|
+
protected
|
84
|
+
|
85
|
+
def destination_root_is_set? # :nodoc:
|
86
|
+
raise "You need to configure your Rails::Generators::TestCase destination root." unless destination_root
|
87
|
+
end
|
88
|
+
|
89
|
+
def ensure_current_path # :nodoc:
|
90
|
+
cd current_path
|
91
|
+
end
|
92
|
+
|
93
|
+
def prepare_destination # :nodoc:
|
94
|
+
rm_rf(destination_root)
|
95
|
+
mkdir_p(destination_root)
|
96
|
+
end
|
97
|
+
|
98
|
+
def migration_file_name(relative) # :nodoc:
|
99
|
+
absolute = File.expand_path(relative, destination_root)
|
100
|
+
dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, '')
|
101
|
+
Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rails
|
2
|
+
module Generators
|
3
|
+
module Testing
|
4
|
+
module SetupAndTeardown
|
5
|
+
def setup # :nodoc:
|
6
|
+
destination_root_is_set?
|
7
|
+
ensure_current_path
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown # :nodoc:
|
12
|
+
ensure_current_path
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/rails/info.rb
CHANGED
@@ -29,7 +29,7 @@ module Rails
|
|
29
29
|
def framework_version(framework)
|
30
30
|
if Object.const_defined?(framework.classify)
|
31
31
|
require "#{framework}/version"
|
32
|
-
|
32
|
+
framework.classify.constantize.version.to_s
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -75,7 +75,7 @@ module Rails
|
|
75
75
|
|
76
76
|
# The Rails version.
|
77
77
|
property 'Rails version' do
|
78
|
-
Rails
|
78
|
+
Rails.version.to_s
|
79
79
|
end
|
80
80
|
|
81
81
|
property 'JavaScript Runtime' do
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rdoc/task'
|
2
|
+
require 'rails/api/task'
|
2
3
|
|
3
4
|
# Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise
|
4
5
|
class RDocTaskWithoutDescriptions < RDoc::Task
|
@@ -52,52 +53,7 @@ namespace :doc do
|
|
52
53
|
Rake::Task['doc:app'].comment = "Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")"
|
53
54
|
|
54
55
|
# desc 'Generate documentation for the Rails framework.'
|
55
|
-
|
56
|
-
rdoc.rdoc_dir = 'doc/api'
|
57
|
-
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
58
|
-
rdoc.title = "Rails Framework Documentation"
|
59
|
-
rdoc.options << '--line-numbers'
|
60
|
-
|
61
|
-
gem_path('rails') do |rails|
|
62
|
-
rdoc.options << '-m' << "#{rails}/README.rdoc"
|
63
|
-
end
|
64
|
-
|
65
|
-
gem_path('actionmailer') do |actionmailer|
|
66
|
-
%w(README.rdoc CHANGELOG.md MIT-LICENSE lib/action_mailer/base.rb).each do |file|
|
67
|
-
rdoc.rdoc_files.include("#{actionmailer}/#{file}")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
gem_path('actionpack') do |actionpack|
|
72
|
-
%w(README.rdoc CHANGELOG.md MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file|
|
73
|
-
rdoc.rdoc_files.include("#{actionpack}/#{file}")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
gem_path('activemodel') do |activemodel|
|
78
|
-
%w(README.rdoc CHANGELOG.md MIT-LICENSE lib/active_model/**/*.rb).each do |file|
|
79
|
-
rdoc.rdoc_files.include("#{activemodel}/#{file}")
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
gem_path('activerecord') do |activerecord|
|
84
|
-
%w(README.rdoc CHANGELOG.md lib/active_record/**/*.rb).each do |file|
|
85
|
-
rdoc.rdoc_files.include("#{activerecord}/#{file}")
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
gem_path('activesupport') do |activesupport|
|
90
|
-
%w(README.rdoc CHANGELOG.md lib/active_support/**/*.rb).each do |file|
|
91
|
-
rdoc.rdoc_files.include("#{activesupport}/#{file}")
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
gem_path('railties') do |railties|
|
96
|
-
%w(README.rdoc CHANGELOG.md lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file|
|
97
|
-
rdoc.rdoc_files.include("#{railties}/#{file}")
|
98
|
-
end
|
99
|
-
end
|
100
|
-
}
|
56
|
+
Rails::API::AppTask.new('rails')
|
101
57
|
|
102
58
|
# desc "Generate Rails Guides"
|
103
59
|
task :guides do
|
@@ -59,7 +59,7 @@
|
|
59
59
|
|
60
60
|
|
61
61
|
#header {
|
62
|
-
background-image: url(
|
62
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABACAYAAABY1SR7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAGZhJREFUeNqsWwmUXGWV/t5Sr9aurl6qO0l3Z9/DEoJh18gZQGAUxPHIyQHH7eioZ8bjnAFHZ0RndNxxRBhGcUbxoKIHBkTEcUYREIHIGpKQjUDS6U660/tSVV3Lq/fefPf/Xy2dBFGYx3npqvde/e/e/97v3u/e/8e4Lt2L8DCCAFcGwF8ZBjYbgM1rAZoO+WLwZhDMu9y4+YcOozbAqzwXNA3GdzX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wD996P6rY9zGHWPNMNPf8UJl9+Cdm169G9YWOdapjB8auShsJMc85YdekVWL7lQgroKHd68qMfRcAEu+lrX1GdSdmBKjQn0aOrU9lso5bK53uSLiyscNu10tAy66FganAQD9zwD6jM5ZBe2IeLbvoGWs5YofZQyfKXxbpejl133omfXfth7P/Fz8NRLbXgb0nGNe26GhGST5MzFmEYll2oCl+sd2IZCcWtTKxd6rokwdYVpyK9fB1z1KnIrD0NDt1WiNGB738X3kxJVapiWVmR5pCurc2iSaIkmNJ0Hr+9+WYkMu0YfHI7Dv9+J+766Eew8vSNiFP4WGsGBanhh6bw1K3fRjSdwfSel5FikTT67At4+t9vgVssojA0Rp6VwOyhfjx9262qABrfw1KaJW15YprXvsVcEG1sT5eCji40fXSURVyAvTd9TSmv6nTVifQx/uwzmHiU7kb3Clu+GC27MsY247p07+SihN0m/Kgc6EXRIjmMgDvCF9mcsXJxDgniZSnN3xFLIcc6Yormd1mhCX2QpWc7SteolNUpNUQkIUvJpDkUrsrfqy1L8ZjaFSTrJKLsCbvz6BqxaBwdBReWbJmF3kTa2NYRVYFGHEYKqqFKFXtzMg6uUhaJyzZyQ/d/FdUm8LwmAuYwO/vhQBU+m+ddmy+NpBKNWpIzF7EdRSxrOygMMl6LruUw2tQXOTy1akNFk/XtU/V70H3g6YyNNk5GtOIp/DYvlKp9LoJLWuIl2fADfJ/X71PQ8Jo2Vzbv620OAFI9jtIqCQ7tnfC/JxhNT4dShds4UKvB66s1ftPnRqOh/l13hDDqWGhxqUgTsIV1Fzg5Y7TEpKsK+B/w+sdqUWuqv1CxUN8K/MqHLMnhj/g/J/4/juDky9VSg0kh/zQj322897Pao/8nwAC+AZicLeuzngAAAABJRU5ErkJggg==);
|
63
63
|
background-repeat: no-repeat;
|
64
64
|
background-position: top left;
|
65
65
|
height: 64px;
|
@@ -1,6 +1,83 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
1
3
|
module Rails
|
4
|
+
class TestTask < Rake::TestTask # :nodoc: all
|
5
|
+
class TestInfo
|
6
|
+
def initialize(tasks)
|
7
|
+
@tasks = tasks
|
8
|
+
end
|
9
|
+
|
10
|
+
def files
|
11
|
+
@tasks.map { |task|
|
12
|
+
[task, translate(task)].find { |file| test_file?(file) }
|
13
|
+
}.compact
|
14
|
+
end
|
15
|
+
|
16
|
+
def translate(file)
|
17
|
+
if file =~ /^app\/(.*)$/
|
18
|
+
"test/#{$1.sub(/\.rb$/, '')}_test.rb"
|
19
|
+
else
|
20
|
+
"test/#{file}_test.rb"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def tasks
|
25
|
+
@tasks - test_file_tasks - opt_names
|
26
|
+
end
|
27
|
+
|
28
|
+
def opts
|
29
|
+
opts = opt_names
|
30
|
+
if opts.any?
|
31
|
+
"-n #{opts.join ' '}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def test_file_tasks
|
38
|
+
@tasks.find_all { |task|
|
39
|
+
[task, translate(task)].any? { |file| test_file?(file) }
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_file?(file)
|
44
|
+
file =~ /^test/ && File.file?(file) && !File.directory?(file)
|
45
|
+
end
|
46
|
+
|
47
|
+
def opt_names
|
48
|
+
(@tasks - test_file_tasks).reject { |t| task_defined? t }
|
49
|
+
end
|
50
|
+
|
51
|
+
def task_defined?(task)
|
52
|
+
Rake::Task.task_defined? task
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.test_info(tasks)
|
57
|
+
TestInfo.new tasks
|
58
|
+
end
|
59
|
+
|
60
|
+
def initialize(name = :test)
|
61
|
+
super
|
62
|
+
@libs << "test" # lib *and* test seem like a better default
|
63
|
+
end
|
64
|
+
|
65
|
+
def define
|
66
|
+
task @name do
|
67
|
+
if ENV['TESTOPTS']
|
68
|
+
ARGV.replace Shellwords.split ENV['TESTOPTS']
|
69
|
+
end
|
70
|
+
libs = @libs - $LOAD_PATH
|
71
|
+
$LOAD_PATH.unshift(*libs)
|
72
|
+
file_list.each { |fl|
|
73
|
+
FileList[fl].to_a.each { |f| require File.expand_path f }
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
2
79
|
# Silence the default description to cut down on `rake -T` noise.
|
3
|
-
class SubTestTask < Rake::TestTask
|
80
|
+
class SubTestTask < Rake::TestTask # :nodoc:
|
4
81
|
def desc(string)
|
5
82
|
# Ignore the description.
|
6
83
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rbconfig'
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rails/test_unit/sub_test_task'
|
4
|
+
require 'active_support/deprecation'
|
4
5
|
|
5
6
|
TEST_CHANGES_SINCE = Time.now - 600
|
6
7
|
|
@@ -47,7 +48,18 @@ task default: :test
|
|
47
48
|
|
48
49
|
desc 'Runs test:units, test:functionals, test:integration together'
|
49
50
|
task :test do
|
50
|
-
|
51
|
+
info = Rails::TestTask.test_info Rake.application.top_level_tasks
|
52
|
+
if info.files.any?
|
53
|
+
Rails::TestTask.new('test:single') { |t|
|
54
|
+
t.test_files = info.files
|
55
|
+
}
|
56
|
+
ENV['TESTOPTS'] ||= info.opts
|
57
|
+
Rake.application.top_level_tasks.replace info.tasks
|
58
|
+
|
59
|
+
Rake::Task['test:single'].invoke
|
60
|
+
else
|
61
|
+
Rake::Task[ENV['TEST'] ? 'test:single' : 'test:run'].invoke
|
62
|
+
end
|
51
63
|
end
|
52
64
|
|
53
65
|
namespace :test do
|
@@ -55,26 +67,11 @@ namespace :test do
|
|
55
67
|
# Placeholder task for other Railtie and plugins to enhance. See Active Record for an example.
|
56
68
|
end
|
57
69
|
|
58
|
-
task :run
|
59
|
-
errors = %w(test:units test:functionals test:integration).collect do |task|
|
60
|
-
begin
|
61
|
-
Rake::Task[task].invoke
|
62
|
-
nil
|
63
|
-
rescue => e
|
64
|
-
{ task: task, exception: e }
|
65
|
-
end
|
66
|
-
end.compact
|
67
|
-
|
68
|
-
if errors.any?
|
69
|
-
puts errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n")
|
70
|
-
abort
|
71
|
-
end
|
72
|
-
end
|
70
|
+
task :run => ['test:units', 'test:functionals', 'test:integration']
|
73
71
|
|
74
72
|
# Inspired by: http://ngauthier.com/2012/02/quick-tests-with-bash.html
|
75
73
|
desc "Run tests quickly by merging all types and not resetting db"
|
76
|
-
|
77
|
-
t.libs << "test"
|
74
|
+
Rails::TestTask.new(:all) do |t|
|
78
75
|
t.pattern = "test/**/*_test.rb"
|
79
76
|
end
|
80
77
|
|
@@ -83,7 +80,12 @@ namespace :test do
|
|
83
80
|
task :db => %w[db:test:prepare test:all]
|
84
81
|
end
|
85
82
|
|
86
|
-
|
83
|
+
# Display deprecation message
|
84
|
+
task :deprecated do
|
85
|
+
ActiveSupport::Deprecation.warn "`rake #{ARGV.first}` is deprecated with no replacement."
|
86
|
+
end
|
87
|
+
|
88
|
+
Rake::TestTask.new(recent: ["test:deprecated", "test:prepare"]) do |t|
|
87
89
|
since = TEST_CHANGES_SINCE
|
88
90
|
touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
|
89
91
|
recent_tests('app/models/**/*.rb', 'test/models', since) +
|
@@ -91,12 +93,11 @@ namespace :test do
|
|
91
93
|
recent_tests('app/controllers/**/*.rb', 'test/controllers', since) +
|
92
94
|
recent_tests('app/controllers/**/*.rb', 'test/functional', since)
|
93
95
|
|
94
|
-
t.libs << 'test'
|
95
96
|
t.test_files = touched.uniq
|
96
97
|
end
|
97
|
-
Rake::Task['test:recent'].comment = "Test recent changes"
|
98
|
+
Rake::Task['test:recent'].comment = "Deprecated; Test recent changes"
|
98
99
|
|
99
|
-
Rake::TestTask.new(uncommitted: "test:prepare") do |t|
|
100
|
+
Rake::TestTask.new(uncommitted: ["test:deprecated", "test:prepare"]) do |t|
|
100
101
|
def t.file_list
|
101
102
|
if File.directory?(".svn")
|
102
103
|
changed_since_checkin = silence_stderr { `svn status` }.split.map { |path| path.chomp[7 .. -1] }
|
@@ -115,47 +116,36 @@ namespace :test do
|
|
115
116
|
controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
|
116
117
|
(unit_tests + functional_tests).uniq.select { |file| File.exist?(file) }
|
117
118
|
end
|
118
|
-
|
119
|
-
t.libs << 'test'
|
120
119
|
end
|
121
|
-
Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)"
|
120
|
+
Rake::Task['test:uncommitted'].comment = "Deprecated; Test changes since last checkin (only Subversion and Git)"
|
122
121
|
|
123
|
-
|
124
|
-
t.libs << "test"
|
125
|
-
end
|
122
|
+
Rails::TestTask.new(single: "test:prepare")
|
126
123
|
|
127
|
-
Rails::
|
128
|
-
t.libs << "test"
|
124
|
+
Rails::TestTask.new(models: "test:prepare") do |t|
|
129
125
|
t.pattern = 'test/models/**/*_test.rb'
|
130
126
|
end
|
131
127
|
|
132
|
-
Rails::
|
133
|
-
t.libs << "test"
|
128
|
+
Rails::TestTask.new(helpers: "test:prepare") do |t|
|
134
129
|
t.pattern = 'test/helpers/**/*_test.rb'
|
135
130
|
end
|
136
131
|
|
137
|
-
Rails::
|
138
|
-
t.libs << "test"
|
132
|
+
Rails::TestTask.new(units: "test:prepare") do |t|
|
139
133
|
t.pattern = 'test/{models,helpers,unit}/**/*_test.rb'
|
140
134
|
end
|
141
135
|
|
142
|
-
Rails::
|
143
|
-
t.libs << "test"
|
136
|
+
Rails::TestTask.new(controllers: "test:prepare") do |t|
|
144
137
|
t.pattern = 'test/controllers/**/*_test.rb'
|
145
138
|
end
|
146
139
|
|
147
|
-
Rails::
|
148
|
-
t.libs << "test"
|
140
|
+
Rails::TestTask.new(mailers: "test:prepare") do |t|
|
149
141
|
t.pattern = 'test/mailers/**/*_test.rb'
|
150
142
|
end
|
151
143
|
|
152
|
-
Rails::
|
153
|
-
t.libs << "test"
|
144
|
+
Rails::TestTask.new(functionals: "test:prepare") do |t|
|
154
145
|
t.pattern = 'test/{controllers,mailers,functional}/**/*_test.rb'
|
155
146
|
end
|
156
147
|
|
157
|
-
Rails::
|
158
|
-
t.libs << "test"
|
148
|
+
Rails::TestTask.new(integration: "test:prepare") do |t|
|
159
149
|
t.pattern = 'test/integration/**/*_test.rb'
|
160
150
|
end
|
161
151
|
end
|