Sha256: 0a08324a2d1d60b20da7e8af0b958a464bf5eb08f8a18c289d6491aa62bb32f8
Contents?: true
Size: 597 Bytes
Versions: 5
Compression:
Stored size: 597 Bytes
Contents
class GonTestWorker include Gon::ControllerHelpers def request @request ||= ActionDispatch::TestRequest.create end def env request.env end def execute gon.clear gon.a ||= 1 gon.a += 1 end def value gon.a end end describe 'threading behaviour' do before do allow(Gon).to receive(:current_gon).and_call_original end it 'is threadsafe' do threads = [] 10.times do threads << Thread.new do gtw = GonTestWorker.new gtw.execute expect(gtw.value).to eq 2 end end threads.each(&:join) end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
gon-6.4.0 | spec/gon/thread_spec.rb |
gon-6.3.2 | spec/gon/thread_spec.rb |
gon-6.3.1 | spec/gon/thread_spec.rb |
gon-6.2.1 | spec/gon/thread_spec.rb |
gon-6.2.0 | spec/gon/thread_spec.rb |