Class: RR::Expectations::ArgumentEqualityExpectation
- Inherits:
-
Object
- Object
- RR::Expectations::ArgumentEqualityExpectation
- Defined in:
- lib/rr/expectations/argument_equality_expectation.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#expected_arguments ⇒ Object
readonly
Returns the value of attribute expected_arguments.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #exact_match?(*arguments) ⇒ Boolean
-
#initialize(*expected_arguments) ⇒ ArgumentEqualityExpectation
constructor
A new instance of ArgumentEqualityExpectation.
- #wildcard_match?(*arguments) ⇒ Boolean
Constructor Details
#initialize(*expected_arguments) ⇒ ArgumentEqualityExpectation
Returns a new instance of ArgumentEqualityExpectation.
14 15 16 |
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 14 def initialize(*expected_arguments) @expected_arguments = expected_arguments end |
Instance Attribute Details
#expected_arguments ⇒ Object (readonly)
Returns the value of attribute expected_arguments.
12 13 14 |
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 12 def expected_arguments @expected_arguments end |
Class Method Details
.recursive_safe_eq(arg1, arg2) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 4 def self.recursive_safe_eq(arg1, arg2) if arg1.respond_to?(:'__rr__original_==') arg1.__send__(:'__rr__original_==', arg2) else arg1 == arg2 end end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 |
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 39 def ==(other) expected_arguments == other.expected_arguments end |
#exact_match?(*arguments) ⇒ Boolean
18 19 20 21 22 23 24 |
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 18 def exact_match?(*arguments) return false unless arguments.length == expected_arguments.length arguments.each_with_index do |arg, index| return false unless self.class.recursive_safe_eq(expected_arguments[index], arg) end true end |
#wildcard_match?(*arguments) ⇒ Boolean
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 26 def wildcard_match?(*arguments) return false unless arguments.length == expected_arguments.length arguments.each_with_index do |arg, index| expected_argument = expected_arguments[index] if expected_argument.respond_to?(:wildcard_match?) return false unless expected_argument.wildcard_match?(arg) else return false unless self.class.recursive_safe_eq(expected_argument, arg) end end true end |