From d10752890f96fe84e79cc2b3c9d25f82d99f82ee Mon Sep 17 00:00:00 2001 From: ratovia Date: Tue, 13 Apr 2021 10:00:16 +0900 Subject: [PATCH] change-comment-inject_into --- lib/thor/actions/file_manipulation.rb | 8 ++++---- spec/actions/file_manipulation_spec.rb | 15 ++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/thor/actions/file_manipulation.rb b/lib/thor/actions/file_manipulation.rb index 24c28183..e6c720fd 100644 --- a/lib/thor/actions/file_manipulation.rb +++ b/lib/thor/actions/file_manipulation.rb @@ -210,9 +210,9 @@ def append_to_file(path, *args, &block) # # ==== Examples # - # inject_into_class "app/controllers/application_controller.rb", ApplicationController, " filter_parameter :password\n" + # inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " filter_parameter :password\n" # - # inject_into_class "app/controllers/application_controller.rb", ApplicationController do + # inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do # " filter_parameter :password\n" # end # @@ -233,9 +233,9 @@ def inject_into_class(path, klass, *args, &block) # # ==== Examples # - # inject_into_module "app/helpers/application_helper.rb", ApplicationHelper, " def help; 'help'; end\n" + # inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper", " def help; 'help'; end\n" # - # inject_into_module "app/helpers/application_helper.rb", ApplicationHelper do + # inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper" do # " def help; 'help'; end\n" # end # diff --git a/spec/actions/file_manipulation_spec.rb b/spec/actions/file_manipulation_spec.rb index 3e6db77e..8d954199 100644 --- a/spec/actions/file_manipulation_spec.rb +++ b/spec/actions/file_manipulation_spec.rb @@ -1,8 +1,5 @@ require "helper" -class Application; end -module ApplicationHelper; end - describe Thor::Actions do def runner(options = {}, behavior = :invoke) @runner ||= MyCounter.new([1], options, :destination_root => destination_root, :behavior => behavior) @@ -407,17 +404,17 @@ def file end it "appends content to a class" do - action :inject_into_class, "application.rb", Application, " filter_parameters :password\n" + action :inject_into_class, "application.rb", "Application", " filter_parameters :password\n" expect(File.binread(file)).to eq("class Application < Base\n filter_parameters :password\nend\n") end it "accepts a block" do - action(:inject_into_class, "application.rb", Application) { " filter_parameters :password\n" } + action(:inject_into_class, "application.rb", "Application") { " filter_parameters :password\n" } expect(File.binread(file)).to eq("class Application < Base\n filter_parameters :password\nend\n") end it "logs status" do - expect(action(:inject_into_class, "application.rb", Application, " filter_parameters :password\n")).to eq(" insert application.rb\n") + expect(action(:inject_into_class, "application.rb", "Application", " filter_parameters :password\n")).to eq(" insert application.rb\n") end it "does not append if class name does not match" do @@ -432,17 +429,17 @@ def file end it "appends content to a module" do - action :inject_into_module, "application_helper.rb", ApplicationHelper, " def help; 'help'; end\n" + action :inject_into_module, "application_helper.rb", "ApplicationHelper", " def help; 'help'; end\n" expect(File.binread(file)).to eq("module ApplicationHelper\n def help; 'help'; end\nend\n") end it "accepts a block" do - action(:inject_into_module, "application_helper.rb", ApplicationHelper) { " def help; 'help'; end\n" } + action(:inject_into_module, "application_helper.rb", "ApplicationHelper") { " def help; 'help'; end\n" } expect(File.binread(file)).to eq("module ApplicationHelper\n def help; 'help'; end\nend\n") end it "logs status" do - expect(action(:inject_into_module, "application_helper.rb", ApplicationHelper, " def help; 'help'; end\n")).to eq(" insert application_helper.rb\n") + expect(action(:inject_into_module, "application_helper.rb", "ApplicationHelper", " def help; 'help'; end\n")).to eq(" insert application_helper.rb\n") end it "does not append if module name does not match" do