Class: Rx::MockObserver

Inherits:
Object
  • Object
show all
Includes:
Observer
Defined in:
lib/rx/testing/mock_observer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Observer

allow_reentrancy, #as_observer, #checked, configure, create, from_notifier, #notify_on, prevent_reentrancy, #to_notifier

Constructor Details

#initialize(scheduler) ⇒ MockObserver

Returns a new instance of MockObserver.



14
15
16
17
18
19
# File 'lib/rx/testing/mock_observer.rb', line 14

def initialize(scheduler)
  raise 'scheduler cannot be nil' unless scheduler

  @scheduler = scheduler
  @messages = []
end

Instance Attribute Details

#messagesObject (readonly)

Returns the value of attribute messages.



12
13
14
# File 'lib/rx/testing/mock_observer.rb', line 12

def messages
  @messages
end

Instance Method Details

#on_completedObject



29
30
31
# File 'lib/rx/testing/mock_observer.rb', line 29

def on_completed
  messages.push(Recorded.new(@scheduler.clock, Notification.create_on_completed))
end

#on_error(error) ⇒ Object



25
26
27
# File 'lib/rx/testing/mock_observer.rb', line 25

def on_error(error)
  messages.push(Recorded.new(@scheduler.clock, Notification.create_on_error(error)))
end

#on_next(value) ⇒ Object



21
22
23
# File 'lib/rx/testing/mock_observer.rb', line 21

def on_next(value)
  messages.push(Recorded.new(@scheduler.clock, Notification.create_on_next(value)))
end