describe('count', function() it('passes through errors', function() local _, onError = observableSpy(Rx.Observable.throw():count()) expect(#onError).to.equal(1) end) it('produces a single value representing the number of elements produced by the source', function() local observable = Rx.Observable.fromRange(5):count() expect(observable).to.produce(5) end) it('uses the predicate to filter for values if it is specified', function() local observable = Rx.Observable.fromRange(5):count(function(x) return x > 3 end) expect(observable).to.produce(2) end) it('calls onError if the predicate errors', function() local onError = spy() Rx.Observable.fromRange(3):count(error):subscribe(nil, onError, nil) expect(#onError).to.equal(1) end) end)