How to use Pry inside Factory Girl Rails?

To debug the factory, I inserted rescue binding.pryat the end of the problem line:

after_create do |my_object, proxy|
  my_object.foreign_key_id = proxy.generated_attribute rescue binding.pry

Unfortunately, inside the resulting context, FactoryGirl::Declaration::ImplicitI cannot access the context, as in normal code ( NameError: undefined local variable or method `proxy' for #<FactoryGirl::Declaration::Implicit:0x0...>). How to check and process my_objectand proxyin Pry session?

The code is called as part of the background function of the cucumber:

Given the following my_objects exist:
| property |
| value    |

factory_girl_railsand factory_girl/step_definitions.rbare required by script support.

+5
source share
1 answer

, factory_girl instance_eval Object, binding. , binding.pry , pry ; "binding" pry .

, Kernel.binding.pry .

+12

All Articles