aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/file/open_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/file/open_spec.rb')
-rw-r--r--spec/ruby/core/file/open_spec.rb84
1 files changed, 42 insertions, 42 deletions
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