class AttributeAliasingTest

Constants

Data

Public Instance Methods

test_aliasing_to_uppercase_attributes() click to toggle source
# File activesupport/test/core_ext/module/attribute_aliasing_test.rb, line 44
def test_aliasing_to_uppercase_attributes
  # Although it's very un-Ruby, some people's AR-mapped tables have
  # upper-case attributes, and when people want to alias those names
  # to more sensible ones, everything goes *foof*.
  e = AttributeAliasing::Email.new

  assert !e.body?
  assert !e.Data?

  e.body = "No, really, this is not a joke."
  assert_equal "No, really, this is not a joke.", e.Data
  assert e.Data?

  e.Data = "Uppercased methods are the suck"
  assert_equal "Uppercased methods are the suck", e.body
  assert e.body?
end
test_attribute_alias() click to toggle source
# File activesupport/test/core_ext/module/attribute_aliasing_test.rb, line 30
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