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 8 def initialize(expected_parameters = [ParameterMatchers::AnyParameters.new], &matching_block) @expected_parameters, @matching_block = expected_parameters, matching_block end
Public Instance Methods
match?(actual_parameters = [])
click to toggle source
# File lib/mocha/parameters_matcher.rb, line 12 def match?(actual_parameters = []) if @matching_block return @matching_block.call(*actual_parameters) else return parameters_match?(actual_parameters) end end
matchers()
click to toggle source
# File lib/mocha/parameters_matcher.rb, line 31 def matchers @expected_parameters.map { |parameter| parameter.to_matcher } end
mocha_inspect()
click to toggle source
# File lib/mocha/parameters_matcher.rb, line 24 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 20 def parameters_match?(actual_parameters) matchers.all? { |matcher| matcher.matches?(actual_parameters) } && (actual_parameters.length == 0) end