From c8726d8ed923ed867a89f55d39f45ff43aa06ff6 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 11 Nov 2009 21:42:40 +0000 Subject: * lib/tempfile.rb (Tempfile#initialize): option hash may not be given. [ruby-core:26681] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/test_tempfile.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index 9a90d605e..073a11e15 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 -- cgit