From 5895b4a7d9571ca970b02b68b42e39eafde86fb7 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 11 Oct 2021 17:49:54 +0900 Subject: [PATCH] [ruby/reline] Add I/O test https://github.com/ruby/reline/commit/bca9b9012f --- test/reline/test_reline.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/reline/test_reline.rb b/test/reline/test_reline.rb index 717fe08ff8..b29ef77af3 100644 --- a/test/reline/test_reline.rb +++ b/test/reline/test_reline.rb @@ -1,5 +1,6 @@ require_relative 'helper' require 'reline' +require 'stringio' class Reline::Test < Reline::TestCase class DummyCallbackObject @@ -272,18 +273,21 @@ class Reline::Test < Reline::TestCase assert_equal(5, Reline.point) end - def test_input= - # TODO + def test_set_input_and_output assert_raise(TypeError) do Reline.input = "This is not a file." end - end - - def test_output= - # TODO assert_raise(TypeError) do Reline.output = "This is not a file." end + Reline.input, to_write = IO.pipe + to_read, Reline.output = IO.pipe + to_write.write "a\n" + result = Reline.readline + to_write.close + read_text = to_read.read_nonblock(100) + assert_equal('a', result) + refute(read_text.empty?) end def test_vi_editing_mode