Sha256: 952741962b6a48f8058e63ea98b8be8b248d1d773b728643753ddeb306c87447
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
require 'spec_helper' if RUBY_VERSION > '1.9' require 'fiber' describe EMJack::Connection do it "should process live messages" do EM.run do EM.add_timer(10) { EM.stop } Fiber.new do bean = EMJack::Connection.new bean.fiber! bean.put("hello!") job = bean.reserve job.body.should == "hello!" job.delete EM.stop end.resume end end it "should process each job" do EM.run do EM.add_timer(10) { EM.stop } job_body = '' f = Fiber.new do bean = EMJack::Connection.new bean.fiber! bean.put("hello!") bean.put("bonjour!") mock = double() mock.should_receive(:foo).with("hello!") mock.should_receive(:foo).with("bonjour!") bean.each_job(0) do |job| mock.foo(job.body) job_body = job.body job.delete end end f.resume EM.add_timer(1) { EM.stop unless f.alive?; job_body.should eq "bonjour!" unless f.alive? } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
em-jack-0.1.5 | spec/em-jack/fiber_spec.rb |
em-jack-0.1.4 | spec/em-jack/fiber_spec.rb |