1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/lib/factory_girl/attribute.rb
Peter Suschlik 263e7be9da Fix exception message when defining attr writer.
Before this patch the message looked like:
factory_girl uses 'f.test value' syntax rather than 'f.test= = value'

Signed-off-by: Nick Quaranto <nick@quaran.to>
2009-04-20 17:09:20 -04:00

29 lines
676 B
Ruby

class Factory
# Raised when defining an invalid attribute:
# * Defining an attribute which has a name ending in "="
# * Defining an attribute with both a static and lazy value
# * Defining an attribute twice in the same factory
class AttributeDefinitionError < RuntimeError
end
class Attribute #:nodoc:
attr_reader :name
def initialize(name)
@name = name.to_sym
if @name.to_s =~ /=$/
attribute_name = $`
raise AttributeDefinitionError,
"factory_girl uses 'f.#{attribute_name} value' syntax " +
"rather than 'f.#{attribute_name} = value'"
end
end
def add_to(proxy)
end
end
end