diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-10-20 21:21:14 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-11-02 17:14:50 +0100 |
commit | b36fa51a3f56431d8e46c1fff6a6493d3c10607a (patch) | |
tree | a446299bd74918c0942b64a38b5f74404eccb94d /railties/lib | |
parent | fd1562af8c662fee8a44d244eaed3350ce10e7da (diff) | |
download | rails-b36fa51a3f56431d8e46c1fff6a6493d3c10607a.tar.gz rails-b36fa51a3f56431d8e46c1fff6a6493d3c10607a.tar.bz2 rails-b36fa51a3f56431d8e46c1fff6a6493d3c10607a.zip |
Allow easy overriding of test framework in 'rake plugin new' generator, using PluginBuilder
Diffstat (limited to 'railties/lib')
3 files changed, 32 insertions, 16 deletions
diff --git a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb index 3c710b8908..6067c5d87e 100644 --- a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +++ b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb @@ -35,7 +35,7 @@ module Rails directory "test" end - def test_dummy + def generate_test_dummy invoke Rails::Generators::AppGenerator, [ File.expand_path(dummy_path, destination_root) ], {} end @@ -68,6 +68,27 @@ module Rails end chmod "script", 0755, :verbose => false end + + def rakefile_test_tasks + <<-RUBY +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + RUBY + end + + def dummy_path + "#{test_path}/dummy" + end + + def test_path + "test" + end end module Generators @@ -141,7 +162,7 @@ module Rails say_step "Vendoring Rails application at test/dummy" def create_test_dummy_files - build(:test_dummy) + build(:generate_test_dummy) end say_step "Configuring Rails application" @@ -192,10 +213,6 @@ module Rails end end - def dummy_path - "test/dummy" - end - def application_definition @application_definition ||= begin unless options[:pretend] @@ -209,6 +226,12 @@ module Rails def get_builder_class defined?(::PluginBuilder) ? ::PluginBuilder : Rails::PluginBuilder end + + [:test_path, :dummy_path, :rakefile_test_tasks].each do |name| + define_method name do + builder.send(name) if builder.respond_to?(name) + end + end end end end diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile index c0e6185ddc..af5f672396 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile +++ b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile @@ -10,16 +10,9 @@ require 'rake' require 'rake/rdoctask' require 'rake/gempackagetask' -require 'rake/testtask' +<%= rakefile_test_tasks %> -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' - t.verbose = false -end - -task :default => :test +task :default => :<%= test_path %> Rake::RDocTask.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/script/rails.tt b/railties/lib/rails/generators/rails/plugin_new/templates/script/rails.tt index cd4f7f6ab3..91d9cf079d 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +++ b/railties/lib/rails/generators/rails/plugin_new/templates/script/rails.tt @@ -2,4 +2,4 @@ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. ENGINE_PATH = File.expand_path('../..', __FILE__) -load File.expand_path('../../test/dummy/script/rails', __FILE__) +load File.expand_path('../../<%= test_path %>/dummy/script/rails', __FILE__) |