-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
executable file
·58 lines (48 loc) · 1.48 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
require 'spree/testing_support/extension_rake'
RSpec::Core::RakeTask.new
task :default do
if Dir['spec/dummy'].empty?
Rake::Task[:test_app].invoke
Dir.chdir('../../')
end
Rake::Task[:spec].invoke
end
desc 'Generates a dummy app for testing'
task :test_app do
ENV['LIB_NAME'] = 'spree_single_page_checkout'
require "#{ENV['LIB_NAME']}"
Spree::DummyGenerator.start([
"--lib_name=#{ENV['LIB_NAME']}",
], database: 'postgresql')
Spree::InstallGenerator.start([
"--lib_name=#{ENV['LIB_NAME']}",
"--auto-accept",
"--migrate=false",
"--seed=false",
"--sample=false",
"--user_class=Spree::LegacyUser"
])
# Use the postgres database.yml instead of SQLite
require 'fileutils'
pg_database = File.expand_path('../support/database.yml')
dummy_db_config = File.expand_path('config/database.yml')
cp(pg_database, dummy_db_config)
puts "Setting up dummy database..."
cmd = "bundle exec rake db:drop db:create db:migrate db:test:prepare"
if RUBY_PLATFORM =~ /mswin/ #windows
cmd += " >nul"
else
cmd += " >/dev/null"
end
system(cmd)
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