Sha256: e326a0f0a298a5eed1daa82569e7935eb117df457be27305006a89ee5236341c

Contents?: true

Size: 939 Bytes

Versions: 1

Compression:

Stored size: 939 Bytes

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/facets/core/file/self/open_as_string.rb
#
# Extracted Fri Feb 16 02:00:36 EST 2007
# Project.rb Test Extraction
#

require 'facets/core/file/self/open_as_string.rb'


  require 'test/unit'

  # mock File class

  class File
    def self.mock_content( content )
      @mock_content = content
    end

    def self.open( name, mode, &blk )
      blk.call( self )
    end
    def self.read( fname=nil )
      @mock_content.clone
    end
    def self.write( str )
      @mock_content = str
    end
  end


  class TC_OPEN_AS_STRING < Test::Unit::TestCase

    def test_open_as_string
      f = "not a real file"
      t = 'This is a test'
      File.mock_content( t )
      File.open_as_string(f) { |s| s.reverse! }
      s = File.read(f)
      assert_equal( t.reverse, s )
    end

  end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-1.8.49 test/lib/facets/core/file/self/test_open_as_string.rb