diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-08-03 18:47:43 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-08-03 18:47:43 +0000 |
commit | 9d00b0ce858a6f642089a477e7d39fb3f9cf6777 (patch) | |
tree | 1da460b1b198591eca304b91e35eb1d27c42e9b4 /activesupport/test | |
parent | b5c2366569573c76ab9dcbf871a4a00b91d7f141 (diff) | |
download | rails-9d00b0ce858a6f642089a477e7d39fb3f9cf6777.tar.gz rails-9d00b0ce858a6f642089a477e7d39fb3f9cf6777.tar.bz2 rails-9d00b0ce858a6f642089a477e7d39fb3f9cf6777.zip |
Added Module#alias_attribute [Jamis/DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4653 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/module/attribute_aliasing_test.rb | 31 | ||||
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 1 |
2 files changed, 31 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/module/attribute_aliasing_test.rb b/activesupport/test/core_ext/module/attribute_aliasing_test.rb new file mode 100644 index 0000000000..66ddbfe62a --- /dev/null +++ b/activesupport/test/core_ext/module/attribute_aliasing_test.rb @@ -0,0 +1,31 @@ +require File.dirname(__FILE__) + '/../../abstract_unit' + +module AttributeAliasing + class Content + attr_accessor :title + + def title? + !title.nil? + end + end + + class Email < Content + alias_attribute :subject, :title + end +end + +class AttributeAliasingTest < Test::Unit::TestCase + def test_attribute_alias + e = AttributeAliasing::Email.new + + assert !e.subject? + + e.title = "Upgrade computer" + assert_equal "Upgrade computer", e.subject + assert e.subject? + + e.subject = "We got a long way to go" + assert_equal "We got a long way to go", e.title + assert e.title? + end +end diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 5507ef3120..cdcb511e45 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -117,7 +117,6 @@ module BarMethodAliaser end class MethodAliasingTest < Test::Unit::TestCase - def setup Object.const_set(:FooClassWithBarMethod, Class.new) FooClassWithBarMethod.send(:define_method, 'bar', Proc.new { 'bar' }) |