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)
138138 end
139139 unless name . nil?
140140 begin
141- parent . send :remove_const , name if parent . const_defined? name
141+ parent . send :remove_const , name if parent . const_defined? ( name , false )
142142 parent . const_set ( name , clazz )
143143 clazz
144144 rescue NameError
Original file line number Diff line number Diff line change 1010 expect ( clazz . ancestors ) . to include described_class
1111 end
1212
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+
1322 it 'creates an anonymous class when given at least one member' do
1423 clazz = described_class . new ( :foo )
1524 expect { described_class . const_get ( clazz . to_s ) } . to raise_error ( NameError )
You can’t perform that action at this time.
0 commit comments