Skip to content

Commit 3f12534

Browse files
committed
Update the Rakefile setup
Backport a few tricks from solidus_dev_support and fix `rake clobber` which was called by bin/setup, but broken. Keep supporting the old task names as deprecated.
1 parent f962ca2 commit 3f12534

1 file changed

Lines changed: 29 additions & 12 deletions

File tree

Rakefile

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,38 @@
33
require 'bundler'
44
Bundler::GemHelper.install_tasks
55

6-
require 'rspec/core/rake_task'
6+
require 'rake/clean'
77
require 'spree/testing_support/common_rake'
8+
ENV['DUMMY_PATH'] = "spec/dummy"
9+
ENV['LIB_NAME'] = "solidus/auth"
10+
::CLOBBER.include ENV['DUMMY_PATH']
811

9-
RSpec::Core::RakeTask.new
12+
namespace :extension do
13+
# We need to go back to the gem root since the upstream
14+
# extension:test_app changes the working directory to be the dummy app.
15+
task :test_app do
16+
Rake::Task['extension:test_app'].invoke
17+
cd __dir__
18+
end
1019

11-
task :default do
12-
if Dir["spec/dummy"].empty?
13-
Rake::Task[:test_app].invoke
14-
Dir.chdir("../../")
20+
directory ENV['DUMMY_PATH'] do
21+
Rake::Task['common:test_app'].invoke("Spree::User")
1522
end
16-
Rake::Task[:spec].invoke
17-
end
1823

19-
desc 'Generates a dummy app for testing'
20-
task :test_app do
21-
ENV['LIB_NAME'] = 'solidus/auth'
22-
Rake::Task['common:test_app'].invoke("Spree::User")
24+
require 'rspec/core/rake_task'
25+
RSpec::Core::RakeTask.new(:specs, [] => FileList[ENV['DUMMY_PATH']]) do |t|
26+
# Ref: https://circleci.com/docs/2.0/configuration-reference#store_test_results
27+
# Ref: https://github.com/solidusio/circleci-orbs-extensions#test-results-rspec
28+
if ENV['TEST_RESULTS_PATH']
29+
t.rspec_opts =
30+
"--format progress " \
31+
"--format RspecJunitFormatter --out #{ENV['TEST_RESULTS_PATH']}"
32+
end
33+
end
2334
end
35+
36+
task default: 'extension:specs'
37+
38+
# DEPRECATED:
39+
task test_app: 'extension:test_app'
40+
task spec: 'extension:specs'

0 commit comments

Comments
 (0)