diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5aa1012650d..391f3efbcb5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,17 @@ # frozen_string_literal: true +## +# NOTE: Appraisal sets `BUNDLE_GEMFILE' env variable. +# This is how appraisals can be differentiated from each other. +# https://github.com/thoughtbot/appraisal/blob/v2.4.1/lib/appraisal/command.rb#L36 +# +# If `BUNDLE_GEMFILE' is an empty string, then `APPRAISAL_NAME' is resolved to an empty string as well. +# User passed `APPRAISAL_NAME' has a precedence. +# +# IMPORTANT: `APPRAISAL_NAME' env variable should be initialized as far as it is possible. +# +ENV["APPRAISAL_NAME"] ||= ENV["BUNDLE_GEMFILE"].to_s.then(&File.method(:basename)).then { |name| name.end_with?(".gemfile") ? name.delete_suffix(".gemfile") : "" } + require_relative "coverage_helper" require "bundler/setup"