Sha256: 233f5816b396bbdce673d3f4891d050a8556eeaa0caf021979803d342cf5e931

Contents?: true

Size: 596 Bytes

Versions: 11

Compression:

Stored size: 596 Bytes

Contents

require 'facets/file/create'
require 'test/unit'
#require 'tempfile'

class Tets_File_Create < Test::Unit::TestCase

   class MockFile < ::File
     def self.open( fname, mode, &blk )
       blk.call(self)
     end
     def self.read( fname=nil )
       @mock_content.clone
     end
     def self.write( str )
       @mock_content = str
     end
     def self.<<( str )
       (@mock_content ||="") << str
     end
   end

   def test_create
     f = "not-a-real-file.txt"
     t = 'This is a test!'
     MockFile.create( f, t )
     s = MockFile.read( f )
     assert_equal( t, s )
   end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
facets-2.8.4 test/core/file/test_create.rb
facets-2.8.3 test/core/file/test_create.rb
facets-2.8.2 test/core/file/test_create.rb
facets-2.8.1 test/core/file/test_create.rb
facets-2.8.0 test/core/file/test_create.rb
facets-2.7.0 test/core/file/test_create.rb
facets-2.6.0 test/core/file/test_create.rb
facets-2.5.1 test/core/file/test_create.rb
facets-2.5.0 test/core/file/test_create.rb
facets-2.4.5 test/core/file/test_create.rb
facets-2.5.2 test/core/file/test_create.rb