File: test_helper.rb

package info (click to toggle)
ruby-fakefs 0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 432 kB
  • sloc: ruby: 5,528; makefile: 3
file content (31 lines) | stat: -rw-r--r-- 672 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'fakefs/safe'
require 'minitest/autorun'

def act_on_real_fs(&block)
  FakeFS.without(&block)
end

def capture_stderr
  real_stderr, $stderr = $stderr, StringIO.new

  # force FileUtils to use our stderr
  RealFileUtils.instance_variable_set('@fileutils_output', $stderr)

  yield

  $stderr.string
ensure
  $stderr = real_stderr

  # restore FileUtils stderr
  RealFileUtils.instance_variable_set('@fileutils_output', $stderr)
end

def real_file_sandbox(path = nil)
  base_path = real_file_sandbox_path
  path ? File.join(base_path, path) : base_path
end

def real_file_sandbox_path
  File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_sandbox'))
end