Skip to content
Snippets Groups Projects
test_plugin_helper.rb 498 B
Newer Older
  • Learn to ignore specific revisions
  • Alexander Olofsson's avatar
    Alexander Olofsson committed
    # frozen_string_literal: true
    
    # This calls the main test_helper in Foreman-core
    require 'test_helper'
    require 'database_cleaner'
    
    # Add plugin to FactoryBot's paths
    FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
    FactoryBot.reload
    
    # Foreman's setup doesn't handle cleaning up for Minitest::Spec
    DatabaseCleaner.strategy = :transaction
    
    class Minitest::Spec
      before :each do
        DatabaseCleaner.start
      end
    
      after :each do
        DatabaseCleaner.clean
      end
    end