lib/mocha/parameter_matchers/instance_methods.rb in mocha-2.4.0 vs lib/mocha/parameter_matchers/instance_methods.rb in mocha-2.4.1

- old
+ new

@@ -1,27 +1,26 @@ +require 'mocha/parameter_matchers/base' require 'mocha/parameter_matchers/equals' require 'mocha/parameter_matchers/positional_or_keyword_hash' module Mocha module ParameterMatchers # @private module InstanceMethods # @private - def to_matcher(_expectation = nil) - Mocha::ParameterMatchers::Equals.new(self) + def to_matcher(expectation: nil, top_level: false) + if is_a?(Base) + self + elsif is_a?(Hash) && top_level + Mocha::ParameterMatchers::PositionalOrKeywordHash.new(self, expectation) + else + Mocha::ParameterMatchers::Equals.new(self) + end end end end end # @private class Object include Mocha::ParameterMatchers::InstanceMethods -end - -# @private -class Hash - # @private - def to_matcher(expectation = nil) - Mocha::ParameterMatchers::PositionalOrKeywordHash.new(self, expectation) - end end