11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/penknife/rake.rb', line 11
def self.define_plugin_tasks_for(plugin)
plugin = plugin.to_s
plugin_path = "#{RAILS_ROOT}/vendor/plugins/#{plugin}"
namespace plugin do
if Object.const_defined?(:Spec)
desc "Run #{plugin} specs"
Spec::Rake::SpecTask.new(:spec => "db:test:prepare") do |t|
t.spec_opts = ["-f n -c"]
t.spec_files = FileList["#{plugin_path}/spec/**/*_spec.rb"]
end
else
task :spec do
puts "To run specs for #{plugin} you must install rspec"
end
end
desc "#{plugin.titleize} stats"
task :stats do
require 'code_statistics'
::CodeStatistics::TEST_TYPES << "#{plugin.titleize} specs"
directories = [
[plugin.titleize + " code", "lib"],
[plugin.titleize + " specs", "spec"]
].collect { |name, dir|
[name, File.expand_path(File.join(plugin_path, dir))]}.select { |name, dir| File.directory?(dir) }
CodeStatistics.new(*directories).to_s
end
end
end
|