diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-01 15:41:50 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-01 15:41:50 +0000 |
commit | 4d7b0b9112f2adf9e87ef75056f930bf7c1f3dc4 (patch) | |
tree | 8d712e18a619a9720d181d0d44e8cc2474ff31ee /spec/ruby/core/file | |
parent | 821d9a2d30f2e0d3f9009dc001b4b49aaa63c66e (diff) | |
download | ruby-4d7b0b9112f2adf9e87ef75056f930bf7c1f3dc4.tar.gz |
Update to ruby/spec@bacedc5
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/file')
-rw-r--r-- | spec/ruby/core/file/printf_spec.rb | 18 | ||||
-rw-r--r-- | spec/ruby/core/file/stat/blocks_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/file/stat/new_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/file/utime_spec.rb | 11 |
4 files changed, 34 insertions, 3 deletions
diff --git a/spec/ruby/core/file/printf_spec.rb b/spec/ruby/core/file/printf_spec.rb new file mode 100644 index 0000000000..8423c010ab --- /dev/null +++ b/spec/ruby/core/file/printf_spec.rb @@ -0,0 +1,18 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../../kernel/shared/sprintf', __FILE__) + +describe "File#printf" do + it_behaves_like :kernel_sprintf, -> (format, *args) { + begin + @filename = tmp("printf.txt") + + File.open(@filename, "w", encoding: "utf-8") do |f| + f.printf(format, *args) + end + + File.read(@filename, encoding: "utf-8") + ensure + rm_r @filename + end + } +end diff --git a/spec/ruby/core/file/stat/blocks_spec.rb b/spec/ruby/core/file/stat/blocks_spec.rb index ca0fd2c8a6..e84e822a27 100644 --- a/spec/ruby/core/file/stat/blocks_spec.rb +++ b/spec/ruby/core/file/stat/blocks_spec.rb @@ -11,10 +11,10 @@ describe "File::Stat#blocks" do end platform_is_not :windows do - it "returns the blocks of a File::Stat object" do + it "returns a non-negative integer" do st = File.stat(@file) st.blocks.is_a?(Integer).should == true - st.blocks.should > 0 + st.blocks.should >= 0 end end diff --git a/spec/ruby/core/file/stat/new_spec.rb b/spec/ruby/core/file/stat/new_spec.rb index ec7d81362f..4579c4a807 100644 --- a/spec/ruby/core/file/stat/new_spec.rb +++ b/spec/ruby/core/file/stat/new_spec.rb @@ -13,7 +13,9 @@ 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 + lambda { + File::Stat.new(tmp("i_am_a_dummy_file_that_doesnt_exist")) + }.should raise_error(Errno::ENOENT) end it "creates a File::Stat object for the given file" do diff --git a/spec/ruby/core/file/utime_spec.rb b/spec/ruby/core/file/utime_spec.rb index 73112420d1..e586029715 100644 --- a/spec/ruby/core/file/utime_spec.rb +++ b/spec/ruby/core/file/utime_spec.rb @@ -33,4 +33,15 @@ describe "File.utime" do it "accepts an object that has a #to_path method" do File.utime(@atime, @mtime, mock_to_path(@file1), mock_to_path(@file2)) end + + platform_is :linux do + platform_is wordsize: 64 do + it "allows Time instances in the far future to set mtime and atime" do + time = Time.at(1<<44) + File.utime(time, time, @file1) + File.atime(@file1).year.should == 559444 + File.mtime(@file1).year.should == 559444 + end + end + end end |