I have been using FactoryBot with Sequel and I'm delighted with it. Here is the setup in my spec_helper (with additional infos, if it helps along the way):
RSpec.configure do |config| config.before(:suite) do DatabaseCleaner[:sequel].clean_with(:truncation) # gem is database_cleaner-sequel # Load any fixture in the database in case you need it end # Setup & Tear down config.around(:each) do |example| Qontrol.db.transaction(rollback: :always, auto_savepoint: true) do example.run end # If using sidekiq # Remove all workers jobs after running an example Sidekiq::Worker.clear_all # needs "require 'sidekiq/testing'" end # Factory-bot config.include FactoryBot::Syntax::Methods config.before(:suite) do FactoryBot.find_definitions FactoryBot.define do to_create(&:save) end end end Then, my factories are simply: FactoryBot.define do factory :diag_control, class: 'Sqan::Diag::Control' do # this is the model class title { Faker::Lorem.words(number: 3).join(' ') } description { Faker::Lorem.paragraph } # fields & sub-factories, and so on end end Hope it helps, Best, Michael Le mer. 6 janv. 2021 à 07:50, Mateusz Urbanski < mateusz.urban...@htdevelopers.com> a écrit : > I'm loading it in my spec_helper before everything: > > # frozen_string_literal: true > > # Set RACK_ENV to test. > ENV['RACK_ENV'] = 'test' > > require 'rack/test' > require 'fabrication' > > require_relative '../app' > > # Require all files in spec/support folder. > root_path = Pathname.new(File.expand_path('..', __dir__)) > Dir[root_path.join('spec/support/**/*.rb')].sort.each { |f| require f } > > RSpec.configure do |config| > config.include Rack::Test::Methods, type: :request > config.include ApiHelpers, type: :request > > config.include(Module.new do > def app > App.freeze.app > end > end) > > # Configuration for database cleaning strategy using Sequel. > config.around do |example| > DB.transaction(rollback: :always, auto_savepoint: true) { example.run } > end > end > > > > środa, 6 stycznia 2021 o 00:47:16 UTC+1 Jeremy Evans napisał(a): > >> On Tue, Jan 5, 2021 at 1:41 PM Mateusz Urbanski < >> mateusz....@htdevelopers.com> wrote: >> >>> When I use Fabrication I receive the following error: >>> >>> FrozenError: >>> >>> can't modify frozen Array: [Sequel::Model, >>> Sequel::Model::Associations, Sequel::Plugins::AutoValidations, >>> Sequel::Plugins::ValidationHelpers, Sequel::Plugins::PreparedStatements, >>> Sequel::Plugins::Subclasses, Sequel::Plugins::Timestamps] >>> >>> >>> This is because I use: >>> >>> Sequel::Model.freeze_descendents >>> >> >> While I don't have experience with Fabrication, I assume you want to load >> Fabrication before freezing. >> >> Thanks, >> Jeremy >> > -- > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sequel-talk+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sequel-talk/2fb96f65-9cb8-413e-a7bd-da9b145089f1n%40googlegroups.com > <https://groups.google.com/d/msgid/sequel-talk/2fb96f65-9cb8-413e-a7bd-da9b145089f1n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to sequel-talk+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/CAAkfp_RWmgV3gcKtjB9v9nX%2BnK%2B5HV4aHYGa942d70sRjtrFyg%40mail.gmail.com.