diff options
Diffstat (limited to 'spec/ruby/core/file/new_spec.rb')
-rw-r--r-- | spec/ruby/core/file/new_spec.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/spec/ruby/core/file/new_spec.rb b/spec/ruby/core/file/new_spec.rb index a1ca46979e..1e82a070b1 100644 --- a/spec/ruby/core/file/new_spec.rb +++ b/spec/ruby/core/file/new_spec.rb @@ -100,7 +100,7 @@ describe "File.new" do File.should.exist?(@file) end - it "raises an Errorno::EEXIST if the file exists when create a new file with File::CREAT|File::EXCL" do + it "raises an Errno::EEXIST if the file exists when create a new file with File::CREAT|File::EXCL" do -> { @fh = File.new(@file, File::CREAT|File::EXCL) }.should raise_error(Errno::EEXIST) end @@ -168,16 +168,14 @@ describe "File.new" do File.should.exist?(@file) end - ruby_version_is "3.0" do - it "accepts options as a keyword argument" do - @fh = File.new(@file, 'w', 0755, flags: @flags) - @fh.should be_kind_of(File) - @fh.close + it "accepts options as a keyword argument" do + @fh = File.new(@file, 'w', 0755, flags: @flags) + @fh.should be_kind_of(File) + @fh.close - -> { - @fh = File.new(@file, 'w', 0755, {flags: @flags}) - }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") - end + -> { + @fh = File.new(@file, 'w', 0755, {flags: @flags}) + }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") end it "bitwise-ORs mode and flags option" do @@ -190,6 +188,12 @@ describe "File.new" do }.should raise_error(Errno::EEXIST, /File exists/) end + it "does not use the given block and warns to use File::open" do + -> { + @fh = File.new(@file) { raise } + }.should complain(/warning: File::new\(\) does not take block; use File::open\(\) instead/) + end + it "raises a TypeError if the first parameter can't be coerced to a string" do -> { File.new(true) }.should raise_error(TypeError) -> { File.new(false) }.should raise_error(TypeError) |