diff options
Diffstat (limited to 'spec/ruby/core/io')
65 files changed, 230 insertions, 191 deletions
diff --git a/spec/ruby/core/io/advise_spec.rb b/spec/ruby/core/io/advise_spec.rb index 81d5a49849..59469fa164 100644 --- a/spec/ruby/core/io/advise_spec.rb +++ b/spec/ruby/core/io/advise_spec.rb @@ -12,37 +12,37 @@ describe "IO#advise" do end it "raises a TypeError if advise is not a Symbol" do - lambda { + -> { @io.advise("normal") }.should raise_error(TypeError) end it "raises a TypeError if offset cannot be coerced to an Integer" do - lambda { + -> { @io.advise(:normal, "wat") }.should raise_error(TypeError) end it "raises a TypeError if len cannot be coerced to an Integer" do - lambda { + -> { @io.advise(:normal, 0, "wat") }.should raise_error(TypeError) end it "raises a RangeError if offset is too big" do - lambda { + -> { @io.advise(:normal, 10 ** 32) }.should raise_error(RangeError) end it "raises a RangeError if len is too big" do - lambda { + -> { @io.advise(:normal, 0, 10 ** 32) }.should raise_error(RangeError) end it "raises a NotImplementedError if advise is not recognized" do - lambda{ + ->{ @io.advise(:foo) }.should raise_error(NotImplementedError) end @@ -92,6 +92,6 @@ describe "IO#advise" do it "raises an IOError if the stream is closed" do @io.close - lambda { @io.advise(:normal) }.should raise_error(IOError) + -> { @io.advise(:normal) }.should raise_error(IOError) end end diff --git a/spec/ruby/core/io/binmode_spec.rb b/spec/ruby/core/io/binmode_spec.rb index cc10e297dd..b698777cad 100644 --- a/spec/ruby/core/io/binmode_spec.rb +++ b/spec/ruby/core/io/binmode_spec.rb @@ -17,7 +17,7 @@ describe "IO#binmode" do end it "raises an IOError on closed stream" do - lambda { IOSpecs.closed_io.binmode }.should raise_error(IOError) + -> { IOSpecs.closed_io.binmode }.should raise_error(IOError) end it "sets external encoding to binary" do diff --git a/spec/ruby/core/io/binread_spec.rb b/spec/ruby/core/io/binread_spec.rb index 961044da58..a3f752d8f9 100644 --- a/spec/ruby/core/io/binread_spec.rb +++ b/spec/ruby/core/io/binread_spec.rb @@ -38,10 +38,10 @@ describe "IO.binread" do end it "raises an ArgumentError when not passed a valid length" do - lambda { IO.binread @fname, -1 }.should raise_error(ArgumentError) + -> { IO.binread @fname, -1 }.should raise_error(ArgumentError) end it "raises an Errno::EINVAL when not passed a valid offset" do - lambda { IO.binread @fname, 0, -1 }.should raise_error(Errno::EINVAL) + -> { IO.binread @fname, 0, -1 }.should raise_error(Errno::EINVAL) end end diff --git a/spec/ruby/core/io/bytes_spec.rb b/spec/ruby/core/io/bytes_spec.rb index 2d2bd950f1..feeb493566 100644 --- a/spec/ruby/core/io/bytes_spec.rb +++ b/spec/ruby/core/io/bytes_spec.rb @@ -31,13 +31,13 @@ describe "IO#bytes" do it "raises an IOError on closed stream" do enum = IOSpecs.closed_io.bytes - lambda { enum.first }.should raise_error(IOError) + -> { enum.first }.should raise_error(IOError) end it "raises an IOError on an enumerator for a stream that has been closed" do enum = @io.bytes enum.first.should == 86 @io.close - lambda { enum.first }.should raise_error(IOError) + -> { enum.first }.should raise_error(IOError) end end diff --git a/spec/ruby/core/io/close_on_exec_spec.rb b/spec/ruby/core/io/close_on_exec_spec.rb index d6ba3c3cef..f837bb56af 100644 --- a/spec/ruby/core/io/close_on_exec_spec.rb +++ b/spec/ruby/core/io/close_on_exec_spec.rb @@ -42,7 +42,7 @@ describe "IO#close_on_exec=" do it "raises IOError if called on a closed IO" do @io.close - lambda { @io.close_on_exec = true }.should raise_error(IOError) + -> { @io.close_on_exec = true }.should raise_error(IOError) end it "returns nil" do @@ -74,7 +74,7 @@ describe "IO#close_on_exec?" do it "raises IOError if called on a closed IO" do @io.close - lambda { @io.close_on_exec? }.should raise_error(IOError) + -> { @io.close_on_exec? }.should raise_error(IOError) end end end diff --git a/spec/ruby/core/io/close_read_spec.rb b/spec/ruby/core/io/close_read_spec.rb index 9783cb252a..6fa4fc8ff8 100644 --- a/spec/ruby/core/io/close_read_spec.rb +++ b/spec/ruby/core/io/close_read_spec.rb @@ -16,7 +16,7 @@ describe "IO#close_read" do it "closes the read end of a duplex I/O stream" do @io.close_read - lambda { @io.read }.should raise_error(IOError) + -> { @io.read }.should raise_error(IOError) end it "does nothing on subsequent invocations" do @@ -28,14 +28,14 @@ describe "IO#close_read" do it "allows subsequent invocation of close" do @io.close_read - lambda { @io.close }.should_not raise_error + -> { @io.close }.should_not raise_error end it "raises an IOError if the stream is writable and not duplexed" do io = File.open @path, 'w' begin - lambda { io.close_read }.should raise_error(IOError) + -> { io.close_read }.should raise_error(IOError) ensure io.close unless io.closed? end diff --git a/spec/ruby/core/io/close_spec.rb b/spec/ruby/core/io/close_spec.rb index b7aa2276d1..21bba32cd8 100644 --- a/spec/ruby/core/io/close_spec.rb +++ b/spec/ruby/core/io/close_spec.rb @@ -23,19 +23,19 @@ describe "IO#close" do it "raises an IOError reading from a closed IO" do @io.close - lambda { @io.read }.should raise_error(IOError) + -> { @io.read }.should raise_error(IOError) end it "raises an IOError writing to a closed IO" do @io.close - lambda { @io.write "data" }.should raise_error(IOError) + -> { @io.write "data" }.should raise_error(IOError) end it 'does not close the stream if autoclose is false' do other_io = IO.new(@io.fileno) other_io.autoclose = false other_io.close - lambda { @io.write "data" }.should_not raise_error(IOError) + -> { @io.write "data" }.should_not raise_error(IOError) end it "does nothing if already closed" do @@ -49,7 +49,7 @@ describe "IO#close" do read_io, write_io = IO.pipe going_to_read = false thread = Thread.new do - lambda do + -> do going_to_read = true read_io.read end.should raise_error(IOError, 'stream closed in another thread') @@ -72,7 +72,7 @@ describe "IO#close on an IO.popen stream" do io.close - lambda { io.pid }.should raise_error(IOError) + -> { io.pid }.should raise_error(IOError) end it "sets $?" do diff --git a/spec/ruby/core/io/close_write_spec.rb b/spec/ruby/core/io/close_write_spec.rb index 8643659025..75e1577654 100644 --- a/spec/ruby/core/io/close_write_spec.rb +++ b/spec/ruby/core/io/close_write_spec.rb @@ -15,7 +15,7 @@ describe "IO#close_write" do it "closes the write end of a duplex I/O stream" do @io.close_write - lambda { @io.write "attempt to write" }.should raise_error(IOError) + -> { @io.write "attempt to write" }.should raise_error(IOError) end it "does nothing on subsequent invocations" do @@ -27,14 +27,14 @@ describe "IO#close_write" do it "allows subsequent invocation of close" do @io.close_write - lambda { @io.close }.should_not raise_error + -> { @io.close }.should_not raise_error end it "raises an IOError if the stream is readable and not duplexed" do io = File.open @path, 'w+' begin - lambda { io.close_write }.should raise_error(IOError) + -> { io.close_write }.should raise_error(IOError) ensure io.close unless io.closed? end diff --git a/spec/ruby/core/io/copy_stream_spec.rb b/spec/ruby/core/io/copy_stream_spec.rb index 622be0818b..c541e96e14 100644 --- a/spec/ruby/core/io/copy_stream_spec.rb +++ b/spec/ruby/core/io/copy_stream_spec.rb @@ -31,7 +31,7 @@ describe :io_copy_stream_to_file, shared: true do obj = mock("io_copy_stream_to") obj.should_receive(:to_path).and_return(1) - lambda { IO.copy_stream(@object.from, obj) }.should raise_error(TypeError) + -> { IO.copy_stream(@object.from, obj) }.should raise_error(TypeError) end end @@ -71,7 +71,7 @@ describe :io_copy_stream_to_io, shared: true do it "raises an IOError if the destination IO is not open for writing" do @to_io.close @to_io = new_io @to_name, "r" - lambda { IO.copy_stream @object.from, @to_io }.should raise_error(IOError) + -> { IO.copy_stream @object.from, @to_io }.should raise_error(IOError) end it "does not close the destination IO" do @@ -125,7 +125,7 @@ describe "IO.copy_stream" do it "raises an IOError if the source IO is not open for reading" do @from_io.close @from_io = new_io @from_bigfile, "a" - lambda { IO.copy_stream @from_io, @to_name }.should raise_error(IOError) + -> { IO.copy_stream @from_io, @to_name }.should raise_error(IOError) end it "does not close the source IO" do @@ -183,7 +183,7 @@ describe "IO.copy_stream" do obj = mock("io_copy_stream_from") obj.should_receive(:to_path).and_return(1) - lambda { IO.copy_stream(obj, @to_name) }.should raise_error(TypeError) + -> { IO.copy_stream(obj, @to_name) }.should raise_error(TypeError) end describe "to a file name" do @@ -222,7 +222,7 @@ describe "IO.copy_stream" do platform_is_not :windows do it "raises an error when an offset is specified" do - lambda { IO.copy_stream(@from_io, @to_name, 8, 4) }.should raise_error(Errno::ESPIPE) + -> { IO.copy_stream(@from_io, @to_name, 8, 4) }.should raise_error(Errno::ESPIPE) end end diff --git a/spec/ruby/core/io/dup_spec.rb b/spec/ruby/core/io/dup_spec.rb index c88d109ec9..de32c5e347 100644 --- a/spec/ruby/core/io/dup_spec.rb +++ b/spec/ruby/core/io/dup_spec.rb @@ -49,7 +49,7 @@ end it "allows closing the new IO without affecting the original" do @i.close - lambda { @f.gets }.should_not raise_error(Exception) + -> { @f.gets }.should_not raise_error(Exception) @i.closed?.should == true @f.closed?.should == false @@ -57,14 +57,14 @@ end it "allows closing the original IO without affecting the new one" do @f.close - lambda { @i.gets }.should_not raise_error(Exception) + -> { @i.gets }.should_not raise_error(Exception) @i.closed?.should == false @f.closed?.should == true end it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.dup }.should raise_error(IOError) + -> { IOSpecs.closed_io.dup }.should raise_error(IOError) end it "always sets the close-on-exec flag for the new IO object" do diff --git a/spec/ruby/core/io/each_byte_spec.rb b/spec/ruby/core/io/each_byte_spec.rb index 9cdb1ac0c9..ea618e8c0c 100644 --- a/spec/ruby/core/io/each_byte_spec.rb +++ b/spec/ruby/core/io/each_byte_spec.rb @@ -12,7 +12,7 @@ describe "IO#each_byte" do end it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.each_byte {} }.should raise_error(IOError) + -> { IOSpecs.closed_io.each_byte {} }.should raise_error(IOError) end it "yields each byte" do diff --git a/spec/ruby/core/io/each_codepoint_spec.rb b/spec/ruby/core/io/each_codepoint_spec.rb index 19824c38e4..cddc6b4662 100644 --- a/spec/ruby/core/io/each_codepoint_spec.rb +++ b/spec/ruby/core/io/each_codepoint_spec.rb @@ -38,6 +38,6 @@ describe "IO#each_codepoint" do end it "raises an exception at incomplete character before EOF when conversion takes place" do - lambda { @io.each_codepoint {} }.should raise_error(ArgumentError) + -> { @io.each_codepoint {} }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/io/eof_spec.rb b/spec/ruby/core/io/eof_spec.rb index 3ab389af09..8fd3c37132 100644 --- a/spec/ruby/core/io/eof_spec.rb +++ b/spec/ruby/core/io/eof_spec.rb @@ -16,7 +16,7 @@ describe "IO#eof?" do end it "raises IOError on stream not opened for reading" do - lambda do + -> do File.open(@name, "w") { |f| f.eof? } end.should raise_error(IOError) end @@ -67,12 +67,12 @@ describe "IO#eof?" do end it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.eof? }.should raise_error(IOError) + -> { IOSpecs.closed_io.eof? }.should raise_error(IOError) end it "raises IOError on stream closed for reading by close_read" do @io.close_read - lambda { @io.eof? }.should raise_error(IOError) + -> { @io.eof? }.should raise_error(IOError) end it "returns true on one-byte stream after single-byte read" do diff --git a/spec/ruby/core/io/fcntl_spec.rb b/spec/ruby/core/io/fcntl_spec.rb index 049f92c0a2..30b4876fe3 100644 --- a/spec/ruby/core/io/fcntl_spec.rb +++ b/spec/ruby/core/io/fcntl_spec.rb @@ -3,6 +3,6 @@ require_relative 'fixtures/classes' describe "IO#fcntl" do it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.fcntl(5, 5) }.should raise_error(IOError) + -> { IOSpecs.closed_io.fcntl(5, 5) }.should raise_error(IOError) end end diff --git a/spec/ruby/core/io/fileno_spec.rb b/spec/ruby/core/io/fileno_spec.rb index d7aff99e72..647609bf42 100644 --- a/spec/ruby/core/io/fileno_spec.rb +++ b/spec/ruby/core/io/fileno_spec.rb @@ -7,6 +7,6 @@ describe "IO#fileno" do end it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.fileno }.should raise_error(IOError) + -> { IOSpecs.closed_io.fileno }.should raise_error(IOError) end end diff --git a/spec/ruby/core/io/flush_spec.rb b/spec/ruby/core/io/flush_spec.rb index c81ff74a69..34cf42c425 100644 --- a/spec/ruby/core/io/flush_spec.rb +++ b/spec/ruby/core/io/flush_spec.rb @@ -3,6 +3,35 @@ require_relative 'fixtures/classes' describe "IO#flush" do it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.flush }.should raise_error(IOError) + -> { IOSpecs.closed_io.flush }.should raise_error(IOError) + end + + describe "on a pipe" do + before :each do + @r, @w = IO.pipe + end + + after :each do + @r.close + begin + @w.close + rescue Errno::EPIPE + end + end + + # [ruby-core:90895] MJIT worker may leave fd open in a forked child. + # For instance, MJIT creates a worker before @r.close with fork(), @r.close happens, + # and the MJIT worker keeps the pipe open until the worker execve(). + # TODO: consider acquiring GVL from MJIT worker. + guard_not -> { defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? } do + it "raises Errno::EPIPE if sync=false and the read end is closed" do + @w.sync = false + @w.write "foo" + @r.close + + -> { @w.flush }.should raise_error(Errno::EPIPE, /Broken pipe/) + -> { @w.close }.should raise_error(Errno::EPIPE, /Broken pipe/) + end + end end end diff --git a/spec/ruby/core/io/fsync_spec.rb b/spec/ruby/core/io/fsync_spec.rb index 0261939631..6e6123de94 100644 --- a/spec/ruby/core/io/fsync_spec.rb +++ b/spec/ruby/core/io/fsync_spec.rb @@ -12,7 +12,7 @@ describe "IO#fsync" do end it "raises an IOError on closed stream" do - lambda { IOSpecs.closed_io.fsync }.should raise_error(IOError) + -> { IOSpecs.closed_io.fsync }.should raise_error(IOError) end it "writes the buffered data to permanent storage" do diff --git a/spec/ruby/core/io/getbyte_spec.rb b/spec/ruby/core/io/getbyte_spec.rb index 6b665029d6..6ba8f0a3e0 100644 --- a/spec/ruby/core/io/getbyte_spec.rb +++ b/spec/ruby/core/io/getbyte_spec.rb @@ -23,7 +23,7 @@ describe "IO#getbyte" do end it "raises an IOError on closed stream" do - lambda { IOSpecs.closed_io.getbyte }.should raise_error(IOError) + -> { IOSpecs.closed_io.getbyte }.should raise_error(IOError) end end diff --git a/spec/ruby/core/io/getc_spec.rb b/spec/ruby/core/io/getc_spec.rb index 7c1c18cd90..3949b5cb28 100644 --- a/spec/ruby/core/io/getc_spec.rb +++ b/spec/ruby/core/io/getc_spec.rb @@ -23,7 +23,7 @@ describe "IO#getc" do end it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.getc }.should raise_error(IOError) + -> { IOSpecs.closed_io.getc }.should raise_error(IOError) end end diff --git a/spec/ruby/core/io/gets_spec.rb b/spec/ruby/core/io/gets_spec.rb index 371c1c3d3b..8f6ec0dfc7 100644 --- a/spec/ruby/core/io/gets_spec.rb +++ b/spec/ruby/core/io/gets_spec.rb @@ -30,7 +30,7 @@ describe "IO#gets" do end it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.gets }.should raise_error(IOError) + -> { IOSpecs.closed_io.gets }.should raise_error(IOError) end describe "with no separator" do @@ -156,11 +156,11 @@ describe "IO#gets" do end it "raises an IOError if the stream is opened for append only" do - lambda { File.open(@name, "a:utf-8") { |f| f.gets } }.should raise_error(IOError) + -> { File.open(@name, "a:utf-8") { |f| f.gets } }.should raise_error(IOError) end it "raises an IOError if the stream is opened for writing only" do - lambda { File.open(@name, "w:utf-8") { |f| f.gets } }.should raise_error(IOError) + -> { File.open(@name, "w:utf-8") { |f| f.gets } }.should raise_error(IOError) end end diff --git a/spec/ruby/core/io/initialize_spec.rb b/spec/ruby/core/io/initialize_spec.rb index 4858e0360c..c8f3faf110 100644 --- a/spec/ruby/core/io/initialize_spec.rb +++ b/spec/ruby/core/io/initialize_spec.rb @@ -28,22 +28,22 @@ describe "IO#initialize" do end it "raises a TypeError when passed an IO" do - lambda { @io.send :initialize, STDOUT, 'w' }.should raise_error(TypeError) + -> { @io.send :initialize, STDOUT, 'w' }.should raise_error(TypeError) end it "raises a TypeError when passed nil" do - lambda { @io.send :initialize, nil, 'w' }.should raise_error(TypeError) + -> { @io.send :initialize, nil, 'w' }.should raise_error(TypeError) end it "raises a TypeError when passed a String" do - lambda { @io.send :initialize, "4", 'w' }.should raise_error(TypeError) + -> { @io.send :initialize, "4", 'w' }.should raise_error(TypeError) end it "raises IOError on closed stream" do - lambda { @io.send :initialize, IOSpecs.closed_io.fileno }.should raise_error(IOError) + -> { @io.send :initialize, IOSpecs.closed_io.fileno }.should raise_error(IOError) end it "raises an Errno::EBADF when given an invalid file descriptor" do - lambda { @io.send :initialize, -1, 'w' }.should raise_error(Errno::EBADF) + -> { @io.send :initialize, -1, 'w' }.should raise_error(Errno::EBADF) end end diff --git a/spec/ruby/core/io/ioctl_spec.rb b/spec/ruby/core/io/ioctl_spec.rb index 0f2b67ac44..e819a217a8 100644 --- a/spec/ruby/core/io/ioctl_spec.rb +++ b/spec/ruby/core/io/ioctl_spec.rb @@ -4,7 +4,7 @@ require_relative 'fixtures/classes' describe "IO#ioctl" do platform_is_not :windows do it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.ioctl(5, 5) }.should raise_error(IOError) + -> { IOSpecs.closed_io.ioctl(5, 5) }.should raise_error(IOError) end end @@ -22,7 +22,7 @@ describe "IO#ioctl" do it "raises an Errno error when ioctl fails" do File.open(__FILE__, 'r') do |f| - lambda { + -> { # TIOCGWINSZ in /usr/include/asm-generic/ioctls.h f.ioctl 0x5413, nil }.should raise_error(Errno::ENOTTY) diff --git a/spec/ruby/core/io/lineno_spec.rb b/spec/ruby/core/io/lineno_spec.rb index 322e60d643..3d1b2275cc 100644 --- a/spec/ruby/core/io/lineno_spec.rb +++ b/spec/ruby/core/io/lineno_spec.rb @@ -11,7 +11,7 @@ describe "IO#lineno" do end it "raises an IOError on a closed stream" do - lambda { IOSpecs.closed_io.lineno }.should raise_error(IOError) + -> { IOSpecs.closed_io.lineno }.should raise_error(IOError) end it "returns the current line number" do @@ -37,7 +37,7 @@ describe "IO#lineno=" do end it "raises an IOError on a closed stream" do - lambda { IOSpecs.closed_io.lineno = 5 }.should raise_error(IOError) + -> { IOSpecs.closed_io.lineno = 5 }.should raise_error(IOError) end it "calls #to_int on a non-numeric argument" do @@ -57,7 +57,7 @@ describe "IO#lineno=" do end it "raises TypeError on nil argument" do - lambda { @io.lineno = nil }.should raise_error(TypeError) + -> { @io.lineno = nil }.should raise_error(TypeError) end it "sets the current line number to the given value" do diff --git a/spec/ruby/core/io/open_spec.rb b/spec/ruby/core/io/open_spec.rb index f26753cde7..94df5a5ef6 100644 --- a/spec/ruby/core/io/open_spec.rb +++ b/spec/ruby/core/io/open_spec.rb @@ -38,7 +38,7 @@ describe "IO.open" do end it "propagates an exception raised by #close that is not a StandardError" do - lambda do + -> do IO.open(@fd, "w") do |io| IOSpecs.io_mock(io, :close) do super() @@ -51,7 +51,7 @@ describe "IO.open" do end it "propagates an exception raised by #close that is a StandardError" do - lambda do + -> do IO.open(@fd, "w") do |io| IOSpecs.io_mock(io, :close) do super() diff --git a/spec/ruby/core/io/output_spec.rb b/spec/ruby/core/io/output_spec.rb index d3ec71c563..2aafb305f4 100644 --- a/spec/ruby/core/io/output_spec.rb +++ b/spec/ruby/core/io/output_spec.rb @@ -3,24 +3,24 @@ require_relative 'fixtures/classes' describe "IO#<<" do it "writes an object to the IO stream" do - lambda { + -> { $stderr << "Oh noes, an error!" }.should output_to_fd("Oh noes, an error!", $stderr) end it "calls #to_s on the object to print it" do - lambda { + -> { $stderr << 1337 }.should output_to_fd("1337", $stderr) end it "raises an error if the stream is closed" do io = IOSpecs.closed_io - lambda { io << "test" }.should raise_error(IOError) + -> { io << "test" }.should raise_error(IOError) end it "returns self" do - lambda { + -> { ($stderr << "to_stderr").should == $stderr }.should output(nil, "to_stderr") end diff --git a/spec/ruby/core/io/pid_spec.rb b/spec/ruby/core/io/pid_spec.rb index 97b8a8529d..bc09fe7c3b 100644 --- a/spec/ruby/core/io/pid_spec.rb +++ b/spec/ruby/core/io/pid_spec.rb @@ -30,6 +30,6 @@ describe "IO#pid" do it "raises an IOError on closed stream" do @io.close - lambda { @io.pid }.should raise_error(IOError) + -> { @io.pid }.should raise_error(IOError) end end diff --git a/spec/ruby/core/io/pipe_spec.rb b/spec/ruby/core/io/pipe_spec.rb index 005f60fab6..5b2f18d836 100644 --- a/spec/ruby/core/io/pipe_spec.rb +++ b/spec/ruby/core/io/pipe_spec.rb @@ -50,7 +50,7 @@ describe "IO.pipe" do it "closes both IO objects when the block raises" do r = w = nil - lambda do + -> do IO.pipe do |_r, _w| r = _r w = _w diff --git a/spec/ruby/core/io/popen_spec.rb b/spec/ruby/core/io/popen_spec.rb index 289bb076e4..622b3a9394 100644 --- a/spec/ruby/core/io/popen_spec.rb +++ b/spec/ruby/core/io/popen_spec.rb @@ -22,7 +22,7 @@ describe "IO.popen" do it "raises IOError when writing a read-only pipe" do @io = IO.popen(ruby_cmd('puts "foo"'), "r") - lambda { @io.write('bar') }.should raise_error(IOError) + -> { @io.write('bar') }.should raise_error(IOError) @io.read.should == "foo\n" end end @@ -55,7 +55,7 @@ describe "IO.popen" do it "raises IOError when reading a write-only pipe" do @io = IO.popen(ruby_cmd('IO.copy_stream(STDIN,STDOUT)'), "w") - lambda { @io.read }.should raise_error(IOError) + -> { @io.read }.should raise_error(IOError) end it "reads and writes a read/write pipe" do diff --git a/spec/ruby/core/io/pread_spec.rb b/spec/ruby/core/io/pread_spec.rb index b5b516fa53..bfe6472fef 100644 --- a/spec/ruby/core/io/pread_spec.rb +++ b/spec/ruby/core/io/pread_spec.rb @@ -33,19 +33,19 @@ ruby_version_is "2.5" do end it "raises EOFError if end-of-file is reached" do - lambda { @file.pread(1, 10) }.should raise_error(EOFError) + -> { @file.pread(1, 10) }.should raise_error(EOFError) end it "raises IOError when file is not open in read mode" do File.open(@fname, "w") do |file| - lambda { file.pread(1, 1) }.should raise_error(IOError) + -> { file.pread(1, 1) }.should raise_error(IOError) end end it "raises IOError when file is closed" do file = File.open(@fname, "r+") file.close - lambda { file.pread(1, 1) }.should raise_error(IOError) + -> { file.pread(1, 1) }.should raise_error(IOError) end end end diff --git a/spec/ruby/core/io/print_spec.rb b/spec/ruby/core/io/print_spec.rb index 0dd48344ce..2021cd5420 100644 --- a/spec/ruby/core/io/print_spec.rb +++ b/spec/ruby/core/io/print_spec.rb @@ -48,6 +48,6 @@ describe IO, "#print" do end it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.print("stuff") }.should raise_error(IOError) + -> { IOSpecs.closed_io.print("stuff") }.should raise_error(IOError) end end diff --git a/spec/ruby/core/io/printf_spec.rb b/spec/ruby/core/io/printf_spec.rb index be4e5c339e..baa00f14ce 100644 --- a/spec/ruby/core/io/printf_spec.rb +++ b/spec/ruby/core/io/printf_spec.rb @@ -27,6 +27,6 @@ describe "IO#printf" do end it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.printf("stuff") }.should raise_error(IOError) + -> { IOSpecs.closed_io.printf("stuff") }.should raise_error(IOError) end end diff --git a/spec/ruby/core/io/puts_spec.rb b/spec/ruby/core/io/puts_spec.rb index e8d599730f..3e4b877b7f 100644 --- a/ |