Sha256: c83a39aef0c6f6ece54963a3ff92ec2b2c25eee284ab2e54a6ed169d1cf90903

Contents?: true

Size: 631 Bytes

Versions: 2

Compression:

Stored size: 631 Bytes

Contents

require "spec/helper/all"

describe EventMachine::Synchrony do

  it "defer: simple" do
    EM.synchrony do
      x = 1
    
      result = EM::Synchrony.defer do
        x = 2
        sleep 0.1
        3
      end
      
      result.should == 3      
      x.should == 2
      
      EM.stop    
    end
  end
  
  it "defer: with lambda" do
    EM.synchrony do
    
      x = 1
      
      op = lambda do
        sleep 0.1
        x += 1
        3
      end
      
      EM::Synchrony.defer(op).should == 3
      x.should == 2
              
      EM.stop
    end                                                  
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-synchrony-1.0.4 spec/defer_spec.rb
em-synchrony-1.0.3 spec/defer_spec.rb