Class: Rspec::Bash::CallLog
- Inherits:
-
Object
- Object
- Rspec::Bash::CallLog
- Defined in:
- lib/rspec/bash/command/call_log.rb
Instance Attribute Summary collapse
-
#call_log ⇒ Object
Returns the value of attribute call_log.
Instance Method Summary collapse
- #add_log(stdin, argument_list) ⇒ Object
- #call_count(argument_list) ⇒ Object
- #call_log_arguments ⇒ Object
- #called_with_args?(argument_list) ⇒ Boolean
- #called_with_no_args? ⇒ Boolean
-
#initialize ⇒ CallLog
constructor
A new instance of CallLog.
- #stdin_for_args(argument_list) ⇒ Object
Constructor Details
#initialize ⇒ CallLog
Returns a new instance of CallLog.
6 7 8 |
# File 'lib/rspec/bash/command/call_log.rb', line 6 def initialize @call_log = [] end |
Instance Attribute Details
#call_log ⇒ Object
Returns the value of attribute call_log.
4 5 6 |
# File 'lib/rspec/bash/command/call_log.rb', line 4 def call_log @call_log end |
Instance Method Details
#add_log(stdin, argument_list) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/rspec/bash/command/call_log.rb', line 35 def add_log(stdin, argument_list) updated_log = @call_log updated_log << { args: argument_list, stdin: stdin } end |
#call_count(argument_list) ⇒ Object
16 17 18 19 |
# File 'lib/rspec/bash/command/call_log.rb', line 16 def call_count(argument_list) call_argument_list_matcher = Util::CallLogArgumentListMatcher.new(argument_list) call_argument_list_matcher.get_call_count(call_log) end |
#call_log_arguments ⇒ Object
43 44 45 |
# File 'lib/rspec/bash/command/call_log.rb', line 43 def call_log_arguments @call_log.map { |call_log| call_log[:args] || [] }.compact end |
#called_with_args?(argument_list) ⇒ Boolean
21 22 23 24 |
# File 'lib/rspec/bash/command/call_log.rb', line 21 def called_with_args?(argument_list) call_argument_list_matcher = Util::CallLogArgumentListMatcher.new(argument_list) call_argument_list_matcher.args_match?(call_log) end |
#called_with_no_args? ⇒ Boolean
26 27 28 29 30 31 32 33 |
# File 'lib/rspec/bash/command/call_log.rb', line 26 def called_with_no_args? return false if @call_log.empty? @call_log.all? do |call_log| argument_list = call_log[:args] || [] argument_list.empty? end end |
#stdin_for_args(argument_list) ⇒ Object
10 11 12 13 14 |
# File 'lib/rspec/bash/command/call_log.rb', line 10 def stdin_for_args(argument_list) call_argument_list_matcher = Util::CallLogArgumentListMatcher.new(argument_list) matching_call_log_list = call_argument_list_matcher.get_call_log_matches(call_log) matching_call_log_list.first[:stdin] unless matching_call_log_list.empty? end |