This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 22
33class Thread
44 attr_accessor :__rspec_local_data
5+
6+ class << self
7+ alias __current_for_rspec current
8+ end
59end
610
711module RSpec
@@ -96,7 +100,7 @@ def self.class_of(object)
96100
97101 # A single thread local variable so we don't excessively pollute that namespace.
98102 def self . thread_local_data
99- Thread . current . __rspec_local_data ||= { }
103+ Thread . __current_for_rspec . __rspec_local_data ||= { }
100104 end
101105
102106 # @api private
Original file line number Diff line number Diff line change @@ -205,6 +205,13 @@ def object.some_method
205205 end
206206 end
207207
208+ it "works when Thread.current is mocked" do
209+ expect ( Thread ) . to_not receive ( :current )
210+
211+ RSpec ::Support . thread_local_data [ :__for_test ] = :oh_hai
212+ expect ( RSpec ::Support . thread_local_data [ :__for_test ] ) . to eq :oh_hai
213+ end
214+
208215 it "works when Thread#thread_variable_get and Thread#thread_variable_set are mocked" do
209216 expect ( Thread . current ) . to receive ( :thread_variable_set ) . with ( :test , true ) . once . and_return ( true )
210217 expect ( Thread . current ) . to receive ( :thread_variable_get ) . with ( :test ) . once . and_return ( true )
You can’t perform that action at this time.
0 commit comments