Sha256: 8b9bb9784a5f0feabbdfad11971bcf4a1906f41be6c238568c2584ce9e9db996
Contents?: true
Size: 1.78 KB
Versions: 2
Compression:
Stored size: 1.78 KB
Contents
require 'spec_helper' require 'gb_dispatch' describe GBDispatch do it 'should run dispatch_async' do a = [] GBDispatch.dispatch_async :test do sleep(0.01) a << 1 end GBDispatch.dispatch_async :test do a << 2 end expect(a.empty?).to be_truthy sleep(0.03) expect(a).to eq [1, 2] end it 'should run dispatch_async_on_queue' do a = [] GBDispatch.dispatch_async_on_queue :test do sleep(0.01) a << 1 end GBDispatch.dispatch_async_on_queue :test do a << 2 end GBDispatch.dispatch_async_on_queue :test do a << 3 end expect(a.empty?).to be_truthy sleep(0.02) expect(a).to eq [1, 2, 3] end it 'should run dispatch_sync' do a = [] GBDispatch.dispatch_async :test do sleep(0.02) a << 1 end result = GBDispatch.dispatch_sync :test do a << 2 a end expect(result).to eq [1,2] end it 'should run dispatch_sync_on_queue' do a = [] GBDispatch.dispatch_async :test do sleep(0.02) a << 1 end result = GBDispatch.dispatch_sync_on_queue :test do a << 2 a end expect(result).to eq [1,2] end it 'should run dispatch_after' do a = [] GBDispatch.dispatch_after 0.1, :test do a << 1 end expect(a.empty?).to be_truthy sleep(0.15) expect(a).to eq [1] end it 'should run dispatch_after_on_queue' do a = [] GBDispatch.dispatch_after_on_queue 0.1, :test do a << 1 end expect(a.empty?).to be_truthy sleep(0.2) expect(a).to eq [1] end it 'should return proper queue' do queue = GBDispatch.get_queue :test expect(queue).to be_a GBDispatch::Queue expect(queue.name).to eq :test expect(GBDispatch.get_queue :test).to equal queue end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gb_dispatch-0.0.6 | spec/dispatch_spec.rb |
gb_dispatch-0.0.5 | spec/dispatch_spec.rb |