Sha256: 91dc384a39781f2a7ca707a441638cd6a40b7af5775d2021b2cce406e23af6e6

Contents?: true

Size: 1.49 KB

Versions: 26

Compression:

Stored size: 1.49 KB

Contents

unless defined?(Spree::InstallGenerator)
  require 'generators/spree/install/install_generator'
end

require 'generators/spree/dummy/dummy_generator'
require 'generators/spree/dummy_model/dummy_model_generator'

desc 'Generates a dummy app for testing'
namespace :common do
  task :test_app, :user_class do |_t, args|
    args.with_defaults(user_class: 'Spree::LegacyUser')
    require ENV['LIB_NAME'].to_s

    ENV['RAILS_ENV'] = 'test'
    Rails.env = 'test'

    Spree::DummyGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", '--quiet']
    Spree::InstallGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", '--auto-accept', '--migrate=false', '--seed=false', '--sample=false', '--quiet', '--copy_storefront=false', "--user_class=#{args[:user_class]}"]

    puts 'Setting up dummy database...'
    system("bundle exec rake db:drop db:create > #{File::NULL}")
    Spree::DummyModelGenerator.start
    system("bundle exec rake db:migrate > #{File::NULL}")

    begin
      require "generators/#{ENV['LIB_NAME']}/install/install_generator"
      puts 'Running extension installation generator...'
      "#{ENV['LIB_NAME'].camelize}::Generators::InstallGenerator".constantize.start(['--auto-run-migrations'])
    rescue LoadError
      puts 'Skipping installation no generator to run...'
    end

    puts 'Precompiling assets...'
    system("bundle exec rake assets:precompile > #{File::NULL}")
  end

  task :seed do |_t|
    puts 'Seeding ...'
    system("bundle exec rake db:seed RAILS_ENV=test > #{File::NULL}")
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
spree_core-4.1.15 lib/spree/testing_support/common_rake.rb
spree_core-4.1.14 lib/spree/testing_support/common_rake.rb
spree_core-4.1.13.1 lib/spree/testing_support/common_rake.rb
spree_core-4.2.0.rc5 lib/spree/testing_support/common_rake.rb
spree_core-4.2.0.rc4 lib/spree/testing_support/common_rake.rb
spree_core-4.2.0.rc3 lib/spree/testing_support/common_rake.rb
spree_core-4.1.13 lib/spree/testing_support/common_rake.rb
spree_core-4.2.0.rc2 lib/spree/testing_support/common_rake.rb
spree_core-4.1.12 lib/spree/testing_support/common_rake.rb
spree_core-4.2.0.rc1 lib/spree/testing_support/common_rake.rb
spree_core-4.1.11 lib/spree/testing_support/common_rake.rb
spree_core-4.1.10 lib/spree/testing_support/common_rake.rb
spree_core-4.2.0.beta lib/spree/testing_support/common_rake.rb
spree_core-4.1.9 lib/spree/testing_support/common_rake.rb
spree_core-4.1.8 lib/spree/testing_support/common_rake.rb
spree_core-4.1.7 lib/spree/testing_support/common_rake.rb
spree_core-4.1.6 lib/spree/testing_support/common_rake.rb
spree_core-4.1.5 lib/spree/testing_support/common_rake.rb
spree_core-4.1.4 lib/spree/testing_support/common_rake.rb
spree_core-4.1.3 lib/spree/testing_support/common_rake.rb