diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-20 20:38:57 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-20 20:38:57 +0000 |
commit | 6204e0804b24f1675b49d5880da014411bcfb831 (patch) | |
tree | ce6c00bf078fc416936ca3cdc972b9b3c1c78dae /spec/ruby/core/file | |
parent | 58573c33e4720315ed27491e31dcc22892e1ce95 (diff) | |
download | ruby-6204e0804b24f1675b49d5880da014411bcfb831.tar.gz |
Update to ruby/spec@35a9fba
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/file')
-rw-r--r-- | spec/ruby/core/file/open_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb index c6a0b68233..c37e7316ba 100644 --- a/spec/ruby/core/file/open_spec.rb +++ b/spec/ruby/core/file/open_spec.rb @@ -638,6 +638,33 @@ describe "File.open" do end end + ruby_version_is "2.6" do + context "'x' flag" do + before :each do + @xfile = tmp("x-flag") + rm_r @xfile + end + + after :each do + rm_r @xfile + end + + it "does nothing if the file doesn't exist" do + File.open(@xfile, "wx") { |f| f.write("content") } + File.read(@xfile).should == "content" + end + + it "throws a Errno::EEXIST error if the file exists" do + touch @xfile + lambda { 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') + end + end + end end describe "File.open when passed a file descriptor" do |