From 3f125341b9db61a668a5f55772fc15f53ffda982 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Thu, 30 Jun 2022 14:59:32 +0200 Subject: [PATCH] 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. --- Rakefile | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/Rakefile b/Rakefile index c45b8d39..44335085 100644 --- a/Rakefile +++ b/Rakefile @@ -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'