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'

# Carrega os arquivos de suporte (factories etc.)
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }

# NÃO usamos maintain_test_schema! porque o projeto não versiona schema.rb
# (as migrations são a fonte de verdade). Rode antes da suíte:
#   RAILS_ENV=test bundle exec rails db:create db:migrate
RSpec.configure do |config|
  config.fixture_paths = [Rails.root.join('spec', 'fixtures')] if config.respond_to?(:fixture_paths)
  config.use_transactional_fixtures = true
  config.infer_spec_type_from_file_location!
  config.filter_rails_from_backtrace!

  config.include FactoryBot::Syntax::Methods
end
