Sha256: 3b43367fec11705670d57bc213396c07b14cd6c40a1feeaec786e2814fd93534
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
module ActiveAdmin class ApplicationGenerator attr_reader :rails_env, :template def initialize(opts = {}) @rails_env = opts[:rails_env] || 'test' @template = opts[:template] || 'rails_template' end def generate if File.exist? app_dir puts "test app #{app_dir} already exists; skipping test app generation" else system "mkdir -p #{base_dir}" args = %W( -m spec/support/#{template}.rb --skip-bootsnap --skip-bundle --skip-gemfile --skip-listen --skip-turbolinks --skip-test-unit ) command = ['bundle', 'exec', 'rails', 'new', app_dir, *args].join(' ') env = { 'BUNDLE_GEMFILE' => ENV['BUNDLE_GEMFILE'], 'RAILS_ENV' => rails_env } Bundler.with_original_env { Kernel.system(env, command) } end app_dir end private def base_dir @base_dir ||= rails_env == 'test' ? 'spec/rails' : '.test-rails-apps' end def app_dir @app_dir ||= begin require 'rails/version' "#{base_dir}/rails-#{Rails::VERSION::STRING}" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activeadmin-1.4.2 | tasks/application_generator.rb |
activeadmin-1.4.1 | tasks/application_generator.rb |
activeadmin-1.4.0 | tasks/application_generator.rb |