Ruby 沉默工厂女孩日志

Ruby 沉默工厂女孩日志,ruby,tdd,rspec,cucumber,factory-bot,Ruby,Tdd,Rspec,Cucumber,Factory Bot,只是想澄清一下,我不是一个残忍的工厂老板,试图让工作女性沉默。我遇到了一个非常恼人的问题,在我的规范中使用Thoughtbot的factory girl时,每次使用factory.create(:foo)时,新创建的ActiveRecord模型实例都会记录到控制台。这使得查看控制台输出更难直观地过滤掉所有额外的日志记录。是否有一个设置或一个可以设置的标志可以使这个额外的日志静音 下面是我的rspec输出的一个小例子。在本例中,每行开头的“.”是一个成功的测试 loading autotest/r

只是想澄清一下,我不是一个残忍的工厂老板,试图让工作女性沉默。我遇到了一个非常恼人的问题,在我的规范中使用Thoughtbot的factory girl时,每次使用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>
加载自动测试/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
#
#
#
#
#
.#
#
.#
.#
.#
我已经检查了很多次我的规格,看看我是否有一个“puts foo.inspect”在任何地方,我没有。这在我的所有rspec和cucumber测试中都会发生,分别使用自动测试和正常运行的测试

这是我与上述输出相关的文件。注意:在我的工厂里发生了一些小的幻想


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

您能提供更多详细信息,说明您在哪里看到日志记录行吗?您是否正在运行rake spec?你能复制/粘贴一些示例输出吗?

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

你这个残忍的资本主义工厂老板!更新:出于某种原因,这不再是一个问题。看看你是否等得够久,什么也不做,事情会自行解决的。我希望我知道是什么改变了这个问题。