diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-08-15 13:56:04 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-08-15 13:56:04 +0100 |
commit | 27da0c5480ecf6b020e73f994d3240ae15b0646b (patch) | |
tree | 70acc0e93bce0eba04de1e2427df1a21acb8d59f /activesupport/test | |
parent | 63d100ea35a7fabea25c37f654177c3828fc1dcb (diff) | |
download | rails-27da0c5480ecf6b020e73f994d3240ae15b0646b.tar.gz rails-27da0c5480ecf6b020e73f994d3240ae15b0646b.tar.bz2 rails-27da0c5480ecf6b020e73f994d3240ae15b0646b.zip |
Split up the definitions in Module#delegate depending on :allow_nil, and don't use exceptions for flow control in the :allow_nil => true case.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index c33ade8381..a24f013d4f 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -44,6 +44,9 @@ class Someone < Struct.new(:name, :place) FAILED_DELEGATE_LINE = __LINE__ + 1 delegate :foo, :to => :place + + FAILED_DELEGATE_LINE_2 = __LINE__ + 1 + delegate :bar, :to => :place, :allow_nil => true end Invoice = Struct.new(:client) do @@ -194,6 +197,15 @@ class ModuleTest < Test::Unit::TestCase "[#{e.backtrace.first}] did not include [#{file_and_line}]" end + def test_delegation_exception_backtrace_with_allow_nil + someone = Someone.new("foo", "bar") + someone.bar + rescue NoMethodError => e + file_and_line = "#{__FILE__}:#{Someone::FAILED_DELEGATE_LINE_2}" + 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 |