Sha256: 290f92f6621db3605750c2e50ea5b6e0377cd97deecc37933811c54343f1be5c
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require_relative 'helper' class TestModuleUtils < Test::Unit::TestCase def test_provides_a_k_method_for_generating_constant_arrays obj = Object.new obj.extend FFaker::ModuleUtils result = obj.k %w[1 2 3] assert result.frozen? result.each { |e| assert e.frozen? } end def test_unique generator = Object.new generator.extend FFaker::ModuleUtils # returns [1 1 2 2 1 1 2 2 ..][call_index] def generator.test index = Thread.current[:test_unique] ||= 0 Thread.current[:test_unique] = (index > 2 ? 0 : index + 1) (index / 2) + 1 end assert_equal(1, generator.unique.test) assert_equal(2, generator.unique.test) Thread.new do assert_equal(1, generator.unique.test) assert_equal(2, generator.unique.test) assert_raises FFaker::UniqueUtils::RetryLimitExceeded do generator.unique.test end generator.unique.clear generator.unique.test end.join assert_raises FFaker::UniqueUtils::RetryLimitExceeded do generator.unique.test end FFaker::UniqueUtils.clear generator.unique.test end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ffaker-2.23.0 | test/test_module_utils.rb |
ffaker-2.22.0 | test/test_module_utils.rb |