Class TempPathTest
In: lib/temp_path.rb
Parent: Test::Unit::TestCase

Methods

Public Instance methods

[Source]

# 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

[Source]

# File lib/temp_path.rb, line 181
    def teardown
      @list.each { |l| l.clean }
      [@foo, @foobar].each { |l| l.clean }
    end

[Source]

# 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

[Source]

# File lib/temp_path.rb, line 202
    def test_different
      assert_not_equal TempPath.new, TempPath.new
    end

[Source]

# 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

[Source]

# 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

[Source]

# File lib/temp_path.rb, line 206
    def test_temp?
      assert(@foo.temp?, 'not tmp.temp?')
      assert_nothing_raised do
        assert(!Pathname.new(@foo.to_s).temp?)
      end
    end

[Validate]