How to enable Rails' file_fixture helper in FactoryBot

Posted . Visible to the public. Deprecated.

This is now build-in into factory_bot_rails https://github.com/thoughtbot/factory_bot_rails/pull/427/files

In FactoryBot factories, Rails' file_fixture is not available by default. To enable it, include a support module from rspec-rails:

FactoryBot::SyntaxRunner.include(RSpec::Rails::FileFixtureSupport)

That includes ActiveSupport::Testing::FileFixtures, where file_fixture is defined, but also configures the file_fixture_path so that you can actually use file_fixture.

Profile picture of Arne Hartherz
Arne Hartherz
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2024-12-10 08:28)