class Mocha::ParametersMatcher
Public Class Methods
new(expected_parameters = [ParameterMatchers::AnyParameters.new], &matching_block)
click to toggle source
# File lib/mocha/parameters_matcher.rb, line 6 def initialize(expected_parameters = [ParameterMatchers::AnyParameters.new], &matching_block) @expected_parameters = expected_parameters @matching_block = matching_block end
Public Instance Methods
match?(actual_parameters = [])
click to toggle source
# File lib/mocha/parameters_matcher.rb, line 11 def match?(actual_parameters = []) if @matching_block @matching_block.call(*actual_parameters) else parameters_match?(actual_parameters) end end
matchers()
click to toggle source
# File lib/mocha/parameters_matcher.rb, line 30 def matchers @expected_parameters.map(&:to_matcher) end
mocha_inspect()
click to toggle source
# File lib/mocha/parameters_matcher.rb, line 23 def mocha_inspect signature = matchers.mocha_inspect signature = signature.gsub(/^\[|\]$/, '') signature = signature.gsub(/^\{|\}$/, '') if matchers.length == 1 "(#{signature})" end
parameters_match?(actual_parameters)
click to toggle source
# File lib/mocha/parameters_matcher.rb, line 19 def parameters_match?(actual_parameters) matchers.all? { |matcher| matcher.matches?(actual_parameters) } && actual_parameters.empty? end