aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-08-15 12:50:57 +0100
committerJon Leighton <j@jonathanleighton.com>2011-08-15 13:03:28 +0100
commit63d100ea35a7fabea25c37f654177c3828fc1dcb (patch)
treee6e0800b7f36fc597f9d2f034c87bcda73a51482 /activesupport/test/core_ext
parent7b56fb034a2f9a03ccbdc485287946b49e5e9b68 (diff)
downloadrails-63d100ea35a7fabea25c37f654177c3828fc1dcb.tar.gz
rails-63d100ea35a7fabea25c37f654177c3828fc1dcb.tar.bz2
rails-63d100ea35a7fabea25c37f654177c3828fc1dcb.zip
Fix the line number in the backtrace when Module#delegate raises
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/module_test.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index 074a3412d4..c33ade8381 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -38,9 +38,12 @@ Somewhere = Struct.new(:street, :city) do
end
end
-Someone = Struct.new(:name, :place) do
+class Someone < Struct.new(:name, :place)
delegate :street, :city, :to_f, :protected_method, :private_method, :to => :place
delegate :upcase, :to => "place.city"
+
+ FAILED_DELEGATE_LINE = __LINE__ + 1
+ delegate :foo, :to => :place
end
Invoice = Struct.new(:client) do
@@ -182,6 +185,15 @@ class ModuleTest < Test::Unit::TestCase
end
end
+ def test_delegation_exception_backtrace
+ someone = Someone.new("foo", "bar")
+ someone.foo
+ rescue NoMethodError => e
+ file_and_line = "#{__FILE__}:#{Someone::FAILED_DELEGATE_LINE}"
+ assert e.backtrace.first.include?(file_and_line),
+ "[#{e.backtrace.first}] did not include [#{file_and_line}]"
+ end
+
def test_parent
assert_equal Yz::Zy, Yz::Zy::Cd.parent
assert_equal Yz, Yz::Zy.parent