Sha256: b53923d55de4f5ba6ec1fb1f5e6ea9228054aab0b4cb71aeab19288f5254d297
Contents?: true
Size: 1019 Bytes
Versions: 1
Compression:
Stored size: 1019 Bytes
Contents
require 'spec_helper' describe 'utilities' do context '#atomic' do it 'calls the block' do @expected = false atomic{ @expected = true } @expected.should be_true end it 'passes all arguments to the block' do @expected = nil atomic(1, 2, 3, 4) do |a, b, c, d| @expected = [a, b, c, d] end @expected.should eq [1, 2, 3, 4] end it 'returns the result of the block' do expected = atomic{ 'foo' } expected.should eq 'foo' end it 'raises an exception if no block is given' do lambda { atomic() }.should raise_error end it 'creates a new Fiber' do fiber = Fiber.new{ 'foo' } Fiber.should_receive(:new).with(no_args()).and_return(fiber) atomic{ 'foo' } end it 'immediately runs the Fiber' do fiber = Fiber.new{ 'foo' } Fiber.stub(:new).with(no_args()).and_return(fiber) fiber.should_receive(:resume).with(no_args()) atomic{ 'foo' } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
concurrent-ruby-0.1.1 | spec/concurrent/utilities_spec.rb |