mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
c848baffd2
895134bcff (diff-7789e18ec0a61c6845755a257e6eb34fR3)
ee9e308f68 (diff-5e9551294914b338d923032fa904c6beR103)
5f63c771f7 (diff-600d5368b55e46ed961abb4295977ac3R506)
48b6bacbc5 (diff-279ac5c088a3ee7e9f954bbc10d1b773R246)
49adb7f4c6 (diff-0cbe7171fdd7821fd5836896849141c0R111)
9bfe89e68e (diff-9c1c95b001e3680ba8a473cf23508b68R8)
a0f18e6090 (diff-bef0ae2c16dacf77bfd2ba099af8a330R47)
8b4d344815 (diff-09660f59aee7ec893ad609315e8843c5R18)
49d1b5a98d (diff-531e71a9d5fdc8181f38ce4416553694R107)
b674f04756 (diff-7521c0bb452244663b689e77658e63e3R98)
a9012af688 (diff-60bdcf1e1954ec56d41fc4c7bd8d3e39R512)
6380aee182 (diff-5158c234d5e19bb1cffadcbc088400f1R262)
c7820d8124 (diff-f4614e7ba8081c0c9e20fe64b6374228R60)
8df7ed3b88 (diff-0495ed68f82d1bbde593ab5491eab24aR169)
6f94260ac6 (diff-7ecb6672f3fd37dfb79c4539395d3857R28)
03e44f9300 (diff-e9234c4c6668852448059c0a35840bcaR185)
47 lines
1.6 KiB
Ruby
47 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "isolation/abstract_unit"
|
|
require "rails/command"
|
|
|
|
class Rails::Command::InitializersTest < ActiveSupport::TestCase
|
|
setup :build_app
|
|
teardown :teardown_app
|
|
|
|
test "`rails initializers` prints out defined initializers invoked by Rails" do
|
|
initial_output = run_initializers_command
|
|
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_initializers_command
|
|
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
|
|
|
|
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(args = [])
|
|
rails "initializers", args
|
|
end
|
|
end
|