Merge pull request #62 from opf/feature/plugin_test_from_core

enable testing plugins from OpenProject core
pull/64/head
ulferts 12 years ago
commit 7bbe80adf7
  1. 3
      config/application.rb
  2. 36
      lib/tasks/plugin_tests.rake
  3. 6
      spec/spec_helper.rb

@ -72,6 +72,9 @@ module OpenProject
# Version of your assets, change this if you want to expire all your assets # Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0' config.assets.version = '1.0'
# initialize variable for register plugin tests
config.plugins_to_test_paths = []
end end
def self.preload_circular_dependencies def self.preload_circular_dependencies

@ -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

@ -81,6 +81,12 @@ Spork.prefork do
config.treat_symbols_as_metadata_keys_with_true_values = true config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true config.run_all_when_everything_filtered = true
config.after(:suite) do
[User, Project, Issue].each do |cls|
raise "your specs leave a #{cls} in the DB\ndid you use before(:all) instead of before or forget to kill the instances in a after(:all)?" if cls.count > 0
end
end
end end
end end

Loading…
Cancel
Save