Sha256: 29e61b2a92d5c834a1c612347856264a27eb1a35ad08f71016f0fd4c60a9d9da

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

require 'jellyfish/test'
require 'muack'

include Muack::API

describe Jellyfish do
  after do
    Muack.verify
  end

  app = Class.new{
    include Jellyfish
    handle(Exception){ |env| 0 }
  }.new

  exp = RuntimeError.new

  should "no RuntimeError: can't add a new key into hash during iteration" do
    # make static ancestors so that we could stub it
    ancestors = RuntimeError.ancestors
    stub(RuntimeError).ancestors{ancestors}
    flip = true
    stub(ancestors).index(anything).proxy.returns do |i|
      if flip
        flip = false
        sleep 0.0001
      end
      i
    end

    2.times.map{
      Thread.new do
        app.send(:best_handler, exp).call({}).should.eq 0
      end
    }.each(&:join)

    flip.should.eq false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jellyfish-0.9.1 test/test_threads.rb