Rails 3.1,FactoryGirl 还是 Factory?
我正在尝试使用规范构建测试,但我对使用 FactoryGirl 或 Factory 感到困惑, 我安装了 FactoryGirl 2.3.2,因为我在 GemFile 中有 gem "factory_girl_rails", "~> 1.2"
Factory 的声明位于 /home/sam/.rvm/gems/ruby-1.9 .3-p0/gems/factory_girl-2.3.2/lib/factory_girl/deprecated.rb
我看到 Factory 在这样的示例中使用: 如何创建与 has_many 的关联:通过 Factory Girl 中的关系?
有什么想法吗? Rails 3.1 可以使用 Factory 吗?不总是?一点也不 ?
I am trying to build tests using specs, and I am confused about using FactoryGirl or Factory,
I have FactoryGirl 2.3.2 installed, as I have gem "factory_girl_rails", "~> 1.2"
in GemFile
The declaration of Factory is at /home/sam/.rvm/gems/ruby-1.9.3-p0/gems/factory_girl-2.3.2/lib/factory_girl/deprecated.rb
I see Factory used in examples like this: How do I create an association with a has_many :through relationship in Factory Girl?
Any idea please ? is it Ok to use Factory at Rails 3.1 ? not always ? not at all ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我对 deprecation.rb 的理解,只有 FactoryGirl 定义的方法(例如别名)在与 Factory 一起使用时才会被弃用。我想您可以继续使用 Factory.xxxx 调用来构建/创建实例。
As far as I can understand of deprecation.rb, only methods defined by FactoryGirl (e.g. aliases) are deprecated when using with Factory. I guess you can keep on using Factory.xxxx calls to build/create instances.