override.rb

Path: mockfs/override.rb
Last Update: Sun Jun 11 17:37:46 EDT 2006

Include this file to redefine FileUtils, Dir, and File. The point of this is so that you can use MockFS to test a codebase that calls these classes directly instead of going through MockFS.file_utils, etc.

Please note that as of this writing (June 11, 2006), this file is still fairly experimental. Please exercise caution when relying on tests through this.

Required files

mockfs  

Methods

require  

Constants

OriginalFileUtils = FileUtils
OriginalDir = Dir
OriginalFile = File

Public Instance methods

mockfs/override.rb overrides Kernel.require to allow you to include Ruby files that are in the mock file system:

  require 'mockfs/override'
  MockFS.file.open( 'virtual.rb', 'w' ) do |f|
    f.puts "puts 'I am a ruby program living in a virtual file'"
  end
  require 'virtual.rb'
  require 'rexml'        # real files are still accessible

[Validate]