Skip to content

Commit

Permalink
Update the Rakefile setup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
elia committed Jul 4, 2022
1 parent f962ca2 commit 3f12534
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,38 @@
require 'bundler'
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
require 'rake/clean'
require 'spree/testing_support/common_rake'
ENV['DUMMY_PATH'] = "spec/dummy"
ENV['LIB_NAME'] = "solidus/auth"
::CLOBBER.include ENV['DUMMY_PATH']

RSpec::Core::RakeTask.new
namespace :extension do
# We need to go back to the gem root since the upstream
# extension:test_app changes the working directory to be the dummy app.
task :test_app do
Rake::Task['extension:test_app'].invoke
cd __dir__
end

task :default do
if Dir["spec/dummy"].empty?
Rake::Task[:test_app].invoke
Dir.chdir("../../")
directory ENV['DUMMY_PATH'] do
Rake::Task['common:test_app'].invoke("Spree::User")
end
Rake::Task[:spec].invoke
end

desc 'Generates a dummy app for testing'
task :test_app do
ENV['LIB_NAME'] = 'solidus/auth'
Rake::Task['common:test_app'].invoke("Spree::User")
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:specs, [] => FileList[ENV['DUMMY_PATH']]) do |t|
# Ref: https://circleci.com/docs/2.0/configuration-reference#store_test_results
# Ref: https://github.com/solidusio/circleci-orbs-extensions#test-results-rspec
if ENV['TEST_RESULTS_PATH']
t.rspec_opts =
"--format progress " \
"--format RspecJunitFormatter --out #{ENV['TEST_RESULTS_PATH']}"
end
end
end

task default: 'extension:specs'

# DEPRECATED:
task test_app: 'extension:test_app'
task spec: 'extension:specs'

0 comments on commit 3f12534

Please sign in to comment.