Technical
Unit Tests

Testing custom properties (quick one)

I had a case where I had to use a view rather then table, which would not give me column_names, so i had to write bunch of properties that would look this way.


 def address1
    read_attribute("address1")
  end
  def address1=(value)
    write_attribute("address1",value)
  end
  def address2
    read_attribute("address2")
  end
  def address2=(value)
    write_attribute("address2",value)
  end

ruby came to my rescue on saving all that typing for each property, so i was able to do:


def test_properties
    address = LegalEntityAddress.new
    ["address1","address2","city","postalCode","comment","state","country","address_type_id","legalEntityId","parentId"].each do |method|
      assert_nothing_raised{ address.send("#{method}")}
      assert_nothing_raised{address.send "#{method.to_sym}=","test"}
    end
  end