Permalink
Browse files

renames for readability; I still don't like how big this method is, b…

…ut it's good enough

[git-p4: depot-paths = "//src/minitest/dev/": change = 6963]
  • Loading branch information...
1 parent 88eec1b commit c70d36e557e17367815c123cc3948404a5735a29 Steven R. Baker committed Jan 29, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/minitest/mock.rb
View
10 lib/minitest/mock.rb
@@ -78,24 +78,24 @@ def method_missing(sym, *args) # :nodoc:
[sym, @expected_calls.keys.sort_by(&:to_s)]
end
- x_calls = @expected_calls[sym].select { |call| call[:args].size == args.size }
+ expected_calls = @expected_calls[sym].select { |call| call[:args].size == args.size }
- if x_calls.empty?
+ if expected_calls.empty?
arg_sizes = @expected_calls[sym].map { |call| call[:args].size }.uniq.sort
raise ArgumentError, "mocked method %p expects %s arguments, got %d" %
[sym, arg_sizes.join('/'), args.size]
end
- x_call = x_calls.find do |call|
+ expected_call = expected_calls.find do |call|
call[:args].zip(args).all? { |mod, a| mod === a or mod == a }
end
- unless x_call
+ unless expected_call
raise MockExpectationError, "mocked method %p called with unexpected arguments %p" %
[sym, args]
end
- expected_args, retval = x_call[:args], x_call[:retval]
+ expected_args, retval = expected_call[:args], expected_call[:retval]
@actual_calls[sym] << {
:retval => retval,

0 comments on commit c70d36e

Please sign in to comment.