File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -48,14 +48,15 @@ def constantize(camel_cased_word)
4848 constant . const_get ( name )
4949 else
5050 candidate = constant . const_get ( name )
51- next candidate if constant . const_defined? ( name , false )
51+ args = Module . method ( :const_defined? ) . arity != 1 ? [ false ] : [ ]
52+ next candidate if constant . const_defined? ( name , *args )
5253 next candidate unless Object . const_defined? ( name )
5354
5455 # Go down the ancestors to check it it's owned
5556 # directly before we reach Object or the end of ancestors.
5657 constant = constant . ancestors . inject do |const , ancestor |
5758 break const if ancestor == Object
58- break ancestor if ancestor . const_defined? ( name , false )
59+ break ancestor if ancestor . const_defined? ( name , * args )
5960 const
6061 end
6162
Original file line number Diff line number Diff line change @@ -384,7 +384,7 @@ def self.perform
384384 assert_equal nil , found
385385 end
386386 end
387-
387+
388388 it "cleans up dead worker info on start (crash recovery)" do
389389 # first we fake out two dead workers
390390 workerA = Resque ::Worker . new ( :jobs )
@@ -713,4 +713,13 @@ def self.on_failure_store_exception(exc, *args)
713713 end
714714 end
715715 end
716+
717+ it "constantizes" do
718+ assert_same Kernel , Resque ::Worker . constantize ( :Kernel )
719+ assert_same MiniTest ::Unit ::TestCase , Resque ::Worker . constantize ( 'MiniTest::Unit::TestCase' )
720+ assert_raises NameError do
721+ Resque ::Worker . constantize ( 'Object::MissingConstant' )
722+ end
723+ end
724+
716725end
You can’t perform that action at this time.
0 commit comments