Sha256: 4f200f86ae82436fd1885a622a73da1e1e268e55825d9a426773149717296721

Contents?: true

Size: 855 Bytes

Versions: 2

Compression:

Stored size: 855 Bytes

Contents

require "helper/all"

describe EM::Synchrony do
  describe "#sync" do
    it "returns immediately if the syncee already succeeded" do
      args = stub("args")

      Fiber.new {
        df = EM::DefaultDeferrable.new
        df.succeed args
        EM::Synchrony.sync(df).should == args

        df = EM::DefaultDeferrable.new
        df.succeed nil
        EM::Synchrony.sync(df).should == nil
      }.resume
    end
  end

  describe "#next_tick" do
    it "should wrap next_tick into a Fiber context" do
      EM.synchrony {
        begin
          fired = false
          f = Fiber.current

          EM::Synchrony.next_tick do
            fired = true
            Fiber.current.should_not eq(f)
          end

          EM::Synchrony.interrupt

          fired.should eq(true)
        ensure
          EM.stop
        end
      }
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-synchrony-1.0.6 spec/synchrony_spec.rb
em-synchrony-1.0.5 spec/synchrony_spec.rb