diff --git a/railties/lib/rails/commands/console/irb_console.rb b/railties/lib/rails/commands/console/irb_console.rb index b7854bf4364..14c7cf908e3 100644 --- a/railties/lib/rails/commands/console/irb_console.rb +++ b/railties/lib/rails/commands/console/irb_console.rb @@ -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}> ", diff --git a/railties/test/application/console_test.rb b/railties/test/application/console_test.rb index ed2b227f0a5..75519032f92 100644 --- a/railties/test/application/console_test.rb +++ b/railties/test/application/console_test.rb @@ -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)