Class: RR::RecordedCalls

Inherits:
Object
  • Object
show all
Includes:
Space::Reader
Defined in:
lib/rr/recorded_calls.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Space::Reader

#space

Constructor Details

#initialize(recorded_calls = []) ⇒ RecordedCalls

Returns a new instance of RecordedCalls.



5
6
7
8
# File 'lib/rr/recorded_calls.rb', line 5

def initialize(recorded_calls=[])
  @recorded_calls = recorded_calls
  @ordered_index = 0
end

Instance Attribute Details

#recorded_callsObject (readonly)

Returns the value of attribute recorded_calls.



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

def recorded_calls
  @recorded_calls
end

Instance Method Details

#==(other) ⇒ Object



33
34
35
# File 'lib/rr/recorded_calls.rb', line 33

def ==(other)
  recorded_calls == other.recorded_calls
end

#[](index) ⇒ Object



12
13
14
# File 'lib/rr/recorded_calls.rb', line 12

def [](index)
  @recorded_calls[index]
end

#add(subject, method_name, arguments, keyword_arguments, block) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/rr/recorded_calls.rb', line 21

def add(subject, method_name, arguments, keyword_arguments, block)
  recorded_calls << RecordedCall.new(subject,
                                     method_name,
                                     arguments,
                                     keyword_arguments,
                                     block)
end

#any?(&block) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rr/recorded_calls.rb', line 29

def any?(&block)
  recorded_calls.any?(&block)
end

#clearObject



16
17
18
19
# File 'lib/rr/recorded_calls.rb', line 16

def clear
  self.ordered_index = 0
  recorded_calls.clear
end

#match_error(spy_verification) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/rr/recorded_calls.rb', line 37

def match_error(spy_verification)
  double_injection_exists_error(spy_verification) || begin
    if spy_verification.ordered?
      ordered_match_error(spy_verification)
    else
      unordered_match_error(spy_verification)
    end
  end
end