没有这样的工厂:用户(ArgumentError)但是......它已定义。并且使用 find_definitions() 只是查找重复项...=\

发布于 2024-12-02 19:56:43 字数 1080 浏览 1 评论 0原文

因此,我最近转向了捆绑程序,但在让一切重新正常工作时遇到了问题。

当我运行bundle exec rake test:units时,我收到此错误:

....../gems/factory_girl-1.2.4/lib/factory_girl/factory.rb:327:in `factory_by_name': No such factory: user (ArgumentError)

并且,我在另一篇堆栈溢出帖子中看到有人通过添加但是解决了问题

FactoryGirl.find_definitions

,错误说我有重复的定义(我没有,原因搜索) 我什至尝试只拥有一个工厂文件。但错误仍然存​​在。

test_helper 顶部:

require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
  require "bundler/setup"
  Bundler.require(:test)

gem 文件中的测试组

group :test do
    gem "cucumber", "~>0.10.3"
    gem "cucumber-rails", "0.3.2"
    gem "launchy"
    gem "hpricot"
    gem "gherkin", "~>2.4.0"

    gem "capybara", "0.4.1.2"
    gem "rspec", "1.3.2"
    gem "rspec-rails", "1.3.2"
    gem "rspec-core"
    gem "rspec-expectations"

    gem "webrat", "0.7.0"
    gem "database_cleaner"

    gem "factory_girl", "1.2.4"
    gem "shoulda"
    gem "awesome_print"
    gem "cobravsmongoose"
end

So, I recently moved to bundler, and I'm having issues getting everything working again.

when I run bundle exec rake test:units, I get this error:

....../gems/factory_girl-1.2.4/lib/factory_girl/factory.rb:327:in `factory_by_name': No such factory: user (ArgumentError)

and, I saw in a another stack overflow post that someone fixed the problem by adding

FactoryGirl.find_definitions

but, that errors in saying that I have duplicate definitions (which I don't, cause search)
I even tried having only one factories file. but the error continued.

top of test_helper:

require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
  require "bundler/setup"
  Bundler.require(:test)

test group in gem file

group :test do
    gem "cucumber", "~>0.10.3"
    gem "cucumber-rails", "0.3.2"
    gem "launchy"
    gem "hpricot"
    gem "gherkin", "~>2.4.0"

    gem "capybara", "0.4.1.2"
    gem "rspec", "1.3.2"
    gem "rspec-rails", "1.3.2"
    gem "rspec-core"
    gem "rspec-expectations"

    gem "webrat", "0.7.0"
    gem "database_cleaner"

    gem "factory_girl", "1.2.4"
    gem "shoulda"
    gem "awesome_print"
    gem "cobravsmongoose"
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文