summaryrefslogtreecommitdiff
path: root/test/test_tempfile.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-11 21:42:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-11 21:42:40 +0000
commit55179696b20fade5a994d711b6fba9901eeb839d (patch)
tree193d912ab0b810b77d235b58f390501341f3c803 /test/test_tempfile.rb
parent9a751c21e7151511762c81e78e5e2a39b30ff33e (diff)
* lib/tempfile.rb (Tempfile#initialize): option hash may not be
given. [ruby-core:26681] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_tempfile.rb')
-rw-r--r--test/test_tempfile.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb
index 9a90d605ee..073a11e15a 100644
--- a/test/test_tempfile.rb
+++ b/test/test_tempfile.rb
@@ -3,6 +3,11 @@ require 'tempfile'
require_relative 'ruby/envutil'
class TestTempfile < Test::Unit::TestCase
+ def initialize(*)
+ super
+ @tempfile = nil
+ end
+
def tempfile(*args, &block)
t = Tempfile.new(*args, &block)
@tempfile = (t unless block)
@@ -45,13 +50,13 @@ class TestTempfile < Test::Unit::TestCase
def test_basename
t = tempfile("foo")
- assert_match /^foo/, File.basename(t.path)
+ assert_match(/^foo/, File.basename(t.path))
end
def test_basename_with_suffix
t = tempfile(["foo", ".txt"])
- assert_match /^foo/, File.basename(t.path)
- assert_match /\.txt$/, File.basename(t.path)
+ assert_match(/^foo/, File.basename(t.path))
+ assert_match(/\.txt$/, File.basename(t.path))
end
def test_unlink
@@ -284,5 +289,14 @@ puts Tempfile.new('foo').path
t.rewind
assert_equal(Encoding::ASCII_8BIT,t.read.encoding)
end
+
+ def test_binmode
+ t = tempfile("TEST", mode: IO::BINARY)
+ if IO::BINARY.nonzero?
+ assert(t.binmode?)
+ else
+ assert_equal(0600, t.stat.mode & 0777)
+ end
+ end
end