Class: Rspec::Shell::Expectations::StubbedEnv
- Inherits:
-
Object
- Object
- Rspec::Shell::Expectations::StubbedEnv
- Defined in:
- lib/rspec/shell/expectations/stubbed_env.rb
Overview
A shell environment that can manipulate behaviour of executables
Instance Method Summary collapse
- #execute(command, env_vars = {}) ⇒ Object
-
#initialize ⇒ StubbedEnv
constructor
A new instance of StubbedEnv.
- #stub_command(command) ⇒ Object
Constructor Details
#initialize ⇒ StubbedEnv
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 |