1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Simplify parse arguments in ConsoleTest

If need a parse result of arguments, can obtain it by creating
an instance of the command.
This commit is contained in:
yuuji.yaginuma 2017-10-08 13:09:30 +09:00
parent 142831159c
commit c4bbce9697

View file

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