Class | Spec::Mocks::ArgumentExpectation |
In: |
lib/spec/mocks/argument_expectation.rb
|
Parent: | Object |
args | [R] |
# File lib/spec/mocks/argument_expectation.rb, line 81 81: def initialize(args) 82: @args = *args 83: if [:any_args] == args then @expected_params = nil 84: elsif [:no_args] == args then @expected_params = [] 85: else @expected_params = process_arg_constraints(args) 86: end 87: end
# File lib/spec/mocks/argument_expectation.rb, line 103 103: def check_args(args) 104: return true if @expected_params.nil? 105: return true if @expected_params == args 106: return constraints_match?(args) 107: end
# File lib/spec/mocks/argument_expectation.rb, line 109 109: def constraints_match?(args) 110: return false if args.length != @expected_params.length 111: @expected_params.each_index { |i| return false unless @expected_params[i].matches?(args[i]) } 112: return true 113: end
# File lib/spec/mocks/argument_expectation.rb, line 95 95: def convert_constraint(constraint) 96: return @@constraint_classes[constraint].new(constraint) if constraint.is_a?(Symbol) 97: return constraint if constraint.is_a?(DuckTypeArgConstraint) 98: return RegexpArgConstraint.new(constraint) if constraint.is_a?(Regexp) 99: return LiteralArgConstraint.new(constraint) 100: 101: end