diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-03-16 09:57:12 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-03-16 10:02:06 +0900 |
commit | 6f94260ac67755fbc4d89e7dd9ba6be04abfa9e7 (patch) | |
tree | ff5638bfc76958caad9298b2866241ef82be7980 /railties/test/commands | |
parent | a47c84d584777238a6955e3a08436577c471af0f (diff) | |
download | rails-6f94260ac67755fbc4d89e7dd9ba6be04abfa9e7.tar.gz rails-6f94260ac67755fbc4d89e7dd9ba6be04abfa9e7.tar.bz2 rails-6f94260ac67755fbc4d89e7dd9ba6be04abfa9e7.zip |
Add -e/--environment option to `rails initializers`
This allows specifying the environment as would any other rails commands.
Diffstat (limited to 'railties/test/commands')
-rw-r--r-- | railties/test/commands/initializers_test.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/railties/test/commands/initializers_test.rb b/railties/test/commands/initializers_test.rb index bdfbb3021c..793365ef3d 100644 --- a/railties/test/commands/initializers_test.rb +++ b/railties/test/commands/initializers_test.rb @@ -25,8 +25,24 @@ class Rails::Command::InitializersTest < ActiveSupport::TestCase assert final_output.include?("set_added_test_module") end + + test "prints out initializers only specified in environment option" do + add_to_config <<-RUBY + initializer(:set_added_development_module) { } if Rails.env.development? + initializer(:set_added_production_module) { } if Rails.env.production? + RUBY + + output = run_initializers_command.split("\n") + assert_includes output, "AppTemplate::Application.set_added_development_module" + assert_not_includes output, "AppTemplate::Application.set_added_production_module" + + output = run_initializers_command(["-e", "production"]).split("\n") + assert_not_includes output, "AppTemplate::Application.set_added_development_module" + assert_includes output, "AppTemplate::Application.set_added_production_module" + end + private - def run_initializers_command - rails "initializers" + def run_initializers_command(args = []) + rails "initializers", args end end |