Class: Rspec::Bash::CallLog

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/bash/call_log.rb

Overview

Log of calls to a command

Instance Method Summary collapse

Constructor Details

#initialize(call_log_path) ⇒ CallLog

Returns a new instance of CallLog.



5
6
7
# File 'lib/rspec/bash/call_log.rb', line 5

def initialize(call_log_path)
  @call_log_path = call_log_path
end

Instance Method Details

#call_count(*expected_argument_series) ⇒ Object



22
23
24
25
26
# File 'lib/rspec/bash/call_log.rb', line 22

def call_count(*expected_argument_series)
  get_call_log_args.count do |actual_argument_series|
    argument_series_contains?(actual_argument_series, expected_argument_series || [])
  end
end

#called_with_args?(*args) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/rspec/bash/call_log.rb', line 13

def called_with_args?(*args)
  call_count(*args) > 0
end

#called_with_no_args?Boolean

Returns:

  • (Boolean)


28
29
30
31
# File 'lib/rspec/bash/call_log.rb', line 28

def called_with_no_args?
  call_log_list = load_call_log_list
  !call_log_list.empty? && call_log_list.first['args'].nil?
end

#exist?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/rspec/bash/call_log.rb', line 9

def exist?
  @call_log_path.exist?
end

#stdin_for_args(*args) ⇒ Object



17
18
19
20
# File 'lib/rspec/bash/call_log.rb', line 17

def stdin_for_args(*args)
  call = find_call(*args)
  call['stdin'] unless call.nil?
end