沉默工厂女孩伐木

时间:2009-11-18 19:27:37

标签: ruby tdd rspec cucumber factory-bot

为了清除空气,我不是一些残酷的工厂大师试图让工作女士们沉默。我有一个非常讨厌的问题,当我在我的规范中使用Thoughtbot的工厂女孩​​时,每次使用Factory.create(:foo)时,新创建的ActiveRecord模型实例都会记录到控制台。这使得查看我的控制台输出更难以在视觉上过滤掉所有额外的日志记录。是否有某个设置或可以设置的标志会使这个额外的日志记录静音?

以下是我的rspec输出的一个小例子。 '。'在每一行的开头,在这种情况下,是一个成功的测试。

loading autotest/rspec
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby /Library/Ruby/Gems/1.8/gems/rspec-1.2.9/bin/spec --autospec spec/publisher_spec.rb -O spec/spec.opts 
#<Event id: nil, oid: "mainEvent1", name: "Main Event", short_name: "mainevent", time_zone: "PST", created_at: nil, updated_at: nil, draft: true, draft_origin_id: nil, draft_deleted: false>
#<Event id: nil, oid: "mainEvent1", name: "Main Event", short_name: "mainevent", time_zone: "PST", created_at: "2009-11-18 19:11:56", updated_at: "2009-11-18 19:11:56", draft: true, draft_origin_id: 3, draft_deleted: false>
#<Event id: nil, oid: "bumbershoo", name: "Bumbershoot", short_name: "bumbershoot", time_zone: "PST", created_at: nil, updated_at: nil, draft: true, draft_origin_id: nil, draft_deleted: false>
#<Notification id: nil, oid: "8P93CNEcl0", event_id: 3, name: "Penut Butter Jelly Time", url: nil, type: "Alert", priority: 10, last_displayed: "2009-11-16 19:11:54", format: nil, content: "IT'S PENUT BUTTER JELLY TIME.  WHERE YOU AT? WHERE ...", image: nil, is_active: true, created_at: nil, updated_at: nil, updated_by: nil, image_file_name: nil, image_content_type: nil, image_file_size: nil, image_updated_at: nil, draft: true, draft_origin_id: nil, draft_deleted: false>
#<Notification id: nil, oid: "8P93CNEcl0", event_id: 3, name: "Penut Butter Jelly Time", url: nil, type: "Alert", priority: 10, last_displayed: "2009-11-16 19:11:54", format: nil, content: "IT'S PENUT BUTTER JELLY TIME.  WHERE YOU AT? WHERE ...", image: nil, is_active: true, created_at: "2009-11-18 19:11:57", updated_at: "2009-11-18 19:11:57", updated_by: nil, image_file_name: nil, image_content_type: nil, image_file_size: nil, image_updated_at: nil, draft: true, draft_origin_id: 3, draft_deleted: false>
.#<Event id: nil, oid: "mainEvent1", name: "Main Event", short_name: "mainevent", time_zone: "PST", created_at: nil, updated_at: nil, draft: true, draft_origin_id: nil, draft_deleted: false>
#<Event id: nil, oid: "bumbershoo", name: "Bumbershoot", short_name: "bumbershoot", time_zone: "PST", created_at: nil, updated_at: nil, draft: true, draft_origin_id: nil, draft_deleted: false>
.#<Event id: nil, oid: "mainEvent1", name: "Main Event", short_name: "mainevent", time_zone: "PST", created_at: nil, updated_at: nil, draft: true, draft_origin_id: nil, draft_deleted: false>
.#<Event id: nil, oid: "mainEvent1", name: "Main Event", short_name: "mainevent", time_zone: "PST", created_at: nil, updated_at: nil, draft: true, draft_origin_id: nil, draft_deleted: false>
.#<Event id: nil, oid: "mainEvent1", name: "Main Event", short_name: "mainevent", time_zone: "PST", created_at: nil, updated_at: nil, draft: true, draft_origin_id: nil, draft_deleted: false>

我多次挑选我的规格,看看我是否有“把foo.inspect”放在任何地方,而我却没有。对于我使用自动测试和正常运行测试的所有rspec和黄瓜测试都会发生这种情况。

这是我的factories.rb文件,它与上面的输出有关。注意:我的工厂发生了一些轻微的幻想.rb。

[更新:2009-11-20]只是想保持这种新鲜感,看看其他人是否有任何想法。

2 个答案:

答案 0 :(得分:2)

您能否详细了解一下您在哪里看到伐木线?你在运行rake spec吗?你能复制/粘贴一些示例输出吗?

答案 1 :(得分:0)

我不知道怎么或为什么,但这个问题已经解决了它的问题。我只能推测它是对Factory Girl或rspec的更新。也许我在代码中删除了一些日志记录。我不能确定。