| Class | TempPathTest |
| In: |
lib/temp_path.rb
|
| Parent: | Test::Unit::TestCase |
# File lib/temp_path.rb, line 175 def setup assert_nothing_raised { @foo = TempPath.new('foo') } assert_nothing_raised { @foobar = TempPath.new('foo', 'bar') } @list = [] end
# File lib/temp_path.rb, line 181 def teardown @list.each { |l| l.clean } [@foo, @foobar].each { |l| l.clean } end
# File lib/temp_path.rb, line 213 def test_block_return assert_nothing_raised do @x = TempPath.new { |tmp| 42 } end assert_equal(42, @x) end
# File lib/temp_path.rb, line 202 def test_different assert_not_equal TempPath.new, TempPath.new end
# File lib/temp_path.rb, line 186 def test_interface assert_match(/\.#{$$}\/foo\.-?\d+$/, @foo.to_s) assert_match(/\.#{$$}\/foo\.-?\d+\.bar$/, @foobar.to_s) assert_nothing_raised { @foo.open('w') { |f| f.puts 'FooFoo' } } end
# File lib/temp_path.rb, line 192 def test_many (0 .. 100).each do |i| tmp = TempPath.new('many') tmp.open('w') { |f| f.puts "i: #{i}" } assert(tmp.exist?) assert_equal("i: #{i}\n", tmp.readlines.join) @list << tmp end end