You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Including FactoryBot::Syntax::Methods gives you access to build, build_list, create, create_list, and attributes_for directly in your tests, such as:
it"renders itself"douser=create(:user,articles: build_list(:article,2))# not FactoryBot.create or FactoryBot.build_listwriter=build(:writer)# not FactoryBot.builduser.render(writer)expect(writer.to_s).toeq("User with two articles")end
find_definitions
The factory_bot_rails library will automatically find and load factory definitions during test runs by hooking into Rails loaders. Outside of Rails, you need to do that manually.