Sha256: 9a084847d5a0efa26975c436043c5d874272bce25655e628e41cf924654f1269

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

require "isolate"
require "minitest/autorun"
require "stringio" # avoid resets via LOADED_FEATURES teardown below

ENV.delete "RUBYOPT" # Rakefile uses isolate, so we don't want this

module Isolate
  Sandbox::DEFAULT_PATH.replace "tmp/test" # change isolate dir for testing

  class Test < Minitest::Test
    def setup
      Isolate.refresh

      @env = ENV.to_hash
      @lp  = $LOAD_PATH.dup
      @lf  = $LOADED_FEATURES.dup
    end

    def teardown
      Gem::DependencyInstaller.reset_value
      Gem::Uninstaller.reset_value

      ENV.replace @env
      $LOAD_PATH.replace @lp
      $LOADED_FEATURES.replace @lf

      FileUtils.rm_rf "tmp/test"
    end
  end
end

module BrutalStub
  @@value = []
  def value; @@value end
  def reset_value; value.clear end
end

class Gem::DependencyInstaller
  extend BrutalStub

  alias old_install install
  def install name, requirement
    self.class.value << [name, requirement]
  end
end

class Gem::Uninstaller
  extend BrutalStub

  attr_reader :gem, :version
  alias old_uninstall uninstall

  def uninstall
    self.class.value << [self.gem,
                         self.version.to_s,
                         self.gem_home.sub(Dir.pwd + "/", '')]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
isolate-4.0.0 test/isolate/test.rb
isolate-3.5.1 test/isolate/test.rb
isolate-3.5.0 test/isolate/test.rb
isolate-3.4.0 test/isolate/test.rb
isolate-3.3.1 test/isolate/test.rb
isolate-3.2.4 test/isolate/test.rb