Permalink
Browse files

Merge pull request #10828 from southpolesteve/delegation_error_class

Create DelegationError class
  • Loading branch information...
2 parents 577fad1 + 8139d72 commit 3f50dd21c13359735bb40c5693010c6dd5e4b132 @senny senny committed Jun 26, 2013
@@ -176,7 +176,7 @@ def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &
end # end
EOS
else
- exception = %(raise "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
+ exception = %(raise DelegationError, "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
module_eval(<<-EOS, file, line - 2)
def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &block)
@@ -194,3 +194,5 @@ def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &
end
end
end
+
+class DelegationError < StandardError ; end
@@ -207,7 +207,7 @@ def test_delegation_with_allow_nil_and_nil_value_and_prefix
def test_delegation_without_allow_nil_and_nil_value
david = Someone.new("David")
- assert_raise(RuntimeError) { david.street }
+ assert_raise(DelegationError) { david.street }
end
def test_delegation_to_method_that_exists_on_nil

0 comments on commit 3f50dd2

Please sign in to comment.