Complete the code to load fixtures in a Rails test.
fixtures :[1]In Rails tests, you load fixtures by specifying the fixture name, such as users for user data.
Complete the factory definition to create a user with FactoryBot.
factory :user do [1] { "test@example.com" } end
name or username instead of email.The email attribute is commonly set in a user factory to provide a unique email address.
Fix the error in the factory usage to create a user instance.
user = FactoryBot.[1](:user)builds or makes.build (which does not save) with create.The correct method to create and save a factory object is create.
Fill both blanks to define a fixture file path and load it in a test.
fixtures :[1] file_path = Rails.root.join('test', 'fixtures', '[2].yml')
The fixture name and file path must match. Here, users is used for both.
Fill all three blanks to create a factory with a sequence and use it in a test.
factory :user do [1] :email do |[2]| "user[2]@example.com" end end user = FactoryBot.[3](:user)
email instead of sequence.n.build instead of create when saving is needed.Use sequence to generate unique emails with a number n. Then use create to make the user.
