Module: RSpec::Support::ShellOut
- Defined in:
- lib/rspec/support/spec/shell_out.rb
Defined Under Namespace
Classes: FakeProcessStatus
Instance Method Summary
collapse
Instance Method Details
#run_ruby_with_current_load_path(ruby_command, *flags) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/rspec/support/spec/shell_out.rb', line 41
def run_ruby_with_current_load_path(ruby_command, *flags)
command = [
FileUtils::RUBY,
"-I#{$LOAD_PATH.map(&:shellescape).join(File::PATH_SEPARATOR)}",
"-e", ruby_command, *flags
]
with_env 'RUBY_GC_HEAP_FREE_SLOTS' => nil, 'RUBY_GC_MALLOC_LIMIT' => nil,
'RUBY_FREE_MIN' => nil do
shell_out(*command)
end
end
|
#shell_out(*command) ⇒ Object
20
21
22
23
|
# File 'lib/rspec/support/spec/shell_out.rb', line 20
def shell_out(*command)
stdout, stderr, status = Open3.capture3(*command)
return stdout, filter(stderr), status
end
|
#strip_known_warnings(input) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/rspec/support/spec/shell_out.rb', line 56
def strip_known_warnings(input)
input.split("\n").reject do |l|
l =~ %r{bundler/source/rubygems} ||
l =~ %r{site_ruby/\d\.\d\.\d/rubygems} ||
l =~ %r{lib/bundler/rubygems} ||
l =~ %r{lib/ruby/stdlib/jar}
end.join("\n")
end
|
#with_env(vars) ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/rspec/support/spec/shell_out.rb', line 8
def with_env(vars)
original = ENV.to_hash
vars.each { |k, v| ENV[k] = v }
begin
yield
ensure
ENV.replace(original)
end
end
|