reacto 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/README.md +932 -11
  4. data/doc/reactive_programming_with_reacto.md +238 -0
  5. data/lib/reacto.rb +70 -0
  6. data/lib/reacto/behaviours.rb +24 -1
  7. data/lib/reacto/constants.rb +4 -1
  8. data/lib/reacto/executors.rb +8 -10
  9. data/lib/reacto/labeled_trackable.rb +14 -2
  10. data/lib/reacto/operations.rb +23 -2
  11. data/lib/reacto/operations/act.rb +69 -0
  12. data/lib/reacto/operations/append.rb +45 -0
  13. data/lib/reacto/operations/blocking_enumerable.rb +40 -0
  14. data/lib/reacto/operations/buffer.rb +1 -4
  15. data/lib/reacto/operations/chunk.rb +81 -0
  16. data/lib/reacto/operations/chunk_while.rb +56 -0
  17. data/lib/reacto/operations/cycle.rb +27 -0
  18. data/lib/reacto/operations/delay_each.rb +75 -0
  19. data/lib/reacto/operations/depend_on.rb +4 -5
  20. data/lib/reacto/operations/diff.rb +8 -10
  21. data/lib/reacto/operations/drop.rb +6 -8
  22. data/lib/reacto/operations/drop_while.rb +23 -0
  23. data/lib/reacto/operations/each_collect.rb +57 -0
  24. data/lib/reacto/operations/each_with_object.rb +31 -0
  25. data/lib/reacto/operations/extremums.rb +54 -0
  26. data/lib/reacto/operations/find_index.rb +28 -0
  27. data/lib/reacto/operations/flat_map.rb +2 -2
  28. data/lib/reacto/operations/flatten.rb +2 -7
  29. data/lib/reacto/operations/flatten_labeled.rb +44 -0
  30. data/lib/reacto/operations/{label.rb → group_by_label.rb} +1 -1
  31. data/lib/reacto/operations/include.rb +40 -0
  32. data/lib/reacto/operations/inject.rb +15 -9
  33. data/lib/reacto/operations/map.rb +15 -13
  34. data/lib/reacto/operations/merge.rb +17 -16
  35. data/lib/reacto/operations/operation_on_labeled.rb +29 -0
  36. data/lib/reacto/operations/partition.rb +52 -0
  37. data/lib/reacto/operations/prepend.rb +0 -3
  38. data/lib/reacto/operations/rescue_and_replace_error.rb +21 -0
  39. data/lib/reacto/operations/retry.rb +26 -0
  40. data/lib/reacto/operations/retry_when.rb +30 -0
  41. data/lib/reacto/operations/select.rb +2 -6
  42. data/lib/reacto/operations/slice.rb +50 -0
  43. data/lib/reacto/operations/slice_when.rb +41 -0
  44. data/lib/reacto/operations/split_labeled.rb +32 -0
  45. data/lib/reacto/operations/take.rb +9 -14
  46. data/lib/reacto/operations/take_while.rb +28 -0
  47. data/lib/reacto/operations/throttle.rb +2 -3
  48. data/lib/reacto/operations/track_on.rb +1 -3
  49. data/lib/reacto/shared_trackable.rb +2 -5
  50. data/lib/reacto/subscriptions/buffered_subscription.rb +10 -9
  51. data/lib/reacto/subscriptions/executor_subscription.rb +12 -4
  52. data/lib/reacto/subscriptions/tracker_subscription.rb +0 -4
  53. data/lib/reacto/subscriptions/zipping_subscription.rb +0 -1
  54. data/lib/reacto/trackable.rb +429 -64
  55. data/lib/reacto/version.rb +1 -1
  56. data/reacto.gemspec +2 -3
  57. data/spec/reacto/labeled_trackable_spec.rb +17 -0
  58. data/spec/reacto/trackable/act_spec.rb +15 -0
  59. data/spec/reacto/trackable/all_spec.rb +38 -0
  60. data/spec/reacto/trackable/any_spec.rb +39 -0
  61. data/spec/reacto/trackable/append_spec.rb +38 -0
  62. data/spec/reacto/trackable/buffer_spec.rb +11 -15
  63. data/spec/reacto/trackable/chunk_spec.rb +86 -0
  64. data/spec/reacto/trackable/chunk_while_spec.rb +22 -0
  65. data/spec/reacto/trackable/class_level/combine_last_spec.rb +1 -3
  66. data/spec/reacto/trackable/class_level/interval_spec.rb +4 -6
  67. data/spec/reacto/trackable/class_level/make_spec.rb +0 -15
  68. data/spec/reacto/trackable/{zip_spec.rb → class_level/zip_spec.rb} +0 -2
  69. data/spec/reacto/trackable/concat_spec.rb +12 -12
  70. data/spec/reacto/trackable/count_spec.rb +38 -0
  71. data/spec/reacto/trackable/cycle_spec.rb +14 -0
  72. data/spec/reacto/trackable/delay_each_spec.rb +18 -0
  73. data/spec/reacto/trackable/depend_on_spec.rb +6 -9
  74. data/spec/reacto/trackable/diff_spec.rb +3 -5
  75. data/spec/reacto/trackable/drop_errors_spec.rb +1 -3
  76. data/spec/reacto/trackable/drop_while_spec.rb +15 -0
  77. data/spec/reacto/trackable/each_cons_spec.rb +53 -0
  78. data/spec/reacto/trackable/each_slice_spec.rb +37 -0
  79. data/spec/reacto/trackable/each_with_index_spec.rb +33 -0
  80. data/spec/reacto/trackable/each_with_object_spec.rb +26 -0
  81. data/spec/reacto/trackable/entries_spec.rb +25 -0
  82. data/spec/reacto/trackable/execute_on_spec.rb +33 -0
  83. data/spec/reacto/trackable/find_index_spec.rb +31 -0
  84. data/spec/reacto/trackable/find_spec.rb +34 -0
  85. data/spec/reacto/trackable/first_spec.rb +36 -0
  86. data/spec/reacto/trackable/flat_map_latest_spec.rb +5 -5
  87. data/spec/reacto/trackable/flat_map_spec.rb +25 -0
  88. data/spec/reacto/trackable/flatten_labeled_spec.rb +48 -0
  89. data/spec/reacto/trackable/grep_spec.rb +29 -0
  90. data/spec/reacto/trackable/grep_v_spec.rb +23 -0
  91. data/spec/reacto/trackable/{label_spec.rb → group_by_label_spec.rb} +4 -11
  92. data/spec/reacto/trackable/include_spec.rb +23 -0
  93. data/spec/reacto/trackable/inject_spec.rb +30 -4
  94. data/spec/reacto/trackable/lift_spec.rb +1 -3
  95. data/spec/reacto/trackable/map_spec.rb +17 -3
  96. data/spec/reacto/trackable/max_by_spec.rb +12 -0
  97. data/spec/reacto/trackable/max_spec.rb +19 -0
  98. data/spec/reacto/trackable/merge_spec.rb +6 -7
  99. data/spec/reacto/trackable/min_by_spec.rb +12 -0
  100. data/spec/reacto/trackable/min_spec.rb +19 -0
  101. data/spec/reacto/trackable/minmax_by_spec.rb +12 -0
  102. data/spec/reacto/trackable/minmax_spec.rb +19 -0
  103. data/spec/reacto/trackable/none_spec.rb +38 -0
  104. data/spec/reacto/trackable/on_spec.rb +11 -4
  105. data/spec/reacto/trackable/one_spec.rb +38 -0
  106. data/spec/reacto/trackable/partition_spec.rb +23 -0
  107. data/spec/reacto/trackable/prepend_spec.rb +1 -3
  108. data/spec/reacto/trackable/reject_spec.rb +21 -0
  109. data/spec/reacto/trackable/rescue_and_replace_error_spec.rb +48 -0
  110. data/spec/reacto/trackable/rescue_and_replace_error_with_spec.rb +26 -0
  111. data/spec/reacto/trackable/retry_spec.rb +50 -0
  112. data/spec/reacto/trackable/retry_when_spec.rb +33 -0
  113. data/spec/reacto/trackable/select_spec.rb +18 -7
  114. data/spec/reacto/trackable/slice_after_spec.rb +38 -0
  115. data/spec/reacto/trackable/slice_before_spec.rb +38 -0
  116. data/spec/reacto/trackable/slice_when_spec.rb +26 -0
  117. data/spec/reacto/trackable/sort_by_spec.rb +16 -0
  118. data/spec/reacto/trackable/sort_spec.rb +23 -0
  119. data/spec/reacto/trackable/split_labeled_spec.rb +37 -0
  120. data/spec/reacto/trackable/take_while_spec.rb +16 -0
  121. data/spec/reacto/trackable/throttle_spec.rb +2 -3
  122. data/spec/reacto/trackable/track_on_spec.rb +2 -3
  123. data/spec/reacto/trackable/uniq_spec.rb +2 -4
  124. data/spec/support/helpers.rb +9 -1
  125. metadata +135 -25
  126. data/Gemfile.lock +0 -32
  127. data/lib/reacto/operations/cache.rb +0 -53
  128. data/spec/reacto/trackable/cache_spec.rb +0 -64
@@ -0,0 +1,36 @@
1
+ context Reacto::Trackable do
2
+ context '#first' do
3
+ subject(:test_source) { described_class.enumerable((1..100)) }
4
+
5
+ it 'emits only the first element emitted by the source' do
6
+ trackable = test_source.first
7
+
8
+ attach_test_trackers(trackable)
9
+
10
+ expect(test_data).to eq([1, '|'])
11
+ end
12
+
13
+ it 'emits only the first <n> element emitted by the source ' \
14
+ 'if <n> is given' do
15
+ trackable = test_source.first(5)
16
+
17
+ attach_test_trackers(trackable)
18
+
19
+ expect(test_data).to eq([1, 2, 3, 4, 5, '|'])
20
+ end
21
+
22
+ it 'raises an ArgumentError if <n> is given and is bellow zero' do
23
+ expect do
24
+ test_data.first(-2)
25
+ end.to raise_error(ArgumentError).with_message('negative array size')
26
+ end
27
+
28
+ it 'emits only the close notification if <n> is given and is zero' do
29
+ trackable = test_source.first(0)
30
+
31
+ attach_test_trackers(trackable)
32
+
33
+ expect(test_data).to eq(['|'])
34
+ end
35
+ end
36
+ end
@@ -1,8 +1,8 @@
1
- require 'spec_helper'
2
-
3
1
  context Reacto::Trackable do
4
- context 'flat_map_latest' do
5
- it 'TODO' do
2
+ context '#flat_map_latest' do
3
+ it 'emits the elements of the first returned Trackable from the block ' \
4
+ 'until the block returns the next one. Then it switches to emitting ' \
5
+ 'from the next' do
6
6
  trackable = described_class.interval(1).take(3).flat_map_latest do |val|
7
7
  Reacto::Trackable.interval(0.3, (val..7).to_enum)
8
8
  end
@@ -12,7 +12,7 @@ context Reacto::Trackable do
12
12
  )
13
13
 
14
14
  trackable.await(subscription)
15
- expect(test_data).to be == [0, 1, 2, 1, 2, 3, 2, 3, 4, 5, 6, 7, '|']
15
+ expect(test_data).to eq([0, 1, 2, 1, 2, 3, 2, 3, 4, 5, 6, 7, '|'])
16
16
  end
17
17
  end
18
18
  end
@@ -14,5 +14,30 @@ context Reacto::Trackable do
14
14
  )
15
15
  expect(test_data).to be == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, '|']
16
16
  end
17
+
18
+ context 'with label' do
19
+ it 'applies the transformation passed only to the values of ' \
20
+ 'the incoming values of type LabeledTrackable with matching label' do
21
+ trackable =
22
+ Reacto::Trackable.enumerable((1..10).each).group_by_label do |value|
23
+ [(value % 3), value]
24
+ end
25
+
26
+ trackable = trackable.flat_map(label: 1) do |value|
27
+ Reacto::Trackable.enumerable((value..10))
28
+ end
29
+
30
+ trackable.on(value: test_on_value)
31
+
32
+ labeled_trackable = test_data.first
33
+ expect(labeled_trackable.label).to eq(1)
34
+
35
+ labeled_data = []
36
+ labeled_trackable.on(value: ->(v) { labeled_data << v })
37
+
38
+ expected = [(1..10), (4..10), (7..10)].map(&:to_a).flatten + [10]
39
+ expect(labeled_data).to eq(expected)
40
+ end
41
+ end
17
42
  end
18
43
  end
@@ -0,0 +1,48 @@
1
+ context Reacto::Trackable do
2
+ context '#flatten_labeled' do
3
+ it 'transfomrs the LabeledTrackable instances emitted into objects with' \
4
+ 'two attributes - label the label of the LabeledTrackable and value -' \
5
+ 'the first value of emitted by the LabeledTrackable' do
6
+ trackable = described_class.enumerable((1..10)).group_by_label do |value|
7
+ [(value % 3), value]
8
+ end
9
+ trackable = trackable.flatten_labeled
10
+
11
+ trackable.on(value: test_on_value)
12
+
13
+ expect(test_data.count).to eq(3)
14
+ expect(test_data.map(&:value)).to eq([1, 2, 3])
15
+ end
16
+
17
+ it 'transfomrs the LabeledTrackable instances emitted into objects with' \
18
+ 'two attributes - label the label of the LabeledTrackable and value -' \
19
+ 'the last value computed by the passed accumulator block' do
20
+ trackable = described_class.enumerable((1..10)).group_by_label do |value|
21
+ [(value % 3), value]
22
+ end
23
+ trackable = trackable.flatten_labeled { |prev, curr| prev + curr }
24
+
25
+ trackable.on(value: test_on_value)
26
+
27
+ expect(test_data.count).to eq(3)
28
+ expect(test_data.map(&:value)).to eq([22, 15, 18])
29
+ end
30
+
31
+ it 'transfomrs the LabeledTrackable instances emitted into objects with' \
32
+ 'two attributes - label the label of the LabeledTrackable and value -' \
33
+ 'the last value computed by the passed accumulator block, using the ' \
34
+ 'passed initial value' do
35
+ trackable = described_class.enumerable((1..10)).group_by_label do |value|
36
+ [(value % 3), value]
37
+ end
38
+ trackable = trackable.flatten_labeled(initial: -10) do |prev, curr|
39
+ prev + curr
40
+ end
41
+
42
+ trackable.on(value: test_on_value)
43
+
44
+ expect(test_data.count).to eq(3)
45
+ expect(test_data.map(&:value)).to eq([12, 5, 8])
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,29 @@
1
+ context Reacto::Trackable do
2
+ context '#grep' do
3
+ subject(:test_source) { described_class.enumerable((1..100)) }
4
+
5
+ it 'returns a Reacto::Trackable emitting every value emitted by the ' \
6
+ 'source for which the given <pattern> === value' do
7
+ trackable = test_source.grep(38..44)
8
+
9
+ attach_test_trackers(trackable)
10
+
11
+ expect(test_data).to eq([38, 39, 40, 41, 42, 43, 44, '|'])
12
+ end
13
+
14
+ subject(:test_source2) do
15
+ described_class.enumerable([
16
+ 'HEY', 'FIND_ME', 'YO', 'FIND_HER', 'FIND_IT', 'FOUND_ME', 'NO_WAY'
17
+ ])
18
+ end
19
+
20
+ it 'passes each matching value to the optional block, if supplied and ' \
21
+ 'the reuslts from it are emitted' do
22
+ trackable = test_source2.grep(/FIND/) { |v| v[-1] }
23
+
24
+ attach_test_trackers(trackable)
25
+
26
+ expect(test_data).to eq(%w(E R T |))
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ context Reacto::Trackable do
2
+ context '#grep_v' do
3
+ subject(:test_source) { described_class.enumerable((1..10)) }
4
+
5
+ it 'returns a Reacto::Trackable emitting every value emitted by the ' \
6
+ 'source for which the given <pattern> === value returns false' do
7
+ trackable = test_source.grep_v(2..5)
8
+
9
+ attach_test_trackers(trackable)
10
+
11
+ expect(test_data).to eq([1, 6, 7, 8, 9, 10, '|'])
12
+ end
13
+
14
+ it 'passes each not matching value to the optional block, if supplied ' \
15
+ 'and the reuslts from it are emitted' do
16
+ trackable = test_source.grep_v(2..7) { |v| v.even? }
17
+
18
+ attach_test_trackers(trackable)
19
+
20
+ expect(test_data).to eq([false, true, false, true, '|'])
21
+ end
22
+ end
23
+ end
@@ -1,12 +1,11 @@
1
1
  context Reacto::Trackable do
2
- context '#label' do
2
+ context '#group_by_label' do
3
3
  it 'transforms each of the values emitted by the source into ' \
4
4
  'LabeledTrackable instances, using the passed function to get their ' \
5
5
  'labels and values to emit' do
6
- trackable =
7
- Reacto::Trackable.enumerable((1..10).each).label do |value|
8
- [(value % 3), value]
9
- end
6
+ trackable = described_class.enumerable((1..10)).group_by_label do |value|
7
+ [(value % 3), value]
8
+ end
10
9
 
11
10
  trackable.on(value: test_on_value)
12
11
 
@@ -24,12 +23,6 @@ context Reacto::Trackable do
24
23
  two.on(value: ->(v) { two_array << v })
25
24
  expect(two_array).to eq([2, 5, 8])
26
25
 
27
- two = test_data[1]
28
- expect(two.label).to eq(2)
29
- two_array = []
30
- two.on(value: ->(v) { two_array << v })
31
- expect(two_array).to eq([2, 5, 8])
32
-
33
26
  zero = test_data.last
34
27
  expect(zero.label).to eq(0)
35
28
  zero_array = []
@@ -0,0 +1,23 @@
1
+ context Reacto::Trackable do
2
+ context '#include?' do
3
+ subject(:test_source) { described_class.enumerable((1..10)) }
4
+
5
+ it 'it creates a Reacto::Trackable emitting only one value : `true` if ' \
6
+ 'the object given is emitted by the source' do
7
+ trackable = test_source.include?(5)
8
+
9
+ attach_test_trackers(trackable)
10
+
11
+ expect(test_data).to eq([true, '|'])
12
+ end
13
+
14
+ it 'it creates a Reacto::Trackable emitting only one value : `false` if ' \
15
+ 'the object given is not emitted by the source' do
16
+ trackable = test_source.include?(15)
17
+
18
+ attach_test_trackers(trackable)
19
+
20
+ expect(test_data).to eq([false, '|'])
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  context Reacto::Trackable do
4
2
  context '#inject' do
5
3
  let(:test_behaviour) do
@@ -23,6 +21,18 @@ context Reacto::Trackable do
23
21
  expect(test_data).to be == [16, 23, 2037]
24
22
  end
25
23
 
24
+ it 'keeps the same results for multiple subscriptions' do
25
+ trackable = source.inject(0) do |prev, v|
26
+ prev + v
27
+ end
28
+ trackable.on(value: test_on_value)
29
+ trackable.on(value: test_on_value)
30
+ trackable.on(value: test_on_value)
31
+
32
+ expect(test_data.size).to be(9)
33
+ expect(test_data).to be == [16, 23, 2037] * 3
34
+ end
35
+
26
36
  it 'sends the values created by applying the `inject` operation on the ' \
27
37
  'last value and current value, using for first value ' \
28
38
  'the first emitted by the source if no initial value provided' do
@@ -36,7 +46,7 @@ context Reacto::Trackable do
36
46
  end
37
47
 
38
48
  it 'sends the initial value if no value is emitted' do
39
- source = described_class.new(-> (t) { t.on_close })
49
+ source = described_class.new(&-> (t) { t.on_close })
40
50
  trackable = source.inject(0) do |prev, v|
41
51
  prev + v
42
52
  end
@@ -47,7 +57,7 @@ context Reacto::Trackable do
47
57
  end
48
58
 
49
59
  it 'sends nothing if no initial value and no value emitted' do
50
- source = described_class.new(-> (t) { t.on_close })
60
+ source = described_class.new(&-> (t) { t.on_close })
51
61
  trackable = source.inject do |prev, v|
52
62
  prev + v
53
63
  end
@@ -55,5 +65,21 @@ context Reacto::Trackable do
55
65
 
56
66
  expect(test_data.size).to be(0)
57
67
  end
68
+
69
+ context 'with label' do
70
+ it 'applies the accumulation only to the emitted values of type ' \
71
+ 'LabeledTrackable with the matching label' do
72
+ source = described_class.enumerable((1..10)).group_by_label do |value|
73
+ [(value % 3), value]
74
+ end
75
+
76
+ trackable = source.inject(12, label: 0) { |prev, curr| prev + curr }
77
+ trackable.on(value: test_on_value)
78
+
79
+ expect_trackable_values(test_data.first, [1, 4, 7, 10], label: 1)
80
+ expect_trackable_values(test_data[1], [2, 5, 8], label: 2)
81
+ expect_trackable_values(test_data.last, [15, 21, 30], label: 0)
82
+ end
83
+ end
58
84
  end
59
85
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  context Reacto::Trackable do
4
2
  context '#lift' do
5
3
  it 'applies a transformation to the trackable behaviour' do
@@ -13,7 +11,7 @@ context Reacto::Trackable do
13
11
  lifted_trackable.on(value: test_on_value)
14
12
 
15
13
  expect(test_data.size).to be(1)
16
- expect(test_data[0]).to be(25)
14
+ expect(test_data.first).to be(25)
17
15
  end
18
16
  end
19
17
  end
@@ -17,7 +17,7 @@ context Reacto::Trackable do
17
17
  subscriber.on_value(4)
18
18
  subscriber.on_error(StandardError.new('error'))
19
19
  end
20
- trackable = source.map(-> (v) { v }, error: -> (e) { 5 })
20
+ trackable = source.map(error: -> (e) { 5 }, &-> (v) { v })
21
21
 
22
22
  trackable.on(value: test_on_value, error: test_on_error)
23
23
 
@@ -28,11 +28,25 @@ context Reacto::Trackable do
28
28
  it 'emits what is produced by the passed `close` function before close' do
29
29
  trackable =
30
30
  described_class.enumerable((1..5)).map(close: ->() { 10 }) do |v|
31
- v
31
+ v
32
32
  end
33
33
 
34
34
  trackable.on(value: test_on_value, close: test_on_close)
35
- expect(test_data).to be == (1..5).to_a + [10, '|']
35
+ expect(test_data).to eq((1..5).to_a + [10, '|'])
36
+ end
37
+
38
+ context 'with label' do
39
+ it 'applies the mapping passed only to the incoming values of type ' \
40
+ 'LabeledTrackable with the matching label' do
41
+ source = described_class.enumerable((1..10)).group_by_label do |value|
42
+ [(value % 3), value]
43
+ end
44
+
45
+ trackable = source.map(label: 1, close: -> { 4 }) { |value| value / 3 }
46
+ trackable.on(value: test_on_value)
47
+
48
+ expect_trackable_values(test_data.first, [0, 1, 2, 3, 4], label: 1)
49
+ end
36
50
  end
37
51
  end
38
52
  end
@@ -0,0 +1,12 @@
1
+ context Reacto::Trackable do
2
+ subject(:source) { described_class.enumerable(%w(albatross dog horse snake)) }
3
+
4
+ context '#max_by' do
5
+ it 'emits the value emitted by source that gives the maximum value from ' \
6
+ 'the given block. ' do
7
+ attach_test_trackers(source.max_by { |val| val.size })
8
+
9
+ expect(test_data).to eq(%w(albatross |))
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,19 @@
1
+ context Reacto::Trackable do
2
+ subject(:source) { described_class.enumerable(%w(albatross dog horse snake)) }
3
+
4
+ context '#max' do
5
+ it 'emits the maximum value emitted by source assuming that all the ' \
6
+ 'values implement Comparable' do
7
+ attach_test_trackers(source.max)
8
+
9
+ expect(test_data).to eq(%w(snake |))
10
+ end
11
+
12
+ it 'emits the maximum value emitted by source using the block given to ' \
13
+ 'compare the values ' do
14
+ attach_test_trackers(source.max { |val1, val2| val1.size <=> val2.size })
15
+
16
+ expect(test_data).to eq(%w(albatross |))
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  context Reacto::Trackable do
4
2
  context '#merge' do
5
3
  it 'merges the passed trackable\'s emitions with the source ones' do
@@ -12,8 +10,9 @@ context Reacto::Trackable do
12
10
  )
13
11
  trackable.await(subscription)
14
12
 
15
- expect(test_data).to be ==
16
- ["0a", "0b", "1a", "2a", "1b", "3a", "4a", "2b", "3b", "|"]
13
+ expect(test_data).to eq(
14
+ ['0a', '0b', '1a', '2a', '1b', '3a', '4a', '2b', '3b', '|']
15
+ )
17
16
  end
18
17
 
19
18
  it 'finishes with the error if `delay_error` is true' do
@@ -32,9 +31,9 @@ context Reacto::Trackable do
32
31
  )
33
32
  trackable.await(subscription, 2)
34
33
 
35
- expect(test_data).to be ==
36
- ["0a", "0b", "1a", "2a", "1b", "2b", "3b", err]
37
-
34
+ expect(test_data).to eq(
35
+ ['0a', '0b', '1a', '2a', '1b', '2b', '3b', err]
36
+ )
38
37
  end
39
38
  end
40
39
  end
@@ -0,0 +1,12 @@
1
+ context Reacto::Trackable do
2
+ subject(:source) { described_class.enumerable(%w(albatross dog horse snake)) }
3
+
4
+ context '#min_by' do
5
+ it 'emits the value emitted by source that gives the minimum value from ' \
6
+ 'the given block. ' do
7
+ attach_test_trackers(source.min_by { |val| val.size })
8
+
9
+ expect(test_data).to eq(%w(dog |))
10
+ end
11
+ end
12
+ end