【问题标题】:Rails with Factory Girl Configuration possible Scoping Issue, best practices?Rails with Factory Girl Configuration 可能的范围问题,最佳实践?
【发布时间】:2015-01-09 19:02:32
【问题描述】:

Factory Girl getting started documentation 中,它说要像这样包含帮助程序模块:

# RSpec
# spec/support/factory_girl.rb
RSpec.configure do |config|
  config.include FactoryGirl::Syntax::Methods
end

在 RSpec 配置块内。但这对我不起作用。我只是将模块包含放在rails_helper.rb 的开头,它工作正常。

我的问题是为什么文档说要把它放在配置块中?那应该工作吗?我会遇到方法冲突吗?我是否违背了最佳实践?

【问题讨论】:

    标签: ruby-on-rails rspec factory-bot rspec-rails


    【解决方案1】:

    默认情况下不加载位于规范/支持中的文件。在 Rails 4.2 的 spec/rails_helper.rb 中取消注释第 21 行。

    【讨论】:

      猜你喜欢
      • 2012-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-14
      • 2020-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多