如何在工厂女孩中安装调试器?

发布于 2024-10-31 15:25:29 字数 62 浏览 2 评论 0原文

如何调试factory_girl?我试图将调试器放在那里,但我就是不能。我只是想测试为什么我的关联无法正常工作

How do you debug factory_girl? i've tried to put debugger in there but i just cant. I just want to test why my associations aren't working right

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罪歌 2024-11-07 15:25:29

你是如何使用调试器的?如果您尝试在测试环境中使用它,我对它不起作用并不感到惊讶。但factory_girl并不局限于测试环境。

只需在开发环境中需要factory_girl gem 和相关工厂,使用调试器(或只是控制台)启动服务器,然后就可以进行调试了。

更新

我在https://github.com/lstejskal/icanhazblog。当您安装它并运行“rails console”时,您可以执行以下操作:

$ a = Factory.create :article
=> #<Article _id: 4dc27b867319e80fb2000001, created_at: 2011-05-05 10:27:18 UTC,
updated_at: 2011-05-05 10:27:18 UTC, title: "Article 1", content: "This is a content
for Article 1.", visible: true, published_at: 2011-02-11 23:00:00 UTC, tags: ["ruby",
"rails", "sinatra"]> 
$ a.title
=> "Article 1" 

在开发模式下启动时只需添加类似的内容:

require 'factory_girl'
# require factories
Dir["#{PATH_TO_FACTORIES}/*.rb"].each { |f| require f }

How did you use the debugger? If you tried to use it in test environment, I'm not surprised it didn't work. But factory_girl is not limited to test environment.

Simply require factory_girl gem and relevant factories in development environment, start the server with debugger (or just console) and you're set for debugging.

UPDATE

I have this setup in https://github.com/lstejskal/icanhazblog. When you install it and run 'rails console', you can then do stuff like:

$ a = Factory.create :article
=> #<Article _id: 4dc27b867319e80fb2000001, created_at: 2011-05-05 10:27:18 UTC,
updated_at: 2011-05-05 10:27:18 UTC, title: "Article 1", content: "This is a content
for Article 1.", visible: true, published_at: 2011-02-11 23:00:00 UTC, tags: ["ruby",
"rails", "sinatra"]> 
$ a.title
=> "Article 1" 

Just add something like this when starting in development mode:

require 'factory_girl'
# require factories
Dir["#{PATH_TO_FACTORIES}/*.rb"].each { |f| require f }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文