Permalink
Browse files

[fix] "super: no superclass method" on _rhook.to(call_method). - it c…

…ould be Method#call's bug in ruby 1.8.7.
  • Loading branch information...
1 parent df50e3e commit f42258665591c797e848e8a7ab9f68eb22aec87c Kaoru Kobo committed Jan 3, 2011
Showing with 43 additions and 1 deletion.
  1. +3 −1 lib/rhook.rb
  2. +40 −0 spec/rhook_minor_spec.rb
View
@@ -145,7 +145,9 @@ def call_method(name, method_name, args, block, opt = {})
inv.args = args
inv.block = block
inv.hooks = hooks
- inv.target_proc = @obj.method(method_name)
+ inv.target_proc = lambda do |*args, &block|
+ @obj.__send__(method_name, *args, &block)
+ end
inv.hint = opt[:hint] || {}
inv.proceed()
ensure
@@ -146,4 +146,44 @@ def both_on_method_and_to_target
end
end
end
+
+ # ========================================================================
+ describe "#call_method(#to): " do
+ before :each do
+ end
+
+ example "[bugfix] super: no superclass method" do
+ class CallMethodSuperTest_Super
+ def the_method
+
+ end
+ end
+
+ module CallMethodSuperTest_Module
+ def the_method
+ super
+ end
+ end
+
+ class CallMethodSuperTest_Inherited < CallMethodSuperTest_Super
+ include CallMethodSuperTest_Module
+ end
+
+ # This bug does not appear without hooks.
+ CallMethodSuperTest_Inherited._rhook.bind(:the_method) do |inv|
+ inv.call
+ end
+
+ # OK.
+ CallMethodSuperTest_Inherited.new.the_method
+
+ # We fixed the bug this cause error:
+ lambda {
+ CallMethodSuperTest_Inherited.new._rhook.to.the_method
+ }.should_not raise_error
+ # - super: no superclass method `the_method'
+ end
+ end
+ # ========================================================================
+
end

0 comments on commit f422586

Please sign in to comment.