Class: RR::Expectations::ArgumentEqualityExpectation

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

Direct Known Subclasses

AnyArgumentExpectation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*expected_arguments) ⇒ ArgumentEqualityExpectation

Returns a new instance of 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



27
28
29
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 27

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

#exact_match?(*arguments) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 10

def exact_match?(*arguments)
  @expected_arguments == arguments
end

#wildcard_match?(*arguments) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rr/expectations/argument_equality_expectation.rb', line 14

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 expected_argument == arg
    end
  end
  return true
end