blob: 66ddbfe62ad21df6b6db3fd9f328605bab24347a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
|