Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions lib/record_invocation/record_invocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,19 @@ def __one_invocation(method_name, **parameters)
alias :one_invocation :__one_invocation

def __invocations(method_name=nil, **parameters)
if method_name.nil? && parameters.empty?
return __records
end
invocations = __records

invocations = __records.select { |invocation| invocation.method_name == method_name }

if parameters.nil?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbellware This is actually wrong -- parameters will always be a hash, and never nil. I replicated defect in my change. It's innocuous ultimately, but it's misleading.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated mine to use parameters.empty?

return invocations
if not method_name.nil?
invocations = invocations.select { |invocation| invocation.method_name == method_name }
end

if invocations.empty?
return []
end

invocations = invocations.select do |invocation|
parameters.all? do |match_parameter_name, match_parameter_value|
invocation_value = invocation.arguments[match_parameter_name]
if not parameters.empty?
invocations = invocations.select do |invocation|
parameters.all? do |match_parameter_name, match_parameter_value|
invocation_value = invocation.arguments[match_parameter_name]

invocation_value == match_parameter_value
invocation_value == match_parameter_value
end
end
end

Expand Down