Reputation: 287760
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?
Upvotes: 2
Views: 124
Reputation: 659
The test logs might already have the stacktrace, but if not you can call
logger.debug $!.backtrace.join("\n")
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.
Upvotes: 2