require "rails/generators/rails/app/app_generator" module Jobshop class Dummy class << self def generate new end end def initialize options = { api: false, database: "postgresql", skip_gemfile: true, skip_git: true, skip_bundle: true, skip_listen: true, skip_test: true, template: template_path } if Dir.exists?(dummy_path) FileUtils.rmtree(dummy_path) dummy_constant = File.basename(dummy_path).gsub(/\W/, '_').squeeze('_').camelize Object.send(:remove_const, dummy_constant) end Rails::Generators::AppGenerator.new([ dummy_path ], options).invoke_all end private def dummy_path @dummy_path ||= File.expand_path("spec/dummy-#{Rails::VERSION::STRING}") end def template_path @template_path ||= File.expand_path("../templates/dummy_template.rb", __FILE__) end end end