Sha256: cad38ac257b448e8fac942aba568578fae002226ca2b761ede0afd460e8dbd00

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

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

require 'generators/spree/dummy/dummy_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'

    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", "--user_class=#{args[:user_class]}"]

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

    puts "Precompiling assets..."
    system("bundle exec rake assets:precompile > #{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
  end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_core-3.0.10 lib/spree/testing_support/common_rake.rb
spree_core-3.0.9 lib/spree/testing_support/common_rake.rb
spree_core-3.0.8 lib/spree/testing_support/common_rake.rb