Object
RR::Double is the use case for a method call. It has the ArgumentEqualityExpectation, TimesCalledExpectation, and the implementation.
# File lib/rr/double.rb, line 23 def initialize(double_injection, definition) @double_injection = double_injection @definition = definition @times_called = 0 @times_called_expectation = Expectations::TimesCalledExpectation.new(self) definition.double = self verify_method_signature if definition.verify_method_signature? double_injection.register_double self end
Double#attempt? returns true when the TimesCalledExpectation is satisfied.
# File lib/rr/double.rb, line 47 def attempt? verify_times_matcher_is_set times_called_expectation.attempt? end
Double#exact_match? returns true when the passed in arguments exactly match the ArgumentEqualityExpectation arguments.
# File lib/rr/double.rb, line 35 def exact_match?(*arguments) definition.exact_match?(*arguments) end
The Arguments that this Double expects
# File lib/rr/double.rb, line 72 def expected_arguments verify_argument_expectation_is_set argument_expectation.expected_arguments end
# File lib/rr/double.rb, line 7 def formatted_name(method_name, args) formatted_errors = args.collect {|arg| arg.inspect}.join(', ') "#{method_name}(#{formatted_errors})" end
# File lib/rr/double.rb, line 94 def implementation_is_original_method? definition.implementation_is_original_method? end
# File lib/rr/double.rb, line 12 def list_message_part(doubles) doubles.collect do |double| "- #{formatted_name(double.method_name, double.expected_arguments)}" end.join("\n") end
# File lib/rr/double.rb, line 86 def method_call(args) if verbose? puts Double.formatted_name(method_name, args) end times_called_expectation.attempt if definition.times_matcher space.verify_ordered_double(self) if ordered? end
The method name that this Double is attatched to
# File lib/rr/double.rb, line 67 def method_name double_injection.method_name end
# File lib/rr/double.rb, line 61 def terminal? verify_times_matcher_is_set times_called_expectation.terminal? end
The TimesCalledMatcher for the TimesCalledExpectation
# File lib/rr/double.rb, line 78 def times_matcher definition.times_matcher end
Double#verify verifies the the TimesCalledExpectation is satisfied for this double. A TimesCalledError is raised if the TimesCalledExpectation is not met.
# File lib/rr/double.rb, line 55 def verify verify_times_matcher_is_set times_called_expectation.verify! true end
Double#wildcard_match? returns true when the passed in arguments wildcard match the ArgumentEqualityExpectation arguments.
# File lib/rr/double.rb, line 41 def wildcard_match?(*arguments) definition.wildcard_match?(*arguments) end
# File lib/rr/double.rb, line 147 def args definition.argument_expectation.expected_arguments end
# File lib/rr/double.rb, line 151 def argument_expectation definition.argument_expectation end
# File lib/rr/double.rb, line 138 def arity_matches? return true if subject_accepts_only_varargs? if subject_accepts_varargs? return ((subject_arity * -1) - 1) <= args.size else return subject_arity == args.size end end
# File lib/rr/double.rb, line 99 def ordered? definition.ordered? end
# File lib/rr/double.rb, line 130 def subject_accepts_only_varargs? subject_arity == -1 end
# File lib/rr/double.rb, line 134 def subject_accepts_varargs? subject_arity < 0 end
# File lib/rr/double.rb, line 126 def subject_arity double_injection.original_method.arity end
# File lib/rr/double.rb, line 103 def verbose? definition.verbose? end
# File lib/rr/double.rb, line 113 def verify_argument_expectation_is_set unless definition.argument_expectation raise RR::Errors::DoubleDefinitionError, "#definition.argument_expectation is not set" end end
Generated with the Darkfish Rdoc Generator 2.