-
-
Notifications
You must be signed in to change notification settings - Fork 395
Improve irb_spec's home setup #1141
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
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 |
|
|
||
| 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) |
| irbrc_fixture = fixture __FILE__, "irbrc" | ||
|
|
||
| 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
~/.irbrcif the project folder has a.irbrcfile. So to avoid loading dev's~/.irbrc, cfe908c added an empty irbrc fixture as a workaround.However, because IRB v1.12 starts loading
~/.irbrceven if the project folder has a.irbrcfile, the workaround no longer works.This commit removes the workaround and uses altering
HOMEenvironment variable to avoid loading.irbrcfrom devs' home directory instead.