File: isolated_home_directory.rb

package info (click to toggle)
ruby-rspec 3.5.0c3e0m0s0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,312 kB
  • ctags: 4,788
  • sloc: ruby: 62,572; sh: 785; makefile: 100
file content (20 lines) | stat: -rw-r--r-- 402 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'tmpdir'
require 'fileutils'

RSpec.shared_context "isolated home directory" do
  around do |ex|
    Dir.mktmpdir do |tmp_dir|
      original_home = ENV['HOME']
      begin
        ENV['HOME'] = tmp_dir
        ex.call
      ensure
        ENV['HOME'] = original_home
      end
    end
  end
end

RSpec.configure do |c|
  c.include_context "isolated home directory", :isolated_home => true
end