Sha256: e063fdd7f9719ef08b12578ac4c9628c4eaa5098cb43273a0039ac5c5b9034d3

Contents?: true

Size: 579 Bytes

Versions: 19

Compression:

Stored size: 579 Bytes

Contents

# encoding: utf-8

require 'tmpdir'
require 'fileutils'

shared_context 'isolated environment', :isolated_environment do
  around do |example|
    Dir.mktmpdir do |tmpdir|
      original_home = ENV['HOME']

      begin
        virtual_home = File.expand_path(File.join(tmpdir, 'home'))
        Dir.mkdir(virtual_home)
        ENV['HOME'] = virtual_home

        working_dir = File.join(tmpdir, 'work')
        Dir.mkdir(working_dir)

        Dir.chdir(working_dir) do
          example.run
        end
      ensure
        ENV['HOME'] = original_home
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
rubocop-0.15.0 spec/support/isolated_environment.rb
rubocop-0.14.1 spec/support/isolated_environment.rb
rubocop-0.14.0 spec/support/isolated_environment.rb
rubocop-0.13.1 spec/support/isolated_environment.rb
rubocop-0.13.0 spec/support/isolated_environment.rb
rubocop-0.12.0 spec/support/isolated_environment.rb
rubocop-0.11.1 spec/support/isolated_environment.rb
rubocop-0.11.0 spec/support/isolated_environment.rb
rubocop-0.10.0 spec/support/isolated_environment.rb
rubocop-0.9.1 spec/support/isolated_environment.rb
sabat-rubocop-0.9.0 spec/support/isolated_environment.rb
rubocop-0.9.0 spec/support/isolated_environment.rb
rubocop-0.8.3 spec/support/isolated_environment.rb
rubocop-0.8.2 spec/support/isolated_environment.rb
rubocop-0.8.1 spec/support/isolated_environment.rb
rubocop-0.8.0 spec/support/isolated_environment.rb
rubocop-0.7.2 spec/support/isolated_environment.rb
rubocop-0.7.1 spec/support/isolated_environment.rb
rubocop-0.7.0 spec/support/isolated_environment.rb