From 824246f66b21c89d4a646a3cb73e46134d97469d Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sun, 12 Jul 2015 17:51:35 +0900 Subject: make test runner work correctly inside engine --- railties/lib/rails/commands/test.rb | 6 +++++- railties/lib/rails/engine/commands.rb | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/commands/test.rb b/railties/lib/rails/commands/test.rb index fe5307788a..dd069f081f 100644 --- a/railties/lib/rails/commands/test.rb +++ b/railties/lib/rails/commands/test.rb @@ -1,5 +1,9 @@ require "rails/test_unit/minitest_plugin" -$: << File.expand_path("../../test", APP_PATH) +if defined?(ENGINE_ROOT) + $: << File.expand_path('test', ENGINE_ROOT) +else + $: << File.expand_path('../../test', APP_PATH) +end exit Minitest.run(ARGV) diff --git a/railties/lib/rails/engine/commands.rb b/railties/lib/rails/engine/commands.rb index f39f926109..a6d87b78e4 100644 --- a/railties/lib/rails/engine/commands.rb +++ b/railties/lib/rails/engine/commands.rb @@ -2,7 +2,8 @@ ARGV << '--help' if ARGV.empty? aliases = { "g" => "generate", - "d" => "destroy" + "d" => "destroy", + "t" => "test" } command = ARGV.shift @@ -12,7 +13,7 @@ require ENGINE_PATH engine = ::Rails::Engine.find(ENGINE_ROOT) case command -when 'generate', 'destroy' +when 'generate', 'destroy', 'test' require 'rails/generators' Rails::Generators.namespace = engine.railtie_namespace engine.load_generators @@ -30,6 +31,7 @@ Usage: rails COMMAND [ARGS] The common Rails commands available for engines are: generate Generate new code (short-cut alias: "g") destroy Undo code generated with "generate" (short-cut alias: "d") + test Run tests (short-cut alias: "t") All commands can be run with -h for more information. -- cgit v1.2.3