Skip to content

Commit

Permalink
Add test for custom prompt mode condition
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Jan 19, 2024
1 parent 5eecb2f commit eb8bf1f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions railties/test/application/console_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "tempfile"

require "isolation/abstract_unit"
require "console_helpers"

Expand Down Expand Up @@ -123,9 +125,9 @@ def write_prompt(command, expected_output = nil)
assert_output "> ", @primary
end

def spawn_console(options, wait_for_prompt: true)
def spawn_console(options, wait_for_prompt: true, env: {})
pid = Process.spawn(
{ "TERM" => "dumb" },
{ "TERM" => "dumb" }.merge(env),
"#{app_path}/bin/rails console #{options}",
in: @replica, out: @replica, err: @replica
)
Expand Down Expand Up @@ -237,4 +239,19 @@ def test_custom_env_console_prompt

write_prompt "123", "custom_env:001> 123"
end

def test_console_respects_user_defined_prompt_mode
irbrc = Tempfile.new("irbrc")
irbrc.write <<-RUBY
IRB.conf[:PROMPT_MODE] = :SIMPLE
RUBY
irbrc.close

options = "-e test -- --nocolorize"
spawn_console(options, env: { "IRBRC" => irbrc.path })

write_prompt "123", ">> 123"
ensure
File.unlink(irbrc)
end
end

0 comments on commit eb8bf1f

Please sign in to comment.