Permalink
Browse files

Add Rakefile to plugin generator. Let test_plugins rake task look dee…

…per 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
  • Loading branch information...
1 parent fd1d6d0 commit 927b847239ede8cb455366b95e640a25d92a2b8e @jeremy jeremy committed Oct 28, 2005
View
@@ -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]
@@ -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
@@ -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
@@ -2,7 +2,7 @@
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
@@ -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
+end

0 comments on commit 927b847

Please sign in to comment.