# In test_helper.rb
# Give this function an array of invalid values, an array of valid values, the object and
# attribute name to test, and it will ensure that only valid values are allowed
def validation_tester ( valid_values, invalid_values, attribute_name, test_object )
valid_values.each do |val|
test_object.[]=(attribute_name, val)
assert test_object.save, "#{attribute_name} should be valid: #{test_object.[](attribute_name)}"
assert test_object.valid?
assert !test_object.errors.invalid?(attribute_name)
end
invalid_values.each do |val|
test_object.[]=(attribute_name, val)
assert !test_object.save, "#{attribute_name} should NOT be valid: #{val}"
assert !test_object.valid?
assert test_object.errors.invalid?(attribute_name)
end
end