summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/tempfile.rb2
-rw-r--r--test/test_tempfile.rb7
-rw-r--r--version.h2
3 files changed, 9 insertions, 2 deletions
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 223637f84a..a0f3fdd90a 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -227,7 +227,7 @@ class Tempfile < DelegateClass(File)
if !@tmpfile.closed?
@tmpfile.size # File#size calls rb_io_flush_raw()
else
- File.size?(@tmpfile.path)
+ File.size(@tmpfile.path)
end
end
alias length size
diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb
index c8af2f5b4d..21edf39776 100644
--- a/test/test_tempfile.rb
+++ b/test/test_tempfile.rb
@@ -243,6 +243,13 @@ puts Tempfile.new('foo').path
assert_equal 5, t.size
end
+ def test_size_on_empty_file
+ t = tempfile("foo")
+ t.write("")
+ t.close
+ assert_equal 0, t.size
+ end
+
def test_concurrency
threads = []
tempfiles = []
diff --git a/version.h b/version.h
index 394769aab6..08935639f6 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.3"
#define RUBY_RELEASE_DATE "2017-03-27"
-#define RUBY_PATCHLEVEL 265
+#define RUBY_PATCHLEVEL 266
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 3