djezzzl / factory_trace

Simple tool to maintain factories and traits from FactoryBot
MIT License
381 stars 7 forks source link

all let calls to factory_bot return argument error with trace enabled #33

Closed JeremiahChurch closed 1 year ago

JeremiahChurch commented 1 year ago

Hi! Trying to give the gem a shot and I'm running in to what I suspect is a monkey patching issue or similar?

rspec 3.11 factory_bot_rails 6.2 factory_bot 6.2 rails 7.0.x

rspec runs with no issues FB_TRACE=1 rspec fails every spec that calls a factory with an argument error

Failure/Error: let!(:user) { create(:user) }

ArgumentError:
  wrong number of arguments (given 1, expected 2)

same result when attempting with the log file command too.

seemingly all (or most) factories are impacted. nothing odd in most of the factories.

example:

FactoryBot.define do
  factory :user do
    sequence(:first_name) { |n| "first_name#{n}" }
    sequence(:last_name) { |n| "last_name#{n}" }
    sequence(:email) { |n| "email_#{n}@example.com" }
    password { 'password_123123' }

    trait :after_signup do
    end
  end
end
djezzzl commented 1 year ago

Hi @JeremiahChurch,

Thank you for using the gem and raising the issue!

It looks like you're correct; I will investigate and fix it as soon as possible.

djezzzl commented 1 year ago

Hi @JeremiahChurch,

I'm so sorry it took me so long to look into this. Moreover, I couldn't reproduce the issue. I have added the rails 7 example to the project: https://github.com/djezzzl/factory_trace/tree/master/rails7, but it works as expected for the minimal case you described.

Please let me know if you could provide steps to reproduce the issue; I would happily fix it ASAP.

Until then, have a great time, and feel free to reopen the issue if needed.