Skip to content

Commit 0af962b

Browse files
zzakst0012
andcommitted
Avoid running console tests against users IRB config
For example if you add this to your `~/.irbrc`: ``` IRB.conf[:PROMPT_MODE] = :SIMPLE ``` This will result in the following test failures: ``` F Failure: FullStackConsoleTest#test_prompt_allows_changing_irb_name [test/application/console_test.rb:32]: "foo(test)>" expected, but got: >> a = 1 a = 1 => ... >> . Expected ">> a = 1\r\r\na = 1\r\n=> ...\r\n>> " to include "foo(test)>". bin/test test/application/console_test.rb:120 .............F Failure: FullStackConsoleTest#test_test_console_prompt [test/application/console_test.rb:32]: "app-template(test)> " expected, but got: 112123>> 123 => 123 >> . Expected "\r\n112123>> 123\r\r\n=> 123\r\n>> " to include "app-template(test)> ". bin/test test/application/console_test.rb:152 ...F Failure: FullStackConsoleTest#test_prompt_is_properly_set [test/application/console_test.rb:32]: "app-template(test)>" expected, but got: >> a = 1 a = 1 => ... >> . Expected ">> a = 1\r\r\na = 1\r\n=> ...\r\n>> " to include "app-template(test)>". bin/test test/application/console_test.rb:113 F Failure: FullStackConsoleTest#test_production_console_prompt [test/application/console_test.rb:32]: "app-template(prod)>" expected, but got: 112123>> 123 => 123 >> . Expected "\r\n112123>> 123\r\r\n=> 123\r\n>> " to include "app-template(prod)>". bin/test test/application/console_test.rb:138 ...F Failure: FullStackConsoleTest#test_development_console_prompt [test/application/console_test.rb:32]: "app-template(dev)> " expected, but got: 112123>> 123 => 123 >> . Expected "\r\n112123>> 123\r\r\n=> 123\r\n>> " to include "app-template(dev)> ". bin/test test/application/console_test.rb:145 Finished in 137.655994s, 0.1743 runs/s, 1.8815 assertions/s. 24 runs, 259 assertions, 5 failures, 0 errors, 0 skips ``` Co-authored-by: Stan Lo <[email protected]>
1 parent bc727a0 commit 0af962b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

railties/test/application/console_test.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ def write_prompt(command, expected_output = nil, prompt: "> ")
3333
end
3434

3535
def spawn_console(options, wait_for_prompt: true, env: {})
36+
# Test should not depend on user's irbrc file
37+
home_tmp_dir = Dir.mktmpdir
38+
3639
pid = Process.spawn(
37-
{ "TERM" => "dumb" }.merge(env),
40+
{ "TERM" => "dumb", "HOME" => home_tmp_dir }.merge(env),
3841
"#{app_path}/bin/rails console #{options}",
3942
in: @replica, out: @replica, err: @replica
4043
)
@@ -44,6 +47,8 @@ def spawn_console(options, wait_for_prompt: true, env: {})
4447
end
4548

4649
pid
50+
ensure
51+
FileUtils.remove_entry(home_tmp_dir)
4752
end
4853

4954
def test_sandbox

0 commit comments

Comments
 (0)