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)
48
48
constant . const_get ( name )
49
49
else
50
50
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 )
52
53
next candidate unless Object . const_defined? ( name )
53
54
54
55
# Go down the ancestors to check it it's owned
55
56
# directly before we reach Object or the end of ancestors.
56
57
constant = constant . ancestors . inject do |const , ancestor |
57
58
break const if ancestor == Object
58
- break ancestor if ancestor . const_defined? ( name , false )
59
+ break ancestor if ancestor . const_defined? ( name , * args )
59
60
const
60
61
end
61
62
Original file line number Diff line number Diff line change @@ -384,7 +384,7 @@ def self.perform
384
384
assert_equal nil , found
385
385
end
386
386
end
387
-
387
+
388
388
it "cleans up dead worker info on start (crash recovery)" do
389
389
# first we fake out two dead workers
390
390
workerA = Resque ::Worker . new ( :jobs )
@@ -713,4 +713,13 @@ def self.on_failure_store_exception(exc, *args)
713
713
end
714
714
end
715
715
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
+
716
725
end
You can’t perform that action at this time.
0 commit comments