diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-10-28 20:28:09 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-10-28 20:28:09 +0000 |
commit | 927b847239ede8cb455366b95e640a25d92a2b8e (patch) | |
tree | d2876cae56fa8c82837b454408c7ce4edd59ab74 /railties | |
parent | fd1d6d0eb32aef7443acb75fc020a72379718f14 (diff) | |
download | rails-927b847239ede8cb455366b95e640a25d92a2b8e.tar.gz rails-927b847239ede8cb455366b95e640a25d92a2b8e.tar.bz2 rails-927b847239ede8cb455366b95e640a25d92a2b8e.zip |
Add Rakefile to plugin generator. Let test_plugins rake task look deeper into plugins' test dirs. Make plugin test cases flunk by default.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2790 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
5 files changed, 46 insertions, 16 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index a1ec0a123c..ac9e96d7fe 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added Rakefile to plugin generator. [Jeremy Kemper] + * Added test_plugins task: Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name) [DHH] * Added default lighttpd config in config/lighttpd.conf and added a default runner for lighttpd in script/lighttpd (works like script/server, but using lighttpd and FastCGI) [DHH] diff --git a/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb b/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb index 2db7f98f8d..d43a8df03f 100644 --- a/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb +++ b/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb @@ -1,17 +1,23 @@ class PluginGenerator < Rails::Generator::NamedBase + attr_reader :plugin_path + + def initialize(*args) + super + @plugin_path = "vendor/plugins/#{file_name}" + end + def manifest record do |m| - m.directory File.join('vendor', 'plugins', file_name) - m.directory File.join('vendor', 'plugins', file_name, 'lib') - m.directory File.join('vendor', 'plugins', file_name, 'test') - m.directory File.join('vendor', 'plugins', file_name, 'tasks') - - m.template 'plugin.rb', File.join('vendor', 'plugins', file_name, 'lib', "#{file_name}.rb") - m.template 'unit_test.rb', File.join('vendor', 'plugins', file_name, 'test', "#{file_name}_test.rb") + m.directory "#{plugin_path}/lib" + m.directory "#{plugin_path}/tasks" + m.directory "#{plugin_path}/test" - m.template 'init.rb', File.join('vendor', 'plugins', file_name, 'init.rb') - m.template 'tasks.rake', File.join('vendor', 'plugins', file_name, 'tasks', "#{file_name}_tasks.rake") - m.template 'README', File.join('vendor', 'plugins', file_name, 'README') + m.template 'README', "#{plugin_path}/README" + m.template 'Rakefile', "#{plugin_path}/Rakefile" + m.template 'init.rb', "#{plugin_path}/init.rb" + m.template 'plugin.rb', "#{plugin_path}/lib/#{file_name}.rb" + m.template 'tasks.rake', "#{plugin_path}/tasks/#{file_name}_tasks.rake" + m.template 'unit_test.rb', "#{plugin_path}/test/#{file_name}_test.rb" end end end diff --git a/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile b/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile new file mode 100755 index 0000000000..069105081a --- /dev/null +++ b/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile @@ -0,0 +1,22 @@ +require 'rake' +require 'rake/testtask' +require 'rake/rdoctask' + +desc 'Default: run unit tests.' +task :default => :test + +desc 'Test the <%= file_name %> plugin.' +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.pattern = 'test/**/*_test.rb' + t.verbose = true +end + +desc 'Generate documentation for the <%= file_name %> plugin.' +Rake::RDocTask.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = '<%= class_name %>' + rdoc.options << '--line-numbers --inline-source' + rdoc.rdoc_files.include('README') + rdoc.rdoc_files.include('lib/**/*.rb') +end diff --git a/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb b/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb index 8491d2e3ae..9028b84b7d 100644 --- a/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +++ b/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb @@ -2,7 +2,7 @@ require 'test/unit' class <%= class_name %>Test < Test::Unit::TestCase # Replace this with your real tests. - def test_truth - assert true + def test_this_plugin + flunk end end diff --git a/railties/lib/tasks/testing.rake b/railties/lib/tasks/testing.rake index a62ed1d2b0..5792f063ac 100644 --- a/railties/lib/tasks/testing.rake +++ b/railties/lib/tasks/testing.rake @@ -37,14 +37,14 @@ Rake::TestTask.new(:test_functional => [ :prepare_test_database ]) do |t| end desc "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)" -Rake::TestTask.new(:test_plugins => [ :prepare_test_database ]) do |t| +Rake::TestTask.new(:test_plugins => :environment) do |t| t.libs << "test" if ENV['PLUGIN'] - t.pattern = "vendor/plugins/#{ENV['PLUGIN']}/test/*_test.rb" + t.pattern = "vendor/plugins/#{ENV['PLUGIN']}/test/**/*_test.rb" else - t.pattern = 'vendor/plugins/**/test/*_test.rb' + t.pattern = 'vendor/plugins/**/test/**/*_test.rb' end t.verbose = true -end
\ No newline at end of file +end |