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
spec/rails_helper should look like this:
(I've removed comments for clarity)
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
require 'factory_bot_rails'
begin
ActiveRecord::Migration.maintain_test_schema!
rescue ActiveRecord::PendingMigrationError => e
abort e.to_s.strip
end
RSpec.configure do |config|
config.fixture_paths = [
Rails.root.join('spec/fixtures')
]
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtrace!
end
bundle exec rspec spec
Expected behavior
The test suite runs without error (even though there are no tests yet)
Description
Running "bundle exec rspec spec" on a brand new Rails 8 app gives NameError: uninitialized constant FactoryBotRails::Railtie::FactoryBot
Reproduction Steps
Edit Gemfile to look like this:
bundle install
rails g rspec:install
spec/rails_helper should look like this:
(I've removed comments for clarity)
bundle exec rspec spec
Expected behavior
The test suite runs without error (even though there are no tests yet)
Actual behavior
System configuration
factory_bot_rails version: 6.4.4
factory_bot version: 6.5.0
rails version: 8.0.0-rc2
ruby version: 3.3.5
Additional thoughts
This feels like it may be an order-of-loading issue, possibly down to the edge Rails version, but I figured it was worth raising it anyway
The text was updated successfully, but these errors were encountered: