- created rake task to run plugin specs - added config variable where plugins can register for tests - added after(:suite) block in spec_helper to check for wrong used before(:all)pull/62/head
parent
ba7fbab69e
commit
bd779b4f82
@ -0,0 +1,36 @@ |
||||
# This task will run all plugin specs separated by plugin. |
||||
# A plugin must register for tests via config variable 'plugins_to_test_paths' |
||||
# |
||||
# e.g. |
||||
# class Engine < ::Rails::Engine |
||||
# initializer 'register_path_to_rspec' do |app| |
||||
# app.config.plugins_to_test_paths << self.root |
||||
# end |
||||
# end |
||||
# |
||||
|
||||
desc "Run plugin tests" |
||||
namespace :openproject do |
||||
namespace :plugins do |
||||
namespace :test do |
||||
desc "Run specs for all test registered plugins" |
||||
task :rspec => :environment do |
||||
get_plugins_to_test.each do |plugin_path| |
||||
puts "run specs for #{plugin_path.split('/').last} plugin" |
||||
ENV['SPEC'] = "#{plugin_path}/spec/" |
||||
Rake::Task["spec"].execute |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
def get_plugins_to_test |
||||
plugin_paths = [] |
||||
Rails.application.config.plugins_to_test_paths.each do |dir| |
||||
if File.directory?( dir ) |
||||
plugin_paths << File.join(dir).to_s |
||||
end |
||||
end |
||||
plugin_paths |
||||
end |
Loading…
Reference in new issue