File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
lib/concurrent/synchronization Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ def ns_initialize(*values)
138
138
end
139
139
unless name . nil?
140
140
begin
141
- parent . send :remove_const , name if parent . const_defined? name
141
+ parent . send :remove_const , name if parent . const_defined? ( name , false )
142
142
parent . const_set ( name , clazz )
143
143
clazz
144
144
rescue NameError
Original file line number Diff line number Diff line change 10
10
expect ( clazz . ancestors ) . to include described_class
11
11
end
12
12
13
+ it 'registers the class when given a class name which is defined in the ancestors' do
14
+ class_name = 'ValidClassName2'
15
+ Object . const_set ( class_name , class_name )
16
+ clazz = described_class . new ( class_name )
17
+ expect { described_class . const_get ( class_name ) } . to_not raise_error
18
+ expect ( clazz ) . to be_a Class
19
+ expect ( clazz . ancestors ) . to include described_class
20
+ end
21
+
13
22
it 'creates an anonymous class when given at least one member' do
14
23
clazz = described_class . new ( :foo )
15
24
expect { described_class . const_get ( clazz . to_s ) } . to raise_error ( NameError )
You can’t perform that action at this time.
0 commit comments