diff options
Diffstat (limited to 'activesupport/test/core_ext')
-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' }) |