Sha256: df6ce7f6946b0ff6627ea1c7a52d2e5ab0af91ed726a5a8b5a98e1997c36f7cb
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
# encoding: UTF-8 require File.expand_path('../../test_helper', __FILE__) require 'eventmachine' class AsyncTest < MiniTest::Spec def setup @site = setup_site @filename = Time.now.to_i @filepath = @site.root / @filename File.exist?(@filepath).should be_false end def teardown teardown_site end context "async system calls" do should "be able to test for running EM reactor" do Spontaneous.async?.should be_false EM.run do Spontaneous.async?.should be_true EM.stop end Spontaneous.async?.should be_false end should "use fibers to simulate sync code if running in a fiber" do EM.run do result = Spontaneous.system("touch #{@filepath}") { File.exist?(@filepath).should be_true } EM.stop end end # TODO: can't get this to work at moment' # should "resort to sync code if execution is not running in a fiber" do # EM.run do # result = Spontaneous.system("touch #{@filepath}") # File.exist?(@filepath).should be_true # EM.stop # end # end should "run synchronously outside of EM reactor" do Spontaneous.system("touch #{@filepath}") { |result| File.exist?(@filepath).should be_true result.should be_true } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spontaneous-0.2.0.beta1 | test/unit/test_async.rb |