Class: Rspec::Shell::Expectations::StubbedCommand
- Inherits:
-
Object
- Object
- Rspec::Shell::Expectations::StubbedCommand
- Defined in:
- lib/rspec/shell/expectations/stubbed_command.rb
Overview
Command that produces specific output and monitors input
Instance Method Summary collapse
- #called? ⇒ Boolean
- #called_with_args?(*args) ⇒ Boolean
-
#initialize(command, dir) ⇒ StubbedCommand
constructor
A new instance of StubbedCommand.
- #outputs(contents, to: :stdout) ⇒ Object
- #returns_exitstatus(statuscode) ⇒ Object
- #stdin ⇒ Object
- #with_args(*args) ⇒ Object
Constructor Details
#initialize(command, dir) ⇒ StubbedCommand
Returns a new instance of StubbedCommand.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 7 def initialize(command, dir) @dir, @command = dir, command FileUtils.cp(stub_filepath, File.join(dir, command)) @call_configuration = CallConfiguration.new( Pathname.new(dir).join("#{command}_stub.yml") ) @call_log = CallLog.new( Pathname.new(dir).join("#{command}_calls.yml") ) end |
Instance Method Details
#called? ⇒ Boolean
22 23 24 |
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 22 def called? with_args.called? end |
#called_with_args?(*args) ⇒ Boolean
26 27 28 |
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 26 def called_with_args?(*args) with_args.called_with_args?(*args) end |
#outputs(contents, to: :stdout) ⇒ Object
38 39 40 |
# 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) ⇒ Object
30 31 32 |
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 30 def returns_exitstatus(statuscode) with_args.returns_exitstatus(statuscode) end |
#stdin ⇒ Object
34 35 36 |
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 34 def stdin with_args.stdin end |
#with_args(*args) ⇒ Object
18 19 20 |
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 18 def with_args(*args) StubbedCall.new(@call_configuration, @call_log, args) end |