Sha256: 19e12ce1521c5d2587fb06b8dc0853fa7aa1f09fb2f6a9b8bce7bed46bb51083
Contents?: true
Size: 1.27 KB
Versions: 4
Compression:
Stored size: 1.27 KB
Contents
require 'spec_helper' require 'gb_dispatch/runner' describe GBDispatch::Runner do it 'should execute synchronously' do a = :foo actor = GBDispatch::Runner.new actor.execute ->() { a=:bar } expect(a).to eq :bar actor.terminate end it 'should return result of passed block' do actor = GBDispatch::Runner.new a = actor.execute ->() { :bar } expect(a).to eq :bar actor.terminate end it 'should execute async' do a = :foo actor = GBDispatch::Runner.new actor.async.execute ->() do sleep(0.01) a = :bar end expect(a).to eq :foo sleep(0.015) expect(a).to eq :bar actor.terminate end it 'should support Celluloid Conditions' do a = :foo actor = GBDispatch::Runner.new actor.async.execute ->() { 5+5 }, :condition => ->(result) { a = result } sleep(0.01) expect(a).to eq 10 actor.terminate end context 'error handling' do it 'should call Celluloid Conditions with exception' do a = :foo actor = GBDispatch::Runner.new actor.async.execute ->() { raise StandardError.new 'Test' }, :condition => ->(result) { a = result }, name: :fail_test sleep(0.01) expect(a).to be_kind_of StandardError expect(actor.alive?).to be_falsey end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
gb_dispatch-0.0.4 | spec/runner_spec.rb |
gb_dispatch-0.0.3 | spec/runner_spec.rb |
gb_dispatch-0.0.2 | spec/runner_spec.rb |
gb_dispatch-0.0.1 | spec/runner_spec.rb |