aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorbogdanvlviv <bogdanvlviv@gmail.com>2017-10-11 10:08:10 +0300
committerbogdanvlviv <bogdanvlviv@gmail.com>2017-11-06 21:29:23 +0000
commitf4af77ab5d6f5bd3b045f676978bc2a4677cee38 (patch)
tree2cce309feb91515d7fc2056a476f8019efd22bd6 /railties
parent0835527d6bb970cedd33633503506e41156ab780 (diff)
downloadrails-f4af77ab5d6f5bd3b045f676978bc2a4677cee38.tar.gz
rails-f4af77ab5d6f5bd3b045f676978bc2a4677cee38.tar.bz2
rails-f4af77ab5d6f5bd3b045f676978bc2a4677cee38.zip
Rails::Generators::Actions#execute_command allows option `capture`
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/generators/actions.rb8
-rw-r--r--railties/test/generators/actions_test.rb16
2 files changed, 23 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb
index 9800e5750a..3362bf629a 100644
--- a/railties/lib/rails/generators/actions.rb
+++ b/railties/lib/rails/generators/actions.rb
@@ -221,6 +221,7 @@ module Rails
# rake("db:migrate")
# rake("db:migrate", env: "production")
# rake("gems:install", sudo: true)
+ # rake("gems:install", capture: true)
def rake(command, options = {})
execute_command :rake, command, options
end
@@ -230,6 +231,7 @@ module Rails
# rails_command("db:migrate")
# rails_command("db:migrate", env: "production")
# rails_command("gems:install", sudo: true)
+ # rails_command("gems:install", capture: true)
def rails_command(command, options = {})
execute_command :rails, command, options
end
@@ -292,7 +294,11 @@ module Rails
log executor, command
env = options[:env] || ENV["RAILS_ENV"] || "development"
sudo = options[:sudo] && !Gem.win_platform? ? "sudo " : ""
- in_root { run("#{sudo}#{extify(executor)} #{command} RAILS_ENV=#{env}", verbose: false) }
+ config = { verbose: false }
+
+ config.merge!(capture: options[:capture]) if options[:capture]
+
+ in_root { run("#{sudo}#{extify(executor)} #{command} RAILS_ENV=#{env}", config) }
end
# Add an extension to the given name based on the platform.
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index 3ecfb4edd9..f421207025 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -308,6 +308,14 @@ class ActionsTest < Rails::Generators::TestCase
end
end
+ test "rake command with capture option should run rake command with capture" do
+ assert_called_with(generator, :run, ["rake log:clear RAILS_ENV=development", verbose: false, capture: true]) do
+ with_rails_env nil do
+ action :rake, "log:clear", capture: true
+ end
+ end
+ end
+
test "rails command should run rails_command with default env" do
assert_called_with(generator, :run, ["rails log:clear RAILS_ENV=development", verbose: false]) do
with_rails_env nil do
@@ -346,6 +354,14 @@ class ActionsTest < Rails::Generators::TestCase
end
end
+ test "rails command with capture option should run rails_command with capture" do
+ assert_called_with(generator, :run, ["rails log:clear RAILS_ENV=development", verbose: false, capture: true]) do
+ with_rails_env nil do
+ action :rails_command, "log:clear", capture: true
+ end
+ end
+ end
+
def test_capify_should_run_the_capify_command
content = capture(:stderr) do
assert_called_with(generator, :run, ["capify .", verbose: false]) do