Module: Rx::ReactiveTest
- Defined in:
- lib/rx/testing/reactive_test.rb
Overview
Module to write unit tests for applications and libraries built using Reactive Extensions.
Defined Under Namespace
Classes: OnErrorPredicate, OnNextPredicate
Constant Summary collapse
- CREATED =
Default virtual time used for creation of observable sequences in ReactiveTest-based unit tests.
100
- SUBSCRIBED =
Default virtual time used to subscribe to observable sequences in ReactiveTest-based unit tests.
200
- DISPOSED =
Default virtual time used to dispose subscriptions in ReactiveTest-based unit tests.
1000
Instance Method Summary collapse
- #assert_messages(expected, actual) ⇒ Object
- #assert_subscriptions(expected, actual) ⇒ Object
-
#on_completed(ticks) ⇒ Object
Factory method for an OnCompleted notification record at a given time.
-
#on_error(ticks, error) ⇒ Object
Factory method for an on_error notification record at a given time with a given error.
-
#on_error_predicate(ticks, &block) ⇒ Object
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.
-
#on_next(ticks, value) ⇒ Object
Factory method for an on_next notification record at a given time with a given value.
-
#on_next_predicate(ticks, &block) ⇒ Object
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.
-
#subscribe(subscribe, unsubscribe) ⇒ Object
Factory method for a subscription record based on a given subscription and unsubscribe time.
Instance Method Details
#assert_messages(expected, actual) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/rx/testing/reactive_test.rb', line 52 def (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) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/rx/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) ⇒ Object
Factory method for an OnCompleted notification record at a given time.
43 44 45 |
# File 'lib/rx/testing/reactive_test.rb', line 43 def on_completed(ticks) Recorded.new(ticks, Notification.create_on_completed) end |
#on_error(ticks, error) ⇒ Object
Factory method for an on_error notification record at a given time with a given error.
32 33 34 |
# File 'lib/rx/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) ⇒ Object
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.
37 38 39 40 |
# File 'lib/rx/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) ⇒ Object
Factory method for an on_next notification record at a given time with a given value.
21 22 23 |
# File 'lib/rx/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) ⇒ Object
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.
26 27 28 29 |
# File 'lib/rx/testing/reactive_test.rb', line 26 def on_next_predicate(ticks, &block) n = OnNextPredicate.new(&block) Recorded.new(ticks, n) end |
#subscribe(subscribe, unsubscribe) ⇒ Object
Factory method for a subscription record based on a given subscription and unsubscribe time.
48 49 50 |
# File 'lib/rx/testing/reactive_test.rb', line 48 def subscribe(subscribe, unsubscribe) TestSubscription.new(subscribe, unsubscribe) end |