spec/thread_safety_spec.rb in countries-4.2.3 vs spec/thread_safety_spec.rb in countries-5.0.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + describe 'Accessing ISO3166::Country instances data in multiple threads' do before do if Thread.respond_to?(:report_on_exception) @report_on_exception_value = Thread.report_on_exception Thread.report_on_exception = false @@ -10,11 +12,11 @@ def create_countries_threaded nthreads = 100 threads = [] - alpha2_codes = ['us', 'es', 'nl', 'ca', 'de', 'fr', 'mx', 'ru', 'ch', 'jp'] + alpha2_codes = %w[us es nl ca de fr mx ru ch jp] nthreads.times do threads << Thread.new do alpha2_codes.each do |a2| country = ISO3166::Country[a2] @@ -29,11 +31,11 @@ it "doesn't raise any exceptions when using a mutex" do expect { create_countries_threaded }.to_not raise_error end - it "raises NoMethodError when not using a mutex" do + it 'raises NoMethodError when not using a mutex' do allow(ISO3166::Data).to receive(:use_mutex?).and_return(false) expect { create_countries_threaded }.to raise_error(NoMethodError) end @@ -41,6 +43,5 @@ if Thread.respond_to?(:report_on_exception) Thread.report_on_exception = @report_on_exception_value end end end -