2019-03-28 14:22:29 +00:00
|
|
|
require_relative '../../spec_helper'
|
|
|
|
|
2020-02-08 19:43:27 +09:00
|
|
|
describe "Binding#irb" do
|
|
|
|
it "creates an IRB session with the binding in scope" do
|
|
|
|
irb_fixture = fixture __FILE__, "irb.rb"
|
|
|
|
irbrc_fixture = fixture __FILE__, "irbrc"
|
2019-03-28 14:22:29 +00:00
|
|
|
|
2020-02-08 19:43:27 +09:00
|
|
|
out = IO.popen([{"IRBRC"=>irbrc_fixture}, *ruby_exe, irb_fixture], "r+") do |pipe|
|
|
|
|
pipe.puts "a ** 2"
|
|
|
|
pipe.puts "exit"
|
|
|
|
pipe.readlines.map(&:chomp)
|
2019-03-28 14:22:29 +00:00
|
|
|
end
|
2020-02-08 19:43:27 +09:00
|
|
|
|
|
|
|
out[-3..-1].should == ["a ** 2", "100", "exit"]
|
2019-03-28 14:22:29 +00:00
|
|
|
end
|
|
|
|
end
|