diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
commit | 5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch) | |
tree | 05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/core/file | |
parent | a06301b103371b0b7da8eaca26ba744961769f99 (diff) | |
download | ruby-5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0.tar.gz |
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/core/file')
34 files changed, 148 insertions, 148 deletions
diff --git a/spec/ruby/core/file/atime_spec.rb b/spec/ruby/core/file/atime_spec.rb index c791aa6d74..02e8412722 100644 --- a/spec/ruby/core/file/atime_spec.rb +++ b/spec/ruby/core/file/atime_spec.rb @@ -30,7 +30,7 @@ describe "File.atime" do end it "raises an Errno::ENOENT exception if the file is not found" do - lambda { File.atime('a_fake_file') }.should raise_error(Errno::ENOENT) + -> { File.atime('a_fake_file') }.should raise_error(Errno::ENOENT) end it "accepts an object that has a #to_path method" do diff --git a/spec/ruby/core/file/basename_spec.rb b/spec/ruby/core/file/basename_spec.rb index 50365b1125..6d7e432086 100644 --- a/spec/ruby/core/file/basename_spec.rb +++ b/spec/ruby/core/file/basename_spec.rb @@ -105,10 +105,10 @@ describe "File.basename" do end it "raises a TypeError if the arguments are not String types" do - lambda { File.basename(nil) }.should raise_error(TypeError) - lambda { File.basename(1) }.should raise_error(TypeError) - lambda { File.basename("bar.txt", 1) }.should raise_error(TypeError) - lambda { File.basename(true) }.should raise_error(TypeError) + -> { File.basename(nil) }.should raise_error(TypeError) + -> { File.basename(1) }.should raise_error(TypeError) + -> { File.basename("bar.txt", 1) }.should raise_error(TypeError) + -> { File.basename(true) }.should raise_error(TypeError) end it "accepts an object that has a #to_path method" do @@ -116,7 +116,7 @@ describe "File.basename" do end it "raises an ArgumentError if passed more than two arguments" do - lambda { File.basename('bar.txt', '.txt', '.txt') }.should raise_error(ArgumentError) + -> { File.basename('bar.txt', '.txt', '.txt') }.should raise_error(ArgumentError) end # specific to MS Windows diff --git a/spec/ruby/core/file/birthtime_spec.rb b/spec/ruby/core/file/birthtime_spec.rb index cab749f7b4..755601df64 100644 --- a/spec/ruby/core/file/birthtime_spec.rb +++ b/spec/ruby/core/file/birthtime_spec.rb @@ -20,13 +20,13 @@ describe "File.birthtime" do end it "raises an Errno::ENOENT exception if the file is not found" do - lambda { File.birthtime('bogus') }.should raise_error(Errno::ENOENT) + -> { File.birthtime('bogus') }.should raise_error(Errno::ENOENT) end end platform_is :openbsd do it "raises an NotImplementedError" do - lambda { File.birthtime(@file) }.should raise_error(NotImplementedError) + -> { File.birthtime(@file) }.should raise_error(NotImplementedError) end end @@ -52,7 +52,7 @@ describe "File#birthtime" do platform_is :openbsd do it "raises an NotImplementedError" do - lambda { @file.birthtime }.should raise_error(NotImplementedError) + -> { @file.birthtime }.should raise_error(NotImplementedError) end end diff --git a/spec/ruby/core/file/chmod_spec.rb b/spec/ruby/core/file/chmod_spec.rb index 6c4e1099e3..86171691f6 100644 --- a/spec/ruby/core/file/chmod_spec.rb +++ b/spec/ruby/core/file/chmod_spec.rb @@ -106,11 +106,11 @@ describe "File.chmod" do end it "throws a TypeError if the given path is not coercable into a string" do - lambda { File.chmod(0, []) }.should raise_error(TypeError) + -> { File.chmod(0, []) }.should raise_error(TypeError) end it "raises an error for a non existent path" do - lambda { + -> { File.chmod(0644, "#{@file}.not.existing") }.should raise_error(Errno::ENOENT) end diff --git a/spec/ruby/core/file/chown_spec.rb b/spec/ruby/core/file/chown_spec.rb index 512d5b4738..8cc8f0d04b 100644 --- a/spec/ruby/core/file/chown_spec.rb +++ b/spec/ruby/core/file/chown_spec.rb @@ -66,7 +66,7 @@ describe "File.chown" do platform_is_not :windows do it "raises an error for a non existent path" do - lambda { + -> { File.chown(nil, nil, "#{@fname}_not_existing") }.should raise_error(Errno::ENOENT) end diff --git a/spec/ruby/core/file/ctime_spec.rb b/spec/ruby/core/file/ctime_spec.rb index 5753e0d90e..68a9fa43cb 100644 --- a/spec/ruby/core/file/ctime_spec.rb +++ b/spec/ruby/core/file/ctime_spec.rb @@ -30,7 +30,7 @@ describe "File.ctime" do end it "raises an Errno::ENOENT exception if the file is not found" do - lambda { File.ctime('bogus') }.should raise_error(Errno::ENOENT) + -> { File.ctime('bogus') }.should raise_error(Errno::ENOENT) end end diff --git a/spec/ruby/core/file/dirname_spec.rb b/spec/ruby/core/file/dirname_spec.rb index 0447a4e471..2ef04a7b64 100644 --- a/spec/ruby/core/file/dirname_spec.rb +++ b/spec/ruby/core/file/dirname_spec.rb @@ -72,10 +72,10 @@ describe "File.dirname" do end it "raises a TypeError if not passed a String type" do - lambda { File.dirname(nil) }.should raise_error(TypeError) - lambda { File.dirname(0) }.should raise_error(TypeError) - lambda { File.dirname(true) }.should raise_error(TypeError) - lambda { File.dirname(false) }.should raise_error(TypeError) + -> { File.dirname(nil) }.should raise_error(TypeError) + -> { File.dirname(0) }.should raise_error(TypeError) + -> { File.dirname(true) }.should raise_error(TypeError) + -> { File.dirname(false) }.should raise_error(TypeError) end # Windows specific tests diff --git a/spec/ruby/core/file/expand_path_spec.rb b/spec/ruby/core/file/expand_path_spec.rb index aa6a3c9c63..88078645ab 100644 --- a/spec/ruby/core/file/expand_path_spec.rb +++ b/spec/ruby/core/file/expand_path_spec.rb @@ -92,7 +92,7 @@ describe "File.expand_path" do end it "raises an ArgumentError if the path is not valid" do - lambda { File.expand_path("~a_not_existing_user") }.should raise_error(ArgumentError) + -> { File.expand_path("~a_not_existing_user") }.should raise_error(ArgumentError) end it "expands ~ENV['USER'] to the user's home directory" do @@ -117,9 +117,9 @@ describe "File.expand_path" do end it "raises a TypeError if not passed a String type" do - lambda { File.expand_path(1) }.should raise_error(TypeError) - lambda { File.expand_path(nil) }.should raise_error(TypeError) - lambda { File.expand_path(true) }.should raise_error(TypeError) + -> { File.expand_path(1) }.should raise_error(TypeError) + -> { File.expand_path(nil) }.should raise_error(TypeError) + -> { File.expand_path(true) }.should raise_error(TypeError) end platform_is_not :windows do @@ -159,7 +159,7 @@ describe "File.expand_path" do platform_is_not :windows do it "raises an Encoding::CompatibilityError if the external encoding is not compatible" do Encoding.default_external = Encoding::UTF_16BE - lambda { File.expand_path("./a") }.should raise_error(Encoding::CompatibilityError) + -> { File.expand_path("./a") }.should raise_error(Encoding::CompatibilityError) end end @@ -244,7 +244,7 @@ platform_is_not :windows do it "raises an ArgumentError when passed '~' if HOME == ''" do ENV["HOME"] = "" - lambda { File.expand_path("~") }.should raise_error(ArgumentError) + -> { File.expand_path("~") }.should raise_error(ArgumentError) end end @@ -259,7 +259,7 @@ platform_is_not :windows do it "raises an ArgumentError" do ENV["HOME"] = "non-absolute" - lambda { File.expand_path("~") }.should raise_error(ArgumentError, 'non-absolute home') + -> { File.expand_path("~") }.should raise_error(ArgumentError, 'non-absolute home') end end end diff --git a/spec/ruby/core/file/extname_spec.rb b/spec/ruby/core/file/extname_spec.rb index 7632b6adc0..358690b44a 100644 --- a/spec/ruby/core/file/extname_spec.rb +++ b/spec/ruby/core/file/extname_spec.rb @@ -33,15 +33,15 @@ describe "File.extname" do end it "raises a TypeError if not passed a String type" do - lambda { File.extname(nil) }.should raise_error(TypeError) - lambda { File.extname(0) }.should raise_error(TypeError) - lambda { File.extname(true) }.should raise_error(TypeError) - lambda { File.extname(false) }.should raise_error(TypeError) + -> { File.extname(nil) }.should raise_error(TypeError) + -> { File.extname(0) }.should raise_error(TypeError) + -> { File.extname(true) }.should raise_error(TypeError) + -> { File.extname(false) }.should raise_error(TypeError) end it "raises an ArgumentError if not passed one argument" do - lambda { File.extname }.should raise_error(ArgumentError) - lambda { File.extname("foo.bar", "foo.baz") }.should raise_error(ArgumentError) + -> { File.extname }.should raise_error(ArgumentError) + -> { File.extname("foo.bar", "foo.baz") }.should raise_error(ArgumentError) end diff --git a/spec/ruby/core/file/flock_spec.rb b/spec/ruby/core/file/flock_spec.rb index 6990915a65..751e99d994 100644 --- a/spec/ruby/core/file/flock_spec.rb +++ b/spec/ruby/core/file/flock_spec.rb @@ -92,13 +92,13 @@ platform_is :solaris do end it "fails with EBADF acquiring exclusive lock on read-only File" do - lambda do + -> do @read_file.flock File::LOCK_EX end.should raise_error(Errno::EBADF) end it "fails with EBADF acquiring shared lock on read-only File" do - lambda do + -> do @write_file.flock File::LOCK_SH end.should raise_error(Errno::EBADF) end diff --git a/spec/ruby/core/file/ftype_spec.rb b/spec/ruby/core/file/ftype_spec.rb index e92f04da2c..20e9af7e5f 100644 --- a/spec/ruby/core/file/ftype_spec.rb +++ b/spec/ruby/core/file/ftype_spec.rb @@ -7,12 +7,12 @@ describe "File.ftype" do end it "raises ArgumentError if not given exactly one filename" do - lambda { File.ftype }.should raise_error(ArgumentError) - lambda { File.ftype('blah', 'bleh') }.should raise_error(ArgumentError) + -> { File.ftype }.should raise_error(ArgumentError) + -> { File.ftype('blah', 'bleh') }.should raise_error(ArgumentError) end it "raises Errno::ENOENT if the file is not valid" do - l = lambda { File.ftype("/#{$$}#{Time.now.to_f}") } + l = -> { File.ftype("/#{$$}#{Time.now.to_f}") } l.should raise_error(Errno::ENOENT) end diff --git a/spec/ruby/core/file/join_spec.rb b/spec/ruby/core/file/join_spec.rb index 333b566c3d..f1eab02de0 100644 --- a/spec/ruby/core/file/join_spec.rb +++ b/spec/ruby/core/file/join_spec.rb @@ -104,15 +104,15 @@ describe "File.join" do it "raises an ArgumentError if passed a recursive array" do a = ["a"] a << a - lambda { File.join a }.should raise_error(ArgumentError) + -> { File.join a }.should raise_error(ArgumentError) end it "raises a TypeError exception when args are nil" do - lambda { File.join nil }.should raise_error(TypeError) + -> { File.join nil }.should raise_error(TypeError) end it "calls #to_str" do - lambda { File.join(mock('x')) }.should raise_error(TypeError) + -> { File.join(mock('x')) }.should raise_error(TypeError) bin = mock("bin") bin.should_receive(:to_str).exactly(:twice).and_return("bin") @@ -129,7 +129,7 @@ describe "File.join" do end it "calls #to_path" do - lambda { File.join(mock('x')) }.should raise_error(TypeError) + -> { File.join(mock('x')) }.should raise_error(TypeError) bin = mock("bin") bin.should_receive(:to_path).exactly(:twice).and_return("bin") diff --git a/spec/ruby/core/file/lchmod_spec.rb b/spec/ruby/core/file/lchmod_spec.rb index 7be09a05ef..9490459a02 100644 --- a/spec/ruby/core/file/lchmod_spec.rb +++ b/spec/ruby/core/file/lchmod_spec.rb @@ -36,7 +36,7 @@ describe "File.lchmod" do end it "raises a NotImplementedError when called" do - lambda { File.lchmod 0 }.should raise_error(NotImplementedError) + -> { File.lchmod 0 }.should raise_error(NotImplementedError) end end end diff --git a/spec/ruby/core/file/link_spec.rb b/spec/ruby/core/file/link_spec.rb index 4e186c6076..11d4c8d25b 100644 --- a/spec/ruby/core/file/link_spec.rb +++ b/spec/ruby/core/file/link_spec.rb @@ -22,18 +22,18 @@ describe "File.link" do it "raises an Errno::EEXIST if the target already exists" do File.link(@file, @link) - lambda { File.link(@file, @link) }.should raise_error(Errno::EEXIST) + -> { File.link(@file, @link) }.should raise_error(Errno::EEXIST) end it "raises an ArgumentError if not passed two arguments" do - lambda { File.link }.should raise_error(ArgumentError) - lambda { File.link(@file) }.should raise_error(ArgumentError) - lambda { File.link(@file, @link, @file) }.should raise_error(ArgumentError) + -> { File.link }.should raise_error(ArgumentError) + -> { File.link(@file) }.should raise_error(ArgumentError) + -> { File.link(@file, @link, @file) }.should raise_error(ArgumentError) end it "raises a TypeError if not passed String types" do - lambda { File.link(@file, nil) }.should raise_error(TypeError) - lambda { File.link(@file, 1) }.should raise_error(TypeError) + -> { File.link(@file, nil) }.should raise_error(TypeError) + -> { File.link(@file, 1) }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/file/mkfifo_spec.rb b/spec/ruby/core/file/mkfifo_spec.rb index a6db87a12e..19298c967c 100644 --- a/spec/ruby/core/file/mkfifo_spec.rb +++ b/spec/ruby/core/file/mkfifo_spec.rb @@ -19,13 +19,13 @@ describe "File.mkfifo" do context "when path passed is not a String value" do it "raises a TypeError" do - lambda { File.mkfifo(:"/tmp/fifo") }.should raise_error(TypeError) + -> { File.mkfifo(:"/tmp/fifo") }.should raise_error(TypeError) end end context "when path does not exist" do it "raises an Errno::ENOENT exception" do - lambda { File.mkfifo("/bogus/path") }.should raise_error(Errno::ENOENT) + -> { File.mkfifo("/bogus/path") }.should raise_error(Errno::ENOENT) end end diff --git a/spec/ruby/core/file/mtime_spec.rb b/spec/ruby/core/file/mtime_spec.rb index 833f759eaa..1941e2ff85 100644 --- a/spec/ruby/core/file/mtime_spec.rb +++ b/spec/ruby/core/file/mtime_spec.rb @@ -29,7 +29,7 @@ describe "File.mtime" do end it "raises an Errno::ENOENT exception if the file is not found" do - lambda { File.mtime('bogus') }.should raise_error(Errno::ENOENT) + -> { File.mtime('bogus') }.should raise_error(Errno::ENOENT) end end diff --git a/spec/ruby/core/file/new_spec.rb b/spec/ruby/core/file/new_spec.rb index 3bb2712ada..e99f6ba72b 100644 --- a/spec/ruby/core/file/new_spec.rb +++ b/spec/ruby/core/file/new_spec.rb @@ -44,7 +44,7 @@ describe "File.new" do rm_r @file begin f = File.new(@file, "w", 0444) - lambda { f.puts("test") }.should_not raise_error(IOError) + -> { f.puts("test") }.should_not raise_error(IOError) ensure f.close end @@ -85,7 +85,7 @@ describe "File.new" do end it "raises an Errorno::EEXIST if the file exists when create a new file with File::CREAT|File::EXCL" do - lambda { @fh = File.new(@file, File::CREAT|File::EXCL) }.should raise_error(Errno::EEXIST) + -> { @fh = File.new(@file, File::CREAT|File::EXCL) }.should raise_error(Errno::EEXIST) end it "creates a new file when use File::WRONLY|File::APPEND mode" do @@ -134,22 +134,22 @@ describe "File.new" do end it "raises a TypeError if the first parameter can't be coerced to a string" do - lambda { File.new(true) }.should raise_error(TypeError) - lambda { File.new(false) }.should raise_error(TypeError) + -> { File.new(true) }.should raise_error(TypeError) + -> { File.new(false) }.should raise_error(TypeError) end it "raises a TypeError if the first parameter is nil" do - lambda { File.new(nil) }.should raise_error(TypeError) + -> { File.new(nil) }.should raise_error(TypeError) end it "raises an Errno::EBADF if the first parameter is an invalid file descriptor" do - lambda { File.new(-1) }.should raise_error(Errno::EBADF) + -> { File.new(-1) }.should raise_error(Errno::EBADF) end platform_is_not :windows do it "can't alter mode or permissions when opening a file" do @fh = File.new(@file) - lambda { + -> { f = File.new(@fh.fileno, @flags) f.autoclose = false }.should raise_error(Errno::EINVAL) diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb index 59c13f08ed..d946fc5ecf 100644 --- a/spec/ruby/core/file/open_spec.rb +++ b/spec/ruby/core/file/open_spec.rb @@ -38,7 +38,7 @@ describe "File.open" do end it "propagates non-StandardErrors produced by close" do - lambda { + -> { File.open(@file, 'r') { |f| FileSpecs.make_closer f, Exception } }.should raise_error(Exception) @@ -46,7 +46,7 @@ describe "File.open" do end it "propagates StandardErrors produced by close" do - lambda { + -> { File.open(@file, 'r') { |f| FileSpecs.make_closer f, StandardError } }.should raise_error(StandardError) @@ -166,40 +166,40 @@ describe "File.open" do end it "opens a file that no exists when use File::WRONLY mode" do - lambda { File.open(@nonexistent, File::WRONLY) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::WRONLY) }.should raise_error(Errno::ENOENT) end it "opens a file that no exists when use File::RDONLY mode" do - lambda { File.open(@nonexistent, File::RDONLY) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::RDONLY) }.should raise_error(Errno::ENOENT) end it "opens a file that no exists when use 'r' mode" do - lambda { File.open(@nonexistent, 'r') }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, 'r') }.should raise_error(Errno::ENOENT) end it "opens a file that no exists when use File::EXCL mode" do - lambda { File.open(@nonexistent, File::EXCL) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::EXCL) }.should raise_error(Errno::ENOENT) end it "opens a file that no exists when use File::NONBLOCK mode" do - lambda { File.open(@nonexistent, File::NONBLOCK) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::NONBLOCK) }.should raise_error(Errno::ENOENT) end platform_is_not :openbsd, :windows do it "opens a file that no exists when use File::TRUNC mode" do - lambda { File.open(@nonexistent, File::TRUNC) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::TRUNC) }.should raise_error(Errno::ENOENT) end end platform_is :openbsd, :windows do it "does not open a file that does no exists when using File::TRUNC mode" do - lambda { File.open(@nonexistent, File::TRUNC) }.should raise_error(Errno::EINVAL) + -> { File.open(@nonexistent, File::TRUNC) }.should raise_error(Errno::EINVAL) end end platform_is_not :windows do it "opens a file that no exists when use File::NOCTTY mode" do - lambda { File.open(@nonexistent, File::NOCTTY) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::NOCTTY) }.should raise_error(Errno::ENOENT) end end @@ -223,7 +223,7 @@ describe "File.open" do # Check the grants associated to the different open modes combinations. it "raises an ArgumentError exception when call with an unknown mode" do - lambda { File.open(@file, "q") }.should raise_error(ArgumentError) + -> { File.open(@file, "q") }.should raise_error(ArgumentError) end it "can read in a block when call open with RDONLY mode" do @@ -240,13 +240,13 @@ describe "File.open" do it "raises an IO exception when write in a block opened with RDONLY mode" do File.open(@file, File::RDONLY) do |f| - lambda { f.puts "writing ..." }.should raise_error(IOError) + -> { f.puts "writing ..." }.should raise_error(IOError) end end it "raises an IO exception when write in a block opened with 'r' mode" do File.open(@file, "r") do |f| - lambda { f.puts "writing ..." }.should raise_error(IOError) + -> { f.puts "writing ..." }.should raise_error(IOError) end end @@ -257,7 +257,7 @@ describe "File.open" do end it "can't read in a block when call open with File::WRONLY||File::RDONLY mode" do - lambda { + -> { File.open(@file, File::WRONLY|File::RDONLY ) do |f| f.gets.should == nil end @@ -278,44 +278,44 @@ describe "File.open" do it "raises an IOError when read in a block opened with WRONLY mode" do File.open(@file, File::WRONLY) do |f| - lambda { f.gets }.should raise_error(IOError) + -> { f.gets }.should raise_error(IOError) end end it "raises an IOError when read in a block opened with 'w' mode" do File.open(@file, "w") do |f| - lambda { f.gets }.should raise_error(IOError) + -> { f.gets }.should raise_error(IOError) end end it "raises an IOError when read in a block opened with 'a' mode" do File.open(@file, "a") do |f| - lambda { f.gets }.should raise_error(IOError) + -> { f.gets }.should raise_error(IOError) end end it "raises an IOError when read in a block opened with 'a' mode" do File.open(@file, "a") do |f| f.puts("writing").should == nil - lambda { f.gets }.should raise_error(IOError) + -> { f.gets }.should raise_error(IOError) end end it "raises an IOError when read in a block opened with 'a' mode" do File.open(@file, File::WRONLY|File::APPEND ) do |f| - lambda { f.gets }.should raise_error(IOError) + -> { f.gets }.should raise_error(IOError) end end it "raises an IOError when read in a block opened with File::WRONLY|File::APPEND mode" do File.open(@file, File::WRONLY|File::APPEND ) do |f| f.puts("writing").should == nil - lambda { f.gets }.should raise_error(IOError) + -> { f.gets }.should raise_error(IOError) end end it "raises an IOError when read in a block opened with File::RDONLY|File::APPEND mode" do - lambda { + -> { File.open(@file, File::RDONLY|File::APPEND ) do |f| f.puts("writing") end @@ -332,7 +332,7 @@ describe "File.open" do end it "can't read in a block when call open with File::EXCL mode" do - lambda { + -> { File.open(@file, File::EXCL) do |f| f.puts("writing").should == nil end @@ -355,7 +355,7 @@ describe "File.open" do end it "raises an Errorno::EEXIST if the file exists when open with File::CREAT|File::EXCL" do - lambda { + -> { File.open(@file, File::CREAT|File::EXCL) do |f| f.puts("writing") end @@ -382,7 +382,7 @@ describe "File.open" do end it "raises an IOError if the file exists when open with File::RDONLY|File::APPEND" do - lambda { + -> { File.open(@file, File::RDONLY|File::APPEND) do |f| f.puts("writing").should == nil end @@ -416,7 +416,7 @@ describe "File.open" do platform_is_not :openbsd, :windows do it "can't write in a block when call open with File::TRUNC mode" do - lambda { + -> { File.open(@file, File::TRUNC) do |f| f.puts("writing") end @@ -424,7 +424,7 @@ describe "File.open" do end it "raises an Errorno::EEXIST if the file exists when open with File::RDONLY|File::TRUNC" do - lambda { + -> { File.open(@file, File::RDONLY|File::TRUNC) do |f| f.puts("writing").should == nil end @@ -434,7 +434,7 @@ describe "File.open" do platform_is :openbsd, :windows do it "can't write in a block when call open with File::TRUNC mode" do - lambda { + -> { File.open(@file, File::TRUNC) do |f| f.puts("writing") end @@ -442,7 +442,7 @@ describe "File.open" do end it "raises an Errorno::EEXIST if the file exists when open with File::RDONLY|File::TRUNC" do - lambda { + -> { File.open(@file, File::RDONLY|File::TRUNC) do |f| f.puts("writing").should == nil end @@ -455,7 +455,7 @@ describe "File.open" do it "raises an Errno::EACCES when opening non-permitted file" do @fh = File.open(@file, "w") @fh.chmod(000) - lambda { fh1 = File.open(@file); fh1.close }.should raise_error(Errno::EACCES) + -> { fh1 = File.open(@file); fh1.close }.should raise_error(Errno::EACCES) end end end @@ -464,7 +464,7 @@ describe "File.open" do it "raises an Errno::EACCES when opening read-only file" do @fh = File.open(@file, "w") @fh.chmod(0444) - lambda { File.open(@file, "w") }.should raise_error(Errno::EACCES) + -> { File.open(@file, "w") }.should raise_error(Errno::EACCES) end end @@ -535,21 +535,21 @@ describe "File.open" do end it "raises a TypeError if passed a filename that is not a String or Integer type" do - lambda { File.open(true) }.should raise_error(TypeError) - lambda { File.open(false) }.should raise_error(TypeError) - lambda { File.open(nil) }.should raise_error(TypeError) + -> { File.open(true) }.should raise_error(TypeError) + -> { File.open(false) }.should raise_error(TypeError) + -> { File.open(nil) }.should raise_error(TypeError) end it "raises a SystemCallError if passed an invalid Integer type" do - lambda { File.open(-1) }.should raise_error(SystemCallError) + -> { File.open(-1) }.should raise_error(SystemCallError) end it "raises an ArgumentError if passed the wrong number of arguments" do - lambda { File.open(@file, File::CREAT, 0755, 'test') }.should raise_error(ArgumentError) + -> { File.open(@file, File::CREAT, 0755, 'test') }.should raise_error(ArgumentError) end it "raises an ArgumentError if passed an invalid string for mode" do - lambda { File.open(@file, 'fake') }.should raise_error(ArgumentError) + -> { File.open(@file, 'fake') }.should raise_error(ArgumentError) end it "defaults external_encoding to BINARY for binary modes" do @@ -570,17 +570,17 @@ describe "File.open" do end it "accepts extra flags as a keyword argument and combine with a string mode" do - lambda { + -> { File.open(@file, "w", flags: File::EXCL) { } }.should raise_error(Errno::EEXIST) - lambda { + -> { File.open(@file, mode: "w", flags: File::EXCL) { } }.should raise_error(Errno::EEXIST) end it "accepts extra flags as a keyword argument and combine with an integer mode" do - lambda { + -> { File.open(@file, File::WRONLY | File::CREAT, flags: File::EXCL) { } }.should raise_error(Errno::EEXIST) end @@ -641,12 +641,12 @@ describe "File.open" do it "throws a Errno::EEXIST error if the file exists" do touch @xfile - lambda { File.open(@xfile, "wx") }.should raise_error(Errno::EEXIST) + -> { File.open(@xfile, "wx") }.should raise_error(Errno::EEXIST) end it "can't be used with 'r' and 'a' flags" do - lambda { File.open(@xfile, "rx") }.should raise_error(ArgumentError, 'invalid access mode rx') - lambda { File.open(@xfile, "ax") }.should raise_error(ArgumentError, 'invalid access mode ax') + -> { File.open(@xfile, "rx") }.should raise_error(ArgumentError, 'invalid access mode rx') + -> { File.open(@xfile, "ax") }.should raise_error(ArgumentError, 'invalid access mode ax') end end end diff --git a/spec/ruby/core/file/printf_spec.rb b/spec/ruby/core/file/printf_spec.rb index 95ce3589c5..2530419fc7 100644 --- a/spec/ruby/core/file/printf_spec.rb +++ b/spec/ruby/core/file/printf_spec.rb @@ -2,7 +2,7 @@ require_relative '../../spec_helper' require_relative '../kernel/shared/sprintf' describe "File#printf" do - it_behaves_like :kernel_sprintf, -> (format, *args) { + it_behaves_like :kernel_sprintf, -> format, *args { begin @filename = tmp("printf.txt") diff --git a/spec/ruby/core/file/readlink_spec.rb b/spec/ruby/core/file/readlink_spec.rb index 7b1fe74047..eb3bfda30e 100644 --- a/spec/ruby/core/file/readlink_spec.rb +++ b/spec/ruby/core/file/readlink_spec.rb @@ -26,12 +26,12 @@ describe "File.readlink" do it "raises an Errno::ENOENT if there is no such file" do # TODO: missing_file - lambda { File.readlink("/this/surely/doesnt/exist") }.should raise_error(Errno::ENOENT) + -> { File.readlink("/this/surely/doesnt/exist") }.should raise_error(Errno::ENOENT) end it "raises an Errno::EINVAL if called with a normal file" do touch @file - lambda { File.readlink(@file) }.should raise_error(Errno::EINVAL) + -> { File.readlink(@file) }.should raise_error(Errno::EINVAL) end end diff --git a/spec/ruby/core/file/realdirpath_spec.rb b/spec/ruby/core/file/realdirpath_spec.rb index 9c90d7330f..74053afce3 100644 --- a/spec/ruby/core/file/realdirpath_spec.rb +++ b/spec/ruby/core/file/realdirpath_spec.rb @@ -61,7 +61,7 @@ platform_is_not :windows do it "raises an Errno::ELOOP if the symlink points to itself" do File.unlink @link File.symlink(@link, @link) - lambda { File.realdirpath(@link) }.should raise_error(Errno::ELOOP) + -> { File.realdirpath(@link) }.should raise_error(Errno::ELOOP) end it "returns the real (absolute) pathname if the file is absent" do @@ -69,7 +69,7 @@ platform_is_not :windows do end it "raises Errno::ENOENT if the directory is absent" do - lambda { File.realdirpath(@fake_file_in_fake_dir) }.should raise_error(Errno::ENOENT) + -> { File.realdirpath(@fake_file_in_fake_dir) }.should raise_error(Errno::ENOENT) end it "returns the real (absolute) pathname if the symlink points to an absent file" do @@ -77,7 +77,7 @@ platform_is_not :windows do end it "raises Errno::ENOENT if the symlink points to an absent directory" do - lambda { File.realdirpath(@fake_link_to_fake_dir) }.should raise_error(Errno::ENOENT) + -> { File.realdirpath(@fake_link_to_fake_dir) }.should raise_error(Errno::ENOENT) end end end diff --git a/spec/ruby/core/file/realpath_spec.rb b/spec/ruby/core/file/realpath_spec.rb index d7bb842759..0c5d19287a 100644 --- a/spec/ruby/core/file/realpath_spec.rb +++ b/spec/ruby/core/file/realpath_spec.rb @@ -57,15 +57,15 @@ platform_is_not :windows do it "raises an Errno::ELOOP if the symlink points to itself" do File.unlink @link File.symlink(@link, @link) - lambda { File.realpath(@link) }.should raise_error(Errno::ELOOP) + -> { File.realpath(@link) }.should raise_error(Errno::ELOOP) end it "raises Errno::ENOENT if the file is absent" do - lambda { File.realpath(@fake_file) }.should raise_error(Errno::ENOENT) + -> { File.realpath(@fake_file) }.should raise_error(Errno::ENOENT) end it "raises Errno::ENOENT if the symlink points to an absent file" do - lambda { File.realpath(@fake_link) }.should raise_error(Errno::ENOENT) + -> { File.realpath(@fake_link) }.should raise_error(Errno::ENOENT) end end end diff --git a/spec/ruby/core/file/rename_spec.rb b/spec/ruby/core/file/rename_spec.rb index 5f47000d38..d903e7a0d5 100644 --- a/spec/ruby/core/file/rename_spec.rb +++ b/spec/ruby/core/file/rename_spec.rb @@ -23,15 +23,15 @@ describe "File.rename" do it "raises an Errno::ENOENT if the source does not exist" do rm_r @old - lambda { File.rename(@old, @new) }.should raise_error(Errno::ENOENT) + -> { File.rename(@old, @new) }.should raise_error(Errno::ENOENT) end it "raises an ArgumentError if not passed two arguments" do - lambda { File.rename }.should raise_error(ArgumentError) - lambda { File.rename(@file) }.should raise_error(ArgumentError) + -> { File.rename }.should raise_error(ArgumentError) + -> { File.rename(@file) }.should raise_error(ArgumentError) end it "raises a TypeError if not passed String types" do - lambda { File.rename(1, 2) }.should raise_error(TypeError) + -> { File.rename(1, 2) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/file/shared/fnmatch.rb b/spec/ruby/core/file/shared/fnmatch.rb index 49a870e95a..a8488fd30a 100644 --- a/spec/ruby/core/file/shared/fnmatch.rb +++ b/spec/ruby/core/file/shared/fnmatch.rb @@ -218,21 +218,21 @@ describe :file_fnmatch, shared: true do end it "raises a TypeError if the first and second arguments are not string-like" do - lambda { File.send(@method, nil, nil, 0, 0) }.should raise_error(ArgumentError) - lambda { File.send(@method, 1, 'some/thing') }.should raise_error(TypeError) - lambda { File.send(@method, 'some/thing', 1) }.should raise_error(TypeError) - lambda { File.send(@method, 1, 1) }.should raise_error(TypeError) + -> { File.send(@method, nil, nil, 0, 0) }.should raise_error(ArgumentError) + -> { File.send(@method, 1, 'some/thing') }.should raise_error(TypeError) + -> { File.send(@method, 'some/thing', 1) }.should raise_error(TypeError) + -> { File.send(@method, 1, 1) }.should raise_error(TypeError) end it "raises a TypeError if the third argument is not an Integer" do - lambda { File.send(@method, "*/place", "path/to/file", "flags") }.should raise_error(TypeError) - lambda { File.send(@method, "*/place", "path/to/file", nil) }.should raise_error(TypeError) + -> { File.send(@method, "*/place", "path/to/file", "flags") }.should raise_error(TypeError) + -> { File.send(@method, "*/place", "path/to/file", nil) }.should raise_error(TypeError) end it "does not raise a TypeError if the third argument can be coerced to an Integer" do flags = mock("flags") flags.should_receive(:to_int).and_return(10) - lambda { File.send(@method, "*/place", "path/to/file", flags) }.should_not raise_error + -> { File.send(@method, "*/place", "path/to/file", flags) }.should_not raise_error end it "matches multibyte characters" do diff --git a/spec/ruby/core/file/shared/read.rb b/spec/ruby/core/file/shared/read.rb index 7fff7f29d6..a2d479966d 100644 --- a/spec/ruby/core/file/shared/read.rb +++ b/spec/ruby/core/file/shared/read.rb @@ -3,13 +3,13 @@ require_relative '../../dir/fixtures/common' describe :file_read_directory, shared: true do platform_is :darwin, :linux, :openbsd, :windows do it "raises an Errno::EISDIR when passed a path that is a directory" do - lambda { @object.send(@method, ".") }.should raise_error(Errno::EISDIR) + -> { @object.send(@method, ".") }.should raise_error(Errno::EISDIR) end end platform_is :freebsd, :netbsd do it "does not raises any exception when passed a path that is a directory" do - lambda { @object.send(@method, ".") }.should_not raise_error + -> { @object.send(@method, ".") }.should_not raise_error end end end diff --git a/spec/ruby/core/file/shared/stat.rb b/spec/ruby/core/file/shared/stat.rb index aac710dd2f..fdaf97ea61 100644 --- a/spec/ruby/core/file/shared/stat.rb +++ b/spec/ruby/core/file/shared/stat.rb @@ -25,7 +25,7 @@ describe :file_stat, shared: true do end it "raises an Errno::ENOENT if the file does not exist" do - lambda { + -> { File.send(@method, "fake_file") }.should raise_error(Errno::ENOENT) end diff --git a/spec/ruby/core/file/shared/unlink.rb b/spec/ruby/core/file/shared/unlink.rb index 42b6a77c5d..d72ab4701f 100644 --- a/spec/ruby/core/file/shared/unlink.rb +++ b/spec/ruby/core/file/shared/unlink.rb @@ -31,11 +31,11 @@ describe :file_unlink, shared: true do end it "raises a TypeError if not passed a String type" do - lambda { File.send(@method, 1) }.should raise_error(TypeError) + -> { File.send(@method, 1) }.should raise_error(TypeError) end it "raises an Errno::ENOENT when the given file doesn't exist" do - lambda { File.send(@method, 'bogus') }.should raise_error(Errno::ENOENT) + -> { File.send(@method, 'bogus') }.should raise_error(Errno::ENOENT) end it "coerces a given parameter into a string if possible" do diff --git a/spec/ruby/core/file/size_spec.rb b/spec/ruby/core/file/size_spec.rb index b0ab2c0651..a2bf408da1 100644 --- a/spec/ruby/core/file/size_spec.rb +++ b/spec/ruby/core/file/size_spec.rb @@ -81,7 +81,7 @@ describe "File#size" do it "raises an IOError on a closed file" do @file.close - lambda { @file.size }.should raise_error(IOError) + -> { @file.size }.should raise_error(IOError) end platform_is_not :windows do diff --git a/spec/ruby/core/file/split_spec.rb b/spec/ruby/core/file/split_spec.rb index 2b22b0a08f..7b958621b9 100644 --- a/spec/ruby/core/file/split_spec.rb +++ b/spec/ruby/core/file/split_spec.rb @@ -44,12 +44,12 @@ describe "File.split" do end it "raises an ArgumentError when not passed a single argument" do - lambda { File.split }.should raise_error(ArgumentError) - lambda { File.split('string', 'another string') }.should raise_error(ArgumentError) + -> { File.split }.should raise_error(ArgumentError) + -> { File.split('string', 'another string') }.should raise_error(ArgumentError) end it "raises a TypeError if the argument is not a String type" do - lambda { File.split(1) }.should raise_error(TypeError) + -> { File.split(1) }.should raise_error(TypeError) end it "coerces the argument with to_str if it is not a String type" do diff --git a/spec/ruby/core/file/stat/birthtime_spec.rb b/spec/ruby/core/file/stat/birthtime_spec.rb index 40e501e87b..a727bbe566 100644 --- a/spec/ruby/core/file/stat/birthtime_spec.rb +++ b/spec/ruby/core/file/stat/birthtime_spec.rb @@ -21,7 +21,7 @@ describe "File::Stat#birthtime" do platform_is :linux, :openbsd do it "raises an NotImplementedError" do st = File.stat(@file) - lambda { st.birthtime }.should raise_error(NotImplementedError) + -> { st.birthtime }.should raise_error(NotImplementedError) end end end diff --git a/spec/ruby/core/file/stat/new_spec.rb b/spec/ruby/core/file/stat/new_spec.rb index f5f22e6711..c0d9432ac8 100644 --- a/spec/ruby/core/file/stat/new_spec.rb +++ b/spec/ruby/core/file/stat/new_spec.rb @@ -13,7 +13,7 @@ describe "File::Stat#initialize" do end it "raises an exception if the file doesn't exist" do - lambda { + -> { File::Stat.new(tmp("i_am_a_dummy_file_that_doesnt_exist")) }.should raise_error(Errno::ENOENT) end diff --git a/spec/ruby/core/file/symlink_spec.rb b/spec/ruby/core/file/symlink_spec.rb index a8486db04a..0e8b0a5a20 100644 --- a/spec/ruby/core/file/symlink_spec.rb +++ b/spec/ruby/core/file/symlink_spec.rb @@ -32,18 +32,18 @@ describe "File.symlink" do it "raises an Errno::EEXIST if the target already exists" do File.symlink(@file, @link) - lambda { File.symlink(@file, @link) }.should raise_error(Errno::EEXIST) + -> { File.symlink(@file, @link) }.should raise_error(Errno::EEXIST) end it "raises an ArgumentError if not called with two arguments" do - lambda { File.symlink }.should raise_error(ArgumentError) - lambda { File.symlink(@file) }.should raise_error(ArgumentError) + -> { File.symlink }.should raise_error(ArgumentError) + -> { File.symlink(@file) }.should raise_error(ArgumentError) end it "raises a TypeError if not called with String types" do - lambda { File.symlink(@file, nil) }.should raise_error(TypeError) - lambda { File.symlink(@file, 1) }.should raise_error(TypeError) - lambda { File.symlink(1, 1) }.should raise_error(TypeError) + -> { File.symlink(@file, nil) }.should raise_error(TypeError) + -> { File.symlink(@file, 1) }.should raise_error(TypeError) + -> { File.symlink(1, 1) }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/file/truncate_spec.rb b/spec/ruby/core/file/truncate_spec.rb index 36fe26a2fe..43b86b7382 100644 --- a/spec/ruby/core/file/truncate_spec.rb +++ b/spec/ruby/core/file/truncate_spec.rb @@ -54,29 +54,29 @@ describe "File.truncate" do rm_r not_existing_file begin - lambda { File.truncate(not_existing_file, 5) }.should raise_error(Errno::ENOENT) + -> { File.truncate(not_existing_file, 5) }.should raise_error(Errno::ENOENT) ensure rm_r not_existing_file end end it "raises an ArgumentError if not passed two arguments" do - lambda { File.truncate }.should raise_error(ArgumentError) - lambda { File.truncate(@name) }.should raise_error(ArgumentError) + -> { File.truncate }.should raise_error(ArgumentError) + -> { File.truncate(@name) }.should raise_error(ArgumentError) end platform_is_not :netbsd, :openbsd do it "raises an Errno::EINVAL if the length argument is not valid" do - lambda { File.truncate(@name, -1) }.should raise_error(Errno::EINVAL) # May fail + -> { File.truncate(@name, -1) }.should raise_error(Errno::EINVAL) # May fail end end it "raises a TypeError if not passed a String type for the first argument" do - lambda { File.truncate(1, 1) }.should raise_error(TypeError) + -> { File.truncate(1, 1) }.should raise_error(TypeError) end it "raises a TypeError if not passed an Integer type for the second argument" do - lambda { File.truncate(@name, nil) }.should raise_error(TypeError) + -> { File.truncate(@name, nil) }.should raise_error(TypeError) end it "accepts an object that has a #to_path method" do @@ -149,29 +149,29 @@ describe "File#truncate" do end it "raises an ArgumentError if not passed one argument" do - lambda { @file.truncate }.should raise_error(ArgumentError) - lambda { @file.truncate(1) }.should_not raise_error(ArgumentError) + -> { @file.truncate }.should raise_error(ArgumentError) + -> { @file.truncate(1) }.should_not raise_error(ArgumentError) end platform_is_not :netbsd do it "raises an Errno::EINVAL if the length argument is not valid" do - lambda { @file.truncate(-1) }.should raise_error(Errno::EINVAL) # May fail + -> { @file.truncate(-1) }.should raise_error(Errno::EINVAL) # May fail end end it "raises an IOError if file is closed" do @file.close @file.closed?.should == true - lambda { @file.truncate(42) }.should raise_error(IOError) + -> { @file.truncate(42) }.should raise_error(IOError) end it "raises an IOError if file is not opened for writing" do File.open(@name, 'r') do |file| - lambda { file.truncate(42) }.should raise_error(IOError) + -> { file.truncate(42) }.should raise_error(IOError) end end it "raises a TypeError if not passed an Integer type for the for the argument" do - lambda { @file.truncate(nil) }.should raise_error(TypeError) + -> { @file.truncate(nil) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/file/umask_spec.rb b/spec/ruby/core/file/umask_spec.rb index 9a4beb8998..2640e3c316 100644 --- a/spec/ruby/core/file/umask_spec.rb +++ b/spec/ruby/core/file/umask_spec.rb @@ -52,6 +52,6 @@ describe "File.umask" do end it "raises ArgumentError when more than one argument is provided" do - lambda { File.umask(022, 022) }.should raise_error(ArgumentError) + -> { File.umask(022, 022) }.should raise_error(ArgumentError) end end |