工厂女孩:如何建造一个不受模型束缚的工厂?
我只需要信用卡和地址等属性的哈希值。 示例:
Factory.define :credit_card, :class => Object do |c|
c.first_name "Alice"
c.last_name "Liddel"
c.month "May"
c.year { Time.now.year + 1 }
c.number "1234567812345678"
c.type "Visa"
c.verification_value "123"
end
显然,对象没有任何属性,而且我没有credit_cord 对象...我只需要一个标准的信用卡骨架。
I just need a hash of attributes for things like credit card, and address.
Example:
Factory.define :credit_card, :class => Object do |c|
c.first_name "Alice"
c.last_name "Liddel"
c.month "May"
c.year { Time.now.year + 1 }
c.number "1234567812345678"
c.type "Visa"
c.verification_value "123"
end
obviously, object doesn't have any attributes, and I don't have a credit_cord object... I just need a standard credit card skeleton.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用工厂女孩来做这件事有什么好处?辅助方法怎么样:
What is the advantage of using factory girl for this? How about a helper method: