Class: Rspec::Shell::Expectations::StubbedEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/shell/expectations/stubbed_env.rb

Overview

A shell environment that can manipulate behaviour of executables

Instance Method Summary collapse

Constructor Details

#initializeStubbedEnv

Returns a new instance of StubbedEnv.



16
17
18
19
# File 'lib/rspec/shell/expectations/stubbed_env.rb', line 16

def initialize
  @dir = Dir.mktmpdir
  at_exit { FileUtils.remove_entry_secure @dir }
end

Instance Method Details

#execute(command, env_vars = {}) ⇒ Object



25
26
27
# File 'lib/rspec/shell/expectations/stubbed_env.rb', line 25

def execute(command, env_vars = {})
  Open3.capture3(env_vars, "#{env} #{command}")
end

#stub_command(command) ⇒ Object



21
22
23
# File 'lib/rspec/shell/expectations/stubbed_env.rb', line 21

def stub_command(command)
  StubbedCommand.new command, @dir
end