Sha256: 0b5c36c371c8f40e69fdf7a4bbfe95fd3db8b0e571fa4edaf58443a39ad2fe72
Contents?: true
Size: 929 Bytes
Versions: 20
Compression:
Stored size: 929 Bytes
Contents
require 'mocha/inspect' require 'mocha/parameter_matchers' module Mocha class ParametersMatcher def initialize(expected_parameters = [ParameterMatchers::AnyParameters.new], &matching_block) @expected_parameters = expected_parameters @matching_block = matching_block end def match?(actual_parameters = []) if @matching_block @matching_block.call(*actual_parameters) else parameters_match?(actual_parameters) end end def parameters_match?(actual_parameters) matchers.all? { |matcher| matcher.matches?(actual_parameters) } && actual_parameters.empty? end def mocha_inspect signature = matchers.mocha_inspect signature = signature.gsub(/^\[|\]$/, '') signature = signature.gsub(/^\{|\}$/, '') if matchers.length == 1 "(#{signature})" end def matchers @expected_parameters.map(&:to_matcher) end end end
Version data entries
20 entries across 20 versions & 2 rubygems