From a58b2d8044ca15c9af5d541b767f7a3dbeadfd5d Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Tue, 20 Jul 2010 22:39:00 -0400 Subject: [PATCH] Allow private methods to be performed in the background --- lib/delayed/performable_method.rb | 2 +- spec/performable_method_spec.rb | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/delayed/performable_method.rb b/lib/delayed/performable_method.rb index f70330038..0eec78623 100644 --- a/lib/delayed/performable_method.rb +++ b/lib/delayed/performable_method.rb @@ -1,7 +1,7 @@ module Delayed class PerformableMethod < Struct.new(:object, :method, :args) def initialize(object, method, args) - raise NoMethodError, "undefined method `#{method}' for #{object.inspect}" unless object.respond_to?(method) + raise NoMethodError, "undefined method `#{method}' for #{object.inspect}" unless object.respond_to?(method, true) self.object = object self.args = args diff --git a/spec/performable_method_spec.rb b/spec/performable_method_spec.rb index b8200046f..298619c70 100644 --- a/spec/performable_method_spec.rb +++ b/spec/performable_method_spec.rb @@ -22,9 +22,20 @@ end end - it "should raise a ArgumentError if target method doesn't exist" do + it "should raise a NoMethodError if target method doesn't exist" do lambda { Delayed::PerformableMethod.new(Object, :method_that_does_not_exist, []) }.should raise_error(NoMethodError) end + + it "should not raise NoMethodError if target method is private" do + clazz = Class.new do + def private_method + end + private :private_method + end + lambda { + Delayed::PerformableMethod.new(clazz.new, :private_method, []) + }.should_not raise_error(NoMethodError) + end end