From c4bbce969779179457218558be7554b4ee4b3230 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sun, 8 Oct 2017 13:09:30 +0900 Subject: [PATCH] Simplify parse arguments in `ConsoleTest` If need a parse result of arguments, can obtain it by creating an instance of the command. --- railties/test/commands/console_test.rb | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/railties/test/commands/console_test.rb b/railties/test/commands/console_test.rb index 7eb26c355c..45ab8d87ff 100644 --- a/railties/test/commands/console_test.rb +++ b/railties/test/commands/console_test.rb @@ -172,21 +172,8 @@ class Rails::ConsoleTest < ActiveSupport::TestCase end def parse_arguments(args) - Rails::Command::ConsoleCommand.class_eval do - alias_method :old_perform, :perform - define_method(:perform) do - extract_environment_option_from_argument - - options - end - end - - Rails::Command.invoke(:console, args) - ensure - Rails::Command::ConsoleCommand.class_eval do - undef_method :perform - alias_method :perform, :old_perform - undef_method :old_perform - end + command = Rails::Command::ConsoleCommand.new([], args) + command.send(:extract_environment_option_from_argument) + command.options end end