# _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # # for lib/facet/file/self/open_as_string.rb # # Extracted Wed Jan 25 11:25:39 EST 2006 # Unit Tools Reap Test Extractor # require 'facet/file/self/open_as_string.rb' require 'test/unit' # FIND TEST DIRECTORY paths = File.expand_path(File.dirname(__FILE__)).split('/') paths.size.downto(1) do |i| f = (paths.slice(0..i)+['test']).join('/') $TESTDIR = File.join(f,'FIXTURE') if File.directory?(f) end raise unless $TESTDIR class TC_OPEN_AS_STRING < Test::Unit::TestCase def test_open_as_string f = File.join( $TESTDIR, 'open_as_string_file' ) t = 'This is a test' File.open( f, 'w' ) { |s| s << t } assert( File.exists?( f ) ) File.open_as_string(f) { |s| s.reverse! } s = File.read( f ) assert_equal( t.reverse, s ) end end