堆栈跟踪的其余部分在哪里?
我有一个测试引发错误。为了追查问题,我最终将此方法添加到名为 NodeAffiliation 的模型中:
def initialize a1, a2
raise "kaboom"
end
然后我收到此错误:
RuntimeError: kaboom
app/models/node_affiliation.rb:13:in `initialize'
test/unit/audit_test.rb:10:in `__bind_1318003437_24401'
但audit_test.rb 正在执行此操作:
Factory.create :form
不知何故,创建表单也会创建 NodeAffiliation,但这些步骤似乎在回溯。有什么想法为什么和/或如何获得它们吗?
I have a test that is raising an error. To track down the problem I ended up adding this method to a model called NodeAffiliation:
def initialize a1, a2
raise "kaboom"
end
and then I get this error:
RuntimeError: kaboom
app/models/node_affiliation.rb:13:in `initialize'
test/unit/audit_test.rb:10:in `__bind_1318003437_24401'
but audit_test.rb is doing this:
Factory.create :form
Somehow, creating a Form also creates a NodeAffiliation, but those steps seem to be missing in the backtrace. Any ideas why and/or how to get them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
测试日志可能已经有堆栈跟踪,但如果没有,您可以调用
where $!是引发的异常的默认名称。这需要在救援区。我会检查您的工厂实现,它可能会将 node_affiliation 与表单对象相关联,或者可能存在一系列关系。工厂中声明的任何关联都会在创建对象时创建。
The test logs might already have the stacktrace, but if not you can call
where $! is the default name of the exception that was raised. This needs to be in a rescue block. I would check your factory implementation, it is likely associating node_affiliation with form objects, or perhaps there is a chain of relations. Any associations declared in the factory get created when the object is created.