Class: Rspec::Bash::Util::CallLogArgumentListMatcher

Inherits:
ArgumentListMatcher
  • Object
show all
Defined in:
lib/rspec/bash/util/call_log_argument_list_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_args = [any_args]) ⇒ CallLogArgumentListMatcher

Returns a new instance of CallLogArgumentListMatcher.



12
13
14
15
# File 'lib/rspec/bash/util/call_log_argument_list_matcher.rb', line 12

def initialize(expected_args = [any_args])
  expected_args = expected_args.empty? ? [any_args] : expected_args
  parent_initialize(*expected_args)
end

Instance Method Details

#args_match?(actual_call_log_list) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rspec/bash/util/call_log_argument_list_matcher.rb', line 17

def args_match?(actual_call_log_list)
  get_call_count(actual_call_log_list) > 0
end

#get_call_count(actual_call_log_list) ⇒ Object



21
22
23
# File 'lib/rspec/bash/util/call_log_argument_list_matcher.rb', line 21

def get_call_count(actual_call_log_list)
  get_call_log_matches(actual_call_log_list).size
end

#get_call_log_matches(actual_call_log_list) ⇒ Object



25
26
27
28
29
# File 'lib/rspec/bash/util/call_log_argument_list_matcher.rb', line 25

def get_call_log_matches(actual_call_log_list)
  actual_call_log_list.select do |actual_call_list|
    parent_args_match?(*actual_call_list[:args])
  end
end

#parent_args_match?Object



9
# File 'lib/rspec/bash/util/call_log_argument_list_matcher.rb', line 9

alias parent_args_match? args_match?

#parent_initializeObject



10
# File 'lib/rspec/bash/util/call_log_argument_list_matcher.rb', line 10

alias parent_initialize initialize