Skip to content

Commit

Permalink
Merge pull request rails#38083 from y-yagi/fix_console_test_in_ruby_27
Browse files Browse the repository at this point in the history
Use the single line editor in console test
  • Loading branch information
y-yagi authored Dec 24, 2019
2 parents c10f4d1 + c8b88dd commit 1421ad5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions railties/test/application/console_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,16 @@ def spawn_console(options, wait_for_prompt: true)
end

def test_sandbox
spawn_console("--sandbox")
options = "--sandbox"
options += " -- --singleline --nocolorize" if RUBY_VERSION >= "2.7"
spawn_console(options)

write_prompt "Post.count", "=> 0"
write_prompt "Post.create"
write_prompt "Post.count", "=> 1"
@primary.puts "quit"

spawn_console("--sandbox")
spawn_console(options)

write_prompt "Post.count", "=> 0"
write_prompt "Post.transaction { Post.create; raise }"
Expand All @@ -164,7 +166,9 @@ def test_sandbox_when_sandbox_is_disabled
end

def test_environment_option_and_irb_option
spawn_console("-e test -- --verbose")
options = "-e test -- --verbose"
options += " --singleline --nocolorize" if RUBY_VERSION >= "2.7"
spawn_console(options)

write_prompt "a = 1", "a = 1"
write_prompt "puts Rails.env", "puts Rails.env\r\ntest"
Expand Down
4 changes: 3 additions & 1 deletion railties/test/engine/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def test_console_command_work_inside_engine
skip "PTY unavailable" unless available_pty?

primary, replica = PTY.open
spawn_command("console", replica)
cmd = "console"
cmd += " --singleline" if RUBY_VERSION >= "2.7"
spawn_command(cmd, replica)
assert_output(">", primary)
ensure
primary.puts "quit"
Expand Down

0 comments on commit 1421ad5

Please sign in to comment.