Sha256: fd36a0b4576d1ecacc180ce9cbc2c66452001fa4fc1482bd5c0039a060bd38dd

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'fileutils'
require 'tmpdir'

TESTAPP_PATH = ENV['TESTAPP_PATH'] || File.join(Dir.tmpdir, 'declare_schema_testapp') unless defined?(TESTAPP_PATH)
FileUtils.chdir(TESTAPP_PATH)

system "rm -rf app/models/ad* app/models/alpha*"
system "rm -rf test/models/ad* test/models/alpha*"
system "rm -rf test/fixtures/ad* test/fixtures/alpha*"
system "rm -rf db/migrate/*"
system "mkdir -p #{TESTAPP_PATH}/app/assets/config"
system "echo '' >> #{TESTAPP_PATH}/app/assets/config/manifest.js"

require "#{TESTAPP_PATH}/config/environment"

require 'rails/generators'
Rails::Generators.configure!(Rails.application.config.generators)

(ActiveRecord::Base.connection.tables - Generators::DeclareSchema::Migration::Migrator.always_ignore_tables).each do |table|
  ActiveRecord::Base.connection.execute("DROP TABLE #{ActiveRecord::Base.connection.quote_table_name(table)}")
end

ActiveRecord::Base.send(:descendants).each do |model|
  unless model.name['Active'] || model.name['Application']
    nuke_model_class(model)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
declare_schema-0.3.0.pre.2 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-0.2.0 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-0.2.0.pre.1 spec/lib/declare_schema/prepare_testapp.rb