Sha256: 33208abc93b87e4a66e1a683955753cce7f21cfccf07bd0dda232d88a00de286

Contents?: true

Size: 1.33 KB

Versions: 16

Compression:

Stored size: 1.33 KB

Contents

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

require 'generators/spree/dummy/dummy_generator'
require 'rails'

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

    puts "Setting up dummy database..."
    system("bundle exec rake db:drop db:create 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

16 entries across 16 versions & 1 rubygems

Version Path
spree_core-3.2.9 lib/spree/testing_support/common_rake.rb
spree_core-3.1.14 lib/spree/testing_support/common_rake.rb
spree_core-3.3.6 lib/spree/testing_support/common_rake.rb
spree_core-3.2.8 lib/spree/testing_support/common_rake.rb
spree_core-3.1.13 lib/spree/testing_support/common_rake.rb
spree_core-3.3.5 lib/spree/testing_support/common_rake.rb
spree_core-3.3.4 lib/spree/testing_support/common_rake.rb
spree_core-3.2.7 lib/spree/testing_support/common_rake.rb
spree_core-3.1.12 lib/spree/testing_support/common_rake.rb
spree_core-3.3.3 lib/spree/testing_support/common_rake.rb
spree_core-3.2.6 lib/spree/testing_support/common_rake.rb
spree_core-3.1.11 lib/spree/testing_support/common_rake.rb
spree_core-3.1.10 lib/spree/testing_support/common_rake.rb
spree_core-3.3.2 lib/spree/testing_support/common_rake.rb
spree_core-3.2.5 lib/spree/testing_support/common_rake.rb
spree_core-3.1.9 lib/spree/testing_support/common_rake.rb