Class: Rspec::Bash::StubbedCommand
- Inherits:
-
Object
- Object
- Rspec::Bash::StubbedCommand
- Defined in:
- lib/rspec/bash/command/stubbed_command.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
- #call_count(*args) ⇒ Object
- #call_log ⇒ Object
- #called? ⇒ Boolean
- #called_with_args?(*args) ⇒ Boolean
- #called_with_no_args? ⇒ Boolean
-
#initialize(command, call_log_manager, call_conf_manager) ⇒ StubbedCommand
constructor
A new instance of StubbedCommand.
- #inspect ⇒ Object
- #outputs(contents, to: :stdout) ⇒ Object
- #returns_exitstatus(exitcode) ⇒ Object
- #stdin ⇒ Object
- #with_args(*args) ⇒ Object
Constructor Details
#initialize(command, call_log_manager, call_conf_manager) ⇒ StubbedCommand
Returns a new instance of StubbedCommand.
8 9 10 11 12 13 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 8 def initialize(command, call_log_manager, call_conf_manager) @command = command @arguments = [] @call_log_manager = call_log_manager @call_conf_manager = call_conf_manager end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
6 7 8 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 6 def arguments @arguments end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
6 7 8 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 6 def command @command end |
Instance Method Details
#call_count(*args) ⇒ Object
32 33 34 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 32 def call_count(*args) @call_log_manager.call_count(@command, args) end |
#call_log ⇒ Object
50 51 52 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 50 def call_log @call_log_manager.call_log(@command) end |
#called? ⇒ Boolean
20 21 22 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 20 def called? @call_log_manager.called_with_args?(@command, @arguments) end |
#called_with_args?(*args) ⇒ Boolean
28 29 30 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 28 def called_with_args?(*args) @call_log_manager.called_with_args?(@command, args) end |
#called_with_no_args? ⇒ Boolean
24 25 26 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 24 def called_with_no_args? @call_log_manager.called_with_no_args?(@command) end |
#inspect ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 54 def inspect if @arguments.any? "<Stubbed #{@call_configuration.command.inspect} " \ "args: #{@arguments.join(' ').inspect}>" else "<Stubbed #{@call_configuration.command.inspect}>" end end |
#outputs(contents, to: :stdout) ⇒ Object
45 46 47 48 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 45 def outputs(contents, to: :stdout) @call_conf_manager.add_output(@command, contents, to, @arguments) self end |
#returns_exitstatus(exitcode) ⇒ Object
40 41 42 43 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 40 def returns_exitstatus(exitcode) @call_conf_manager.set_exitcode(@command, exitcode, @arguments) self end |
#stdin ⇒ Object
36 37 38 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 36 def stdin @call_log_manager.stdin_for_args(@command, @arguments) end |
#with_args(*args) ⇒ Object
15 16 17 18 |
# File 'lib/rspec/bash/command/stubbed_command.rb', line 15 def with_args(*args) @arguments = args self end |