diff --git a/lib/rx/linq/observable/do.rb b/lib/rx/linq/observable/do.rb index 21933d8..4bb405b 100644 --- a/lib/rx/linq/observable/do.rb +++ b/lib/rx/linq/observable/do.rb @@ -22,7 +22,7 @@ def do(observer_or_on_next = nil, on_error_func = nil, on_completed_func = nil) }, lambda {|err| begin - on_error_func && on_error_func.call(x) + on_error_func && on_error_func.call(err) rescue => e observer.on_error e end diff --git a/test/rx/linq/observable/test_do.rb b/test/rx/linq/observable/test_do.rb new file mode 100644 index 0000000..4efc698 --- /dev/null +++ b/test/rx/linq/observable/test_do.rb @@ -0,0 +1,16 @@ +require "#{File.dirname(__FILE__)}/../../../test_helper" + +class TestObservableDo < Minitest::Test + def test_do_error_propagation + expected = RuntimeError.new + actual = nil + assert_raises(RuntimeError) do + Rx::Observable.raise_error(expected).do( + ->(_) {}, + ->(_err) { actual = _err }, + -> {} + ).subscribe + end + assert_equal actual, expected + end +end