Class: RR::Expectations::ArgumentEqualityExpectation

Inherits:
Object
  • Object
show all
Defined in:
lib/rr/expectations/argument_equality_expectation.rb

Overview

:nodoc:

Direct Known Subclasses

AnyArgumentExpectation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*expected_arguments) ⇒ ArgumentEqualityExpectation



6
7
8
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 6

def initialize(*expected_arguments)
  @expected_arguments = expected_arguments
end

Instance Attribute Details

#expected_argumentsObject (readonly)

Returns the value of attribute expected_arguments



4
5
6
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 4

def expected_arguments
  @expected_arguments
end

Instance Method Details

#==(other) ⇒ Object



31
32
33
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 31

def ==(other)
  expected_arguments == other.expected_arguments
end

#exact_match?(*arguments) ⇒ Boolean



10
11
12
13
14
15
16
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 10

def exact_match?(*arguments)
  return false unless arguments.length == expected_arguments.length
  arguments.each_with_index do |arg, index|
    return false unless equality_match(expected_arguments[index], arg)
  end
  true
end

#wildcard_match?(*arguments) ⇒ Boolean



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 18

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 equality_match(expected_argument, arg)
    end
  end
  true
end