Merge pull request #51732 from Shopify/fix-rails-console-prompt

Avoid setting fixed app name in console prompt
This commit is contained in:
Carlos Antonio da Silva 2024-05-14 18:56:21 -03:00 committed by GitHub
commit 5e3611ea5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -90,7 +90,8 @@ module Rails
env = colorized_env
app_name = @app.class.module_parent_name.underscore.dasherize
prompt_prefix = "#{app_name}(#{env})"
prompt_prefix = "%N(#{env})"
IRB.conf[:IRB_NAME] = app_name
IRB.conf[:PROMPT][:RAILS_PROMPT] = {
PROMPT_I: "#{prompt_prefix}> ",

View File

@ -110,6 +110,22 @@ class FullStackConsoleTest < ActiveSupport::TestCase
@primary.puts "quit"
end
def test_prompt_is_properly_set
options = "-e test"
spawn_console(options)
write_prompt "a = 1", "a = 1", prompt: "app-template(test)>"
end
def test_prompt_allows_changing_irb_name
options = "-e test"
spawn_console(options)
write_prompt "conf.irb_name = 'foo'"
write_prompt "a = 1", "a = 1", prompt: "foo(test)>"
@primary.puts "quit"
end
def test_environment_option_and_irb_option
options = "-e test -- --verbose"
spawn_console(options)