-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
Improve irb_spec's home setup #1141
base: master
Are you sure you want to change the base?
Conversation
Before v1.12, IRB avoids loading `~/.irbrc` if the project folder has a `.irbrc` file. So to avoid loading dev's `~/.irbrc`, cfe908c added an empty irbrc fixture as a workaround. However, because IRB v1.12 starts loading `~/.irbrc` even if the project folder has a `.irbrc` file, the workaround no longer works. This commit removes the workaround and uses altering `HOME` environment variable to avoid loading `.irbrc` from devs' home directory instead.
Don't |
@@ -1,11 +1,19 @@ | |||
require_relative '../../spec_helper' | |||
|
|||
describe "Binding#irb" do | |||
before :each do | |||
@env_home = ENV["HOME"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@env_home = ENV["HOME"] | |
@envs = ["IRBRC", "XDG_CONFIG_HOME", "HOME"].map {|e| [e, ENV.delete(e)]}.to_h |
end | ||
|
||
after :each do | ||
ENV["HOME"] = @env_home |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENV["HOME"] = @env_home | |
ENV.update(@envs) |
|
||
out = IO.popen([{"IRBRC"=>irbrc_fixture}, *ruby_exe, irb_fixture], "r+") do |pipe| | ||
out = IO.popen([*ruby_exe, irb_fixture], "r+") do |pipe| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather how about to change states only in the IO.popen
-ed process?
out = IO.popen([*ruby_exe, irb_fixture], "r+") do |pipe| | |
dir = CODE_LOADING_DIR | |
envs = {"IRBRC" => nil, "XDG_CONFIG_HOME" => nil, "HOME" => dir} | |
out = IO.popen([envs, *ruby_exe, irb_fixture, chdir: dir], "r+") do |pipe| |
Could we use irb's |
Before v1.12, IRB avoids loading
~/.irbrc
if the project folder has a.irbrc
file. So to avoid loading dev's~/.irbrc
, cfe908c added an empty irbrc fixture as a workaround.However, because IRB v1.12 starts loading
~/.irbrc
even if the project folder has a.irbrc
file, the workaround no longer works.This commit removes the workaround and uses altering
HOME
environment variable to avoid loading.irbrc
from devs' home directory instead.