diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2018-08-19 19:38:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-19 19:38:17 +0200 |
commit | cc14bf77ca31b6873756fad5b4c1324fb6663fe1 (patch) | |
tree | 2c596738e481fdea4e31750e90d7011488d64d36 /railties/test/application/rake | |
parent | 3c6d2ec46e5593712fea6b9605e0e97cb2f90ed4 (diff) | |
parent | 0d3b5fc0f5e1a208d0666985f68ed6418ba7e8b4 (diff) | |
download | rails-cc14bf77ca31b6873756fad5b4c1324fb6663fe1.tar.gz rails-cc14bf77ca31b6873756fad5b4c1324fb6663fe1.tar.bz2 rails-cc14bf77ca31b6873756fad5b4c1324fb6663fe1.zip |
Merge pull request #33631 from anniecodes/initializers-command
Move the initializers rake task to Rails::Command
Diffstat (limited to 'railties/test/application/rake')
-rw-r--r-- | railties/test/application/rake/initializers_test.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/railties/test/application/rake/initializers_test.rb b/railties/test/application/rake/initializers_test.rb new file mode 100644 index 0000000000..fb498e28ad --- /dev/null +++ b/railties/test/application/rake/initializers_test.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require "isolation/abstract_unit" + +module ApplicationTests + module RakeTests + class RakeInitializersTest < ActiveSupport::TestCase + setup :build_app + teardown :teardown_app + + test "`rake initializers` prints out defined initializers invoked by Rails" do + capture(:stderr) do + initial_output = run_rake_initializers + initial_output_length = initial_output.split("\n").length + + assert_operator initial_output_length, :>, 0 + assert_not initial_output.include?("set_added_test_module") + + add_to_config <<-RUBY + initializer(:set_added_test_module) { } + RUBY + + final_output = run_rake_initializers + final_output_length = final_output.split("\n").length + + assert_equal 1, (final_output_length - initial_output_length) + assert final_output.include?("set_added_test_module") + end + end + + test "`rake initializers` outputs a deprecation warning" do + stderr = capture(:stderr) { run_rake_initializers } + assert_match(/DEPRECATION WARNING: Using `bin\/rake initializers` is deprecated and will be removed in Rails 6.1/, stderr) + end + + private + def run_rake_initializers + Dir.chdir(app_path) { `bin/rake initializers` } + end + end + end +end |