Sha256: e8377ce95fc644377ee69c443771d4ff18f06158439ea36a0ec6803a3810e157

Contents?: true

Size: 760 Bytes

Versions: 12

Compression:

Stored size: 760 Bytes

Contents

RealFile = File
RealFileUtils = FileUtils
RealDir = Dir
RealFileUtils::Dir = RealDir
RealFileUtils::File = RealFile

module FakeFS
  def self.activate!
    Object.class_eval do
      remove_const(:Dir)
      remove_const(:File)
      remove_const(:FileUtils)
      const_set(:Dir, FakeFS::Dir)
      const_set(:File, FakeFS::File)
      const_set(:FileUtils, FakeFS::FileUtils)
    end
  end

  def self.deactivate!
    Object.class_eval do
      remove_const(:Dir)
      remove_const(:File)
      remove_const(:FileUtils)
      const_set(:Dir, RealDir)
      const_set(:File, RealFile)
      const_set(:FileUtils, RealFileUtils)
    end
  end
end

def FakeFS
  return ::FakeFS unless block_given?
  ::FakeFS.activate!
  yield
ensure
::FakeFS.deactivate!
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/fakefs-0.2.1/lib/fakefs/base.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/fakefs-0.2.1/lib/fakefs/base.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/fakefs-0.2.1/lib/fakefs/base.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/fakefs-0.2.1/lib/fakefs/base.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/fakefs-0.2.1/lib/fakefs/base.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/fakefs-0.2.1/lib/fakefs/base.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/fakefs-0.2.1/lib/fakefs/base.rb
simple-templater-0.0.1.3 vendor/fakefs/lib/fakefs/base.rb
simple-templater-0.0.1.2 vendor/fakefs/lib/fakefs/base.rb
simple-templater-0.0.1.1 vendor/fakefs/lib/fakefs/base.rb
simple-templater-0.0.1 vendor/fakefs/lib/fakefs/base.rb
fakefs-0.2.1 lib/fakefs/base.rb