Sha256: 39e51ea94cd6393c4bced4b0bbac8a8d5f5a6be7d01fd8c494c09c1298f96397

Contents?: true

Size: 876 Bytes

Versions: 1

Compression:

Stored size: 876 Bytes

Contents

#
# This file is part of the ballast gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#

require "spec_helper"

describe Ballast do
  describe "#in_em_thread" do
    it "should yield the block in EM::Synchrony thread" do
      counter = 0
      allow(EM).to receive(:reactor_running?).and_return(true)
      expect(EM::Synchrony).to receive(:defer){|&block| block.call }

      Ballast.in_em_thread { counter = 1 }
      expect(counter).to eq(1)
    end

    it "should call the block normally if EM::Synchrony is not running" do
      counter = 0
      allow(EM).to receive(:reactor_running?).and_return(false)
      expect(EM::Synchrony).not_to receive(:defer)

      Ballast.in_em_thread { counter = 1 }
      expect(counter).to eq(1)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ballast-1.8.0 spec/ballast_spec.rb