Sha256: d0d1417d1dc851a2be9d1623d555d26617879b580a39a9ed072c0a47e9c8120e

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

begin
  require 'factory_bot_rails'
rescue LoadError # rubocop:disable Lint/HandleExceptions
end

module MicroCms
  class Engine < ::Rails::Engine
    FACTORIES = File.expand_path('../../spec/factories', __dir__).freeze

    isolate_namespace MicroCms

    config.generators do |generators|
      generators.test_framework :rspec
      generators.fixture_replacement :factory_bot
      generators.factory_bot dir: 'spec/factories'
    end

    initializer 'micro_cms.include_view_helpers' do |_app|
      ActiveSupport.on_load :action_view do
        ActionView::Base.public_send :include, MicroCms::CmsBlockHelper
      end
    end

    initializer 'micro_cms.configure_authorization_token' do |_app|
      MicroCms.configure do |config|
        config.authorization_token = SecureRandom.urlsafe_base64
      end
    end

    if defined? FactoryBotRails
      initializer 'mirco_cms.set_factory_paths', after: 'factory_bot.set_factory_paths' do |_app|
        FactoryBot.definition_file_paths << FACTORIES
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
micro_cms-0.1.2 lib/micro_cms/engine.rb
micro_cms-0.1.1 lib/micro_cms/engine.rb