Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid setting fixed app name in console prompt #51732

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion railties/lib/rails/commands/console/irb_console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def start

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}> ",
Expand Down
16 changes: 16 additions & 0 deletions railties/test/application/console_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ def test_sandbox_by_default_with_development_environment
@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)
Expand Down