factory_bot
factory_bot copied to clipboard
Cannot create Factory with multiple traits got (ArgumentError Exception: wrong number of arguments (given 1, expected 0)) Ruby 3.0, Rails 6.1.72, factory_bot_rails 6.1.0 #408
I have upgraded my application from rails 5.2 to 6.1. and Ruby from 2.7 to 3.0 but when i rspec my test cases i got this error when i try to create a factory that have Factory and traits.
FactoryBot.define do
factory `:registration,` class: "METS::Registration" do
meeting { create(:meeting) }
transient do
attendee_attributes { {} }
end
email
registration_email { email&.value }
address_postal_code { attendee.business_address&.postal_code }
attendance_type { METS::Registration.attendance_type_values.sample }
attendee_type { registration_attendee_type(:invitee) }
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
rsvp_type { meeting.default_attendance_type }
trait :unfrozen do
meeting { build :meeting, :unfrozen_for_registrations }
end
trait :attended do
attendance_type { registration_attendance_type(:in_person) }
end
end
end
in Rspec/test.rb create(:registration, :unfrozen, :as_employee, attendee: attendee, email: primary_email, email_value: primary_email.value)
Error: Failure/Error: create(:registration, :unfrozen)
ArgumentError: wrong number of arguments (given 1, expected 0)
@aliahmadexe you are still facing same issue?
If not then check the faker gem version. update to latest version.