Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/binding/fixtures/irbrc

This file was deleted.

12 changes: 10 additions & 2 deletions core/binding/irb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
require_relative '../../spec_helper'

describe "Binding#irb" do
before :each do
@env_home = ENV["HOME"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@env_home = ENV["HOME"]
@envs = ["IRBRC", "XDG_CONFIG_HOME", "HOME"].map {|e| [e, ENV.delete(e)]}.to_h

ENV["HOME"] = CODE_LOADING_DIR
end

after :each do
ENV["HOME"] = @env_home
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ENV["HOME"] = @env_home
ENV.update(@envs)

end

it "creates an IRB session with the binding in scope" do
irb_fixture = fixture __FILE__, "irb.rb"
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|
Copy link
Member

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?

Suggested change
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|

pipe.puts "a ** 2"
pipe.puts "exit"
pipe.readlines.map(&:chomp)
Expand Down