= Document Unit Testing Load the Folio library. require 'folio' Instantiate document object. @foo = Folio.file('fixtures/foo.txt') Confirm it is a a document. @foo.assert.document? Confirm it is equal to another document initialized identically. @foo.assert == Folio.file('fixtures/foo.txt') Confirm it is equal to the same file initialized from a different working directory. f = nil Dir.chdir('fixtures') do f = Folio.file('foo.txt') end @foo.assert == f Document can be read. @foo.read.assert == "THIS IS FOO!\n" The #readlines methods read the document into an array of lines. @foo.readlines.assert == ["THIS IS FOO!\n"] We can also open the document for reading using the more traditional open() method. t = nil @foo.open('r'){ |f| t = f.read } t.assert == "THIS IS FOO!\n" The #parent method return the Directory object in which the document is contained. @foo.parent.assert == Folio.file('fixtures') A document can be written to as well using the #write method. out = Folio.doc('fixtures/out.txt') out.write('Hello') File.read(out.to_s).assert == 'Hello'