Sha256: 350e02e90aaf76bef413f394ab10e0b9b05fdd7f58de27069517aea8df98b58f

Contents?: true

Size: 763 Bytes

Versions: 1

Compression:

Stored size: 763 Bytes

Contents

require 'jellyfish/test'
require 'muack'

include Muack::API

describe Jellyfish do
  after do
    Muack.verify
  end

  app = Class.new{
    include Jellyfish
    handle(StandardError){ |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.2 test/test_threads.rb