From 6fc8b54621f67bc618885752626937a84785bbd6 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Thu, 11 Aug 2016 20:24:48 +0900 Subject: [PATCH] add missing require rake In ff8035dfeed8c86594c32ef8e9204806e190cb58, require rake is deferred. Therefore, it is necessary to require rake even `Engine::CommandsTasks. --- railties/lib/rails/engine/commands_tasks.rb | 2 ++ railties/test/engine/commands_tasks_test.rb | 24 +++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 railties/test/engine/commands_tasks_test.rb diff --git a/railties/lib/rails/engine/commands_tasks.rb b/railties/lib/rails/engine/commands_tasks.rb index ac0861328b292..e21a7183fc549 100644 --- a/railties/lib/rails/engine/commands_tasks.rb +++ b/railties/lib/rails/engine/commands_tasks.rb @@ -103,6 +103,8 @@ def parse_command(command) end def rake_tasks + require_rake + return @rake_tasks if defined?(@rake_tasks) load_generators diff --git a/railties/test/engine/commands_tasks_test.rb b/railties/test/engine/commands_tasks_test.rb new file mode 100644 index 0000000000000..817175b9efa0e --- /dev/null +++ b/railties/test/engine/commands_tasks_test.rb @@ -0,0 +1,24 @@ +require "abstract_unit" + +class Rails::Engine::CommandsTasksTest < ActiveSupport::TestCase + def setup + @destination_root = Dir.mktmpdir("bukkits") + Dir.chdir(@destination_root) { `bundle exec rails plugin new bukkits --mountable` } + end + + def teardown + FileUtils.rm_rf(@destination_root) + end + + def test_help_command_work_inside_engine + output = capture(:stderr) do + Dir.chdir(plugin_path) { `bin/rails --help` } + end + assert_no_match "NameError", output + end + + private + def plugin_path + "#{@destination_root}/bukkits" + end +end