Sha256: cf4ce85be96d4c6bc7f2abcef1f4c218c3244bf04379f99875ce3413834a03ff

Contents?: true

Size: 1.28 KB

Versions: 10

Compression:

Stored size: 1.28 KB

Contents

require 'rails'

# `Rails::Engine` that exposes MetasploitDataModel's `ActiveRecord::Base` subclasses and automatically loads its
# `FactoryBot` factories, sequences, and traits.
class MetasploitDataModels::Engine < Rails::Engine
  # @see http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
  config.generators do |g|
    g.assets false
    g.fixture_replacement :factory_bot, :dir => 'spec/factories'
    g.helper false
    g.test_framework :rspec, :fixture => false
  end

  # Remove ActiveSupport::Dependencies loading paths to save time during constant resolution and to ensure that
  # metasploit_data_models is properly declaring all autoloads and not falling back on ActiveSupport::Dependencies
  config.paths.values.each do |path|
    path.skip_autoload!
    path.skip_autoload_once!
    path.skip_eager_load!
    path.skip_load_path!
  end

  initializer 'metasploit_data_models.prepend_factory_path', :after => 'factory_bot.set_factory_paths' do
    if defined? FactoryBot
      relative_definition_file_path = config.generators.options[:factory_bot][:dir]
      definition_file_path = root.join(relative_definition_file_path)

      # unshift so that Pro can modify mdm factories
      FactoryBot.definition_file_paths.unshift definition_file_path
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
metasploit_data_models-3.0.10 lib/metasploit_data_models/engine.rb
metasploit_data_models-3.0.9 lib/metasploit_data_models/engine.rb
metasploit_data_models-3.0.8 lib/metasploit_data_models/engine.rb
metasploit_data_models-3.0.7 lib/metasploit_data_models/engine.rb
metasploit_data_models-3.0.6 lib/metasploit_data_models/engine.rb
metasploit_data_models-3.0.5 lib/metasploit_data_models/engine.rb
metasploit_data_models-3.0.4 lib/metasploit_data_models/engine.rb
metasploit_data_models-3.0.2 lib/metasploit_data_models/engine.rb
metasploit_data_models-3.0.1 lib/metasploit_data_models/engine.rb
metasploit_data_models-3.0.0 lib/metasploit_data_models/engine.rb