Sha256: 3459b409b6bd72eaf1d17bb0cb39b988cebe4c228b81f0d2f939d607e8d222ba

Contents?: true

Size: 959 Bytes

Versions: 1

Compression:

Stored size: 959 Bytes

Contents

# frozen_string_literal: true

require 'eac_rails_gem_support/patches/object/template'
require 'eac_ruby_gems_utils/gem'
require 'eac_ruby_utils/core_ext'
require 'fileutils'

module EacRailsGemSupport
  module Rspec
    class AppendableRailsApp
      enable_simple_cache
      common_constructor :gem_dir, :append_dir, :target_dir, default: [nil] do
        self.target_dir = (target_dir || ::Dir.mktmpdir).to_pathname
        build
      end

      protected

      def build
        copy_app_base
        copy_append_directory
        database_migrate
      end

      def database_migrate
        the_gem.bundle('exec', 'rake', 'db:migrate').chdir(target_dir).execute!
      end

      def copy_app_base
        template.apply(self, target_dir)
      end

      def copy_append_directory
        ::FileUtils.cp_r("#{append_dir}/.", target_dir)
      end

      def the_gem_uncached
        ::EacRubyGemsUtils::Gem.new(gem_dir)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eac_rails_gem_support-0.2.0 lib/eac_rails_gem_support/rspec/appendable_rails_app.rb