Sha256: 668631cafd767312b427f21acc8904b938bcdf004539008bd4195b266066b07a

Contents?: true

Size: 647 Bytes

Versions: 1

Compression:

Stored size: 647 Bytes

Contents

require 'test_helper'

class TestConfigurationSynchronized < MiniTest::Test
  module TestModuleA
    include Configurations

    configuration_defaults do |c|
      c.a = -1
    end
  end

  module TestModuleB
    include Configurations

    configuration_defaults do |c|
      c.a = -1
    end
  end

  def test_configuration_synchronized
    collector = []
    semaphore = Mutex.new
    threads = 100.times.map do |i|
      Thread.new do
        sleep i%50 / 1000.0
        collector << TestModuleA.configure do |c|
          c.a = i
        end.a
      end
    end
    threads.each(&:join)

    assert_equal 100, collector.uniq.size
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
configurations-2.2.1 test/configurations/configuration/test_configure_synchronized.rb