class Rspec::Shell::Expectations::StubbedCommand
Command that produces specific output and monitors input
Public Class Methods
new(command, dir)
click to toggle source
# File lib/rspec/shell/expectations/stubbed_command.rb, line 7 def initialize(command, dir) FileUtils.cp(stub_filepath, File.join(dir, command)) @call_configuration = CallConfiguration.new( Pathname.new(dir).join("#{command}_stub.yml"), command ) @call_log = CallLog.new( Pathname.new(dir).join("#{command}_calls.yml") ) end
Public Instance Methods
called?()
click to toggle source
# File lib/rspec/shell/expectations/stubbed_command.rb, line 22 def called? with_args.called? end
called_with_args?(*args)
click to toggle source
# File lib/rspec/shell/expectations/stubbed_command.rb, line 26 def called_with_args?(*args) with_args.called_with_args?(*args) end
inspect()
click to toggle source
# File lib/rspec/shell/expectations/stubbed_command.rb, line 42 def inspect with_args.inspect end
outputs(contents, to: :stdout)
click to toggle source
# File lib/rspec/shell/expectations/stubbed_command.rb, line 38 def outputs(contents, to: :stdout) with_args.outputs(contents, to: to) end
returns_exitstatus(statuscode)
click to toggle source
# File lib/rspec/shell/expectations/stubbed_command.rb, line 30 def returns_exitstatus(statuscode) with_args.returns_exitstatus(statuscode) end
stdin()
click to toggle source
# File lib/rspec/shell/expectations/stubbed_command.rb, line 34 def stdin with_args.stdin end
with_args(*args)
click to toggle source
# File lib/rspec/shell/expectations/stubbed_command.rb, line 18 def with_args(*args) StubbedCall.new(@call_configuration, @call_log, args) end
Private Instance Methods
project_root()
click to toggle source
# File lib/rspec/shell/expectations/stubbed_command.rb, line 52 def project_root Pathname.new(File.dirname(File.expand_path(__FILE__))) .join('..', '..', '..', '..') end
stub_filepath()
click to toggle source
# File lib/rspec/shell/expectations/stubbed_command.rb, line 48 def stub_filepath project_root.join('bin', 'stub') end