Skip to content

Integration: Cucumber

Mike Burns edited this page Apr 14, 2023 · 1 revision

In features/support/env.rb:

World(FactoryBot::Syntax::Methods)

FactoryBot::Syntax::Methods

Including FactoryBot::Syntax::Methods gives you access to build, build_list, create, create_list, and attributes_for directly in your tests, such as:

Given("a user with {int} articles") do |num_articles|
  @user = create(:user, articles: build_list(:article, num_articles)) # not FactoryBot.create or FactoryBot.build_list
end