Sha256: d5f92419fa6c52d0cd70636dc0bc984e302f4318c0303b28f26527514afc0723
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
describe Whenner do describe '#defer' do it 'returns a new promise' do promise = Whenner.defer { 'bla' } expect(promise).to be_kind_of(Whenner::Promise) end it 'yields a deferred' do expect { |b| Whenner.defer(&b) }.to yield_with_args(Whenner::Deferred) end end describe '#when' do let(:deferred1) { Whenner::Deferred.new } let(:deferred2) { Whenner::Deferred.new } let!(:promise) { Whenner.when(deferred1.promise, deferred2.promise) } it 'returns a promise' do expect(Whenner.when).to be_kind_of(Whenner::Promise) end it 'resolves when all given promises are resolved' do expect { deferred1.fulfill }.not_to change { promise.resolved? }.from(false) expect { deferred2.fulfill }.to change { promise.resolved? }.to(true) end it 'fulfills with all values' do deferred1.fulfill :a deferred2.fulfill :b expect(promise.value).to eql([:a, :b]) end it 'rejects with the first reason' do deferred1.reject :a deferred2.reject :b expect(promise.reason).to eql(:a) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
whenner-0.2.0 | spec/whenner_spec.rb |
whenner-0.1.1 | spec/whenner_spec.rb |