From 102352e205b58a2d8462690034a99d71f4992da8 Mon Sep 17 00:00:00 2001 From: Vikhyat Korrapati Date: Sun, 2 Feb 2014 01:52:53 +0530 Subject: [PATCH] Add rake task for running plugin tests. --- config/application.rb | 2 +- lib/tasks/plugin.rake | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index d17b9eee44b..0c0b401f8fd 100644 --- a/config/application.rb +++ b/config/application.rb @@ -157,7 +157,7 @@ module Discourse config.active_record.whitelist_attributes = false unless rails4? require 'auth' - Discourse.activate_plugins! unless Rails.env.test? + Discourse.activate_plugins! unless Rails.env.test? and ENV['LOAD_PLUGINS'] != "true" config.after_initialize do # So open id logs somewhere sane diff --git a/lib/tasks/plugin.rake b/lib/tasks/plugin.rake index 116f82989d5..e3a46100930 100644 --- a/lib/tasks/plugin.rake +++ b/lib/tasks/plugin.rake @@ -42,3 +42,15 @@ task 'plugin:update', :plugin do |t, args| update_status = system('git --git-dir "' + plugin_path + '/.git" --work-tree "' + plugin_path + '" pull') abort('Unable to pull latest version of plugin') unless update_status end + +desc 'run plugin specs' +task 'plugin:spec', :plugin do |t, args| + args.with_defaults(plugin: "**") + ruby = `which ruby`.strip + files = Dir.glob("./plugins/#{args[:plugin]}/spec/*.rb") + if files.length > 0 + sh "LOAD_PLUGINS=true #{ruby} -S rspec #{files.join(' ')}" + else + abort "No specs found." + end +end