File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 108108 end
109109 end # describe 'max_group_results'
110110
111+ describe 'thread safety' do
112+ it 'uses thread-local global config values' do
113+ thread = Thread . new do
114+ RegexpExamples ::Config . max_group_results = 1
115+ expect ( /\d / . examples ) . to eq %w( 0 )
116+ end
117+ sleep 0.1 # Give the above thread time to run
118+ expect ( /\d / . examples ) . to eq %w( 0 1 2 3 4 )
119+ thread . join
120+ end
121+
122+ it 'uses thread-local block config values' do
123+ thread = Thread . new do
124+ RegexpExamples ::Config . with_configuration ( max_group_results : 1 ) do
125+ expect ( /\d / . examples ) . to eq %w( 0 )
126+ sleep 0.2 # Give the below thread time to run while this block is open
127+ end
128+ end
129+ sleep 0.1 # Give the above thread time to run
130+ expect ( /\d / . examples ) . to eq %w( 0 1 2 3 4 )
131+ thread . join
132+ end
133+ end # describe 'thread safety'
134+
111135end
You can’t perform that action at this time.
0 commit comments