In order to debug a factory I've inserted rescue binding.pry
at the end of a problematic line:
after_create do |my_object, proxy|
my_object.foreign_key_id = proxy.generated_attribute rescue binding.pry
Unfortunately, inside the resulting FactoryGirl::Declaration::Implicit
context I can't seem to access the context like I would in "normal" code (NameError: undefined local variable or method `proxy' for #<FactoryGirl::Declaration::Implicit:0x0...>
). How do I inspect and manipulate my_object
and proxy
within the Pry session?
The code is called as part of the background of a Cucumber feature:
Given the following my_objects exist:
| property |
| value |
factory_girl_rails
and factory_girl/step_definitions.rb
are required by the support script.
binding.pry
form the rescue block, put it above the second line and see what happen. – Lowbinding.pry
above the failing line makes no discernable difference -my_object
still isn't available. – BloodrootFactory.create
insteadFactory.build
or other method? – Lowcreate
- We're using the Cucumber helpers. – Bloodroot