From 7a654475d8a850b0c30e8f36000585246a451042 Mon Sep 17 00:00:00 2001 From: Herwin Date: Sat, 2 Sep 2023 11:25:33 +0200 Subject: [PATCH] Check for read access in IO#getbyte spec --- core/io/getbyte_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/io/getbyte_spec.rb b/core/io/getbyte_spec.rb index 6ba8f0a3e0..b4351160e6 100644 --- a/core/io/getbyte_spec.rb +++ b/core/io/getbyte_spec.rb @@ -40,3 +40,19 @@ @io.getbyte.should == nil end end + +describe "IO#getbyte" do + before :each do + @name = tmp("io_getbyte.txt") + @io = new_io(@name, 'w') + end + + after :each do + @io.close if @io + rm_r @name if @name + end + + it "raises an IOError if the stream is not readable" do + -> { @io.getbyte }.should raise_error(IOError) + end +end