Class: Rspec::Bash::CallLog
- Inherits:
-
Object
- Object
- Rspec::Bash::CallLog
- Defined in:
- lib/rspec/bash/call_log.rb
Instance Method Summary collapse
- #add_log(stdin, argument_list) ⇒ Object
- #call_count(*argument_list) ⇒ Object
- #call_log ⇒ Object
- #call_log=(new_log) ⇒ Object
- #called_with_args?(*argument_list) ⇒ Boolean
- #called_with_no_args? ⇒ Boolean
- #exist? ⇒ Boolean
-
#initialize(call_log_path) ⇒ CallLog
constructor
A new instance of CallLog.
- #stdin_for_args(*argument_list) ⇒ Object
Constructor Details
#initialize(call_log_path) ⇒ CallLog
Returns a new instance of CallLog.
4 5 6 |
# File 'lib/rspec/bash/call_log.rb', line 4 def initialize(call_log_path) @call_log_path = call_log_path end |
Instance Method Details
#add_log(stdin, argument_list) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/rspec/bash/call_log.rb', line 37 def add_log(stdin, argument_list) updated_log = call_log updated_log << { args: argument_list, stdin: stdin } write updated_log end |
#call_count(*argument_list) ⇒ Object
18 19 20 21 |
# File 'lib/rspec/bash/call_log.rb', line 18 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 ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/rspec/bash/call_log.rb', line 46 def call_log @call_log_path.open('r') do |call_log| YAML.load(call_log.read) || [] end rescue NoMethodError, Errno::ENOENT return [] end |
#call_log=(new_log) ⇒ Object
54 55 56 |
# File 'lib/rspec/bash/call_log.rb', line 54 def call_log=(new_log) write new_log end |
#called_with_args?(*argument_list) ⇒ Boolean
23 24 25 26 |
# File 'lib/rspec/bash/call_log.rb', line 23 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
28 29 30 31 32 33 34 35 |
# File 'lib/rspec/bash/call_log.rb', line 28 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 |
#exist? ⇒ Boolean
8 9 10 |
# File 'lib/rspec/bash/call_log.rb', line 8 def exist? @call_log_path.exist? end |
#stdin_for_args(*argument_list) ⇒ Object
12 13 14 15 16 |
# File 'lib/rspec/bash/call_log.rb', line 12 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 |