module RxRuby::ReactiveTest

Module to write unit tests for applications and libraries built using Reactive Extensions.

Constants

CREATED

Default virtual time used for creation of observable sequences in ReactiveTest-based unit tests.

DISPOSED

Default virtual time used to dispose subscriptions in ReactiveTest-based unit tests.

SUBSCRIBED

Default virtual time used to subscribe to observable sequences in ReactiveTest-based unit tests.

Public Instance Methods

assert_messages(expected, actual) click to toggle source
# File lib/rx_ruby/testing/reactive_test.rb, line 52
def assert_messages(expected, actual)
  assert_equal expected.length, actual.length, "The size of messages differ"

  for i in 0..expected.length - 1
    assert_equal expected[i].time, actual[i].time, "The messages[#{i}].time differ"
    assert_equal expected[i].value, actual[i].value, "The messages[#{i}].value differ"
  end
end
assert_subscriptions(expected, actual) click to toggle source
# File lib/rx_ruby/testing/reactive_test.rb, line 61
def assert_subscriptions(expected, actual)
  assert_equal expected.length, actual.length

  for i in 0..expected.length - 1
    assert (expected[i] == actual[i])
  end      
end
on_completed(ticks) click to toggle source

Factory method for an OnCompleted notification record at a given time.

# File lib/rx_ruby/testing/reactive_test.rb, line 43
def on_completed(ticks)
  Recorded.new(ticks, Notification.create_on_completed)
end
on_error(ticks, error) click to toggle source

Factory method for an on_error notification record at a given time with a given error.

# File lib/rx_ruby/testing/reactive_test.rb, line 32
def on_error(ticks, error)
  Recorded.new(ticks, Notification.create_on_error(error))
end
on_error_predicate(ticks, &block) click to toggle source

Factory method for writing an assert that checks for an on_error notification record at a given time, using the specified predicate to check the exception.

# File lib/rx_ruby/testing/reactive_test.rb, line 37
def on_error_predicate(ticks, &block)
  n = OnErrorPredicate.new(&block)
  Recorded.new(ticks, n)
end
on_next(ticks, value) click to toggle source

Factory method for an on_next notification record at a given time with a given value.

# File lib/rx_ruby/testing/reactive_test.rb, line 21
def on_next(ticks, value)
  Recorded.new(ticks, Notification.create_on_next(value))
end
on_next_predicate(ticks, &block) click to toggle source

Factory method for writing an assert that checks for an on_next notification record at a given time, using the specified predicate to check the value.

# File lib/rx_ruby/testing/reactive_test.rb, line 26
def on_next_predicate(ticks, &block)
  n = OnNextPredicate.new(&block)
  Recorded.new(ticks, n)
end
subscribe(subscribe, unsubscribe) click to toggle source

Factory method for a subscription record based on a given subscription and unsubscribe time.

# File lib/rx_ruby/testing/reactive_test.rb, line 48
def subscribe(subscribe, unsubscribe)
  TestSubscription.new(subscribe, unsubscribe)
end