From 1f46aed27eb06b03d7b398df616b60a2852c60c1 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 23 Dec 2024 11:56:10 +0000 Subject: [PATCH] DEV: Automatically set LOAD_PLUGINS for bin/rspec (#30437) When passing a `plugins/...` path to bin/rspec, it's reasonable to assume that the developer wants the tests to be run with plugins loaded. This commit automatically takes care of that. If `LOAD_PLUGINS` is explicitly specified, then that value will always be used. This mimics the logic we already have for database migrations in the `bin/rake` stub --- bin/rspec | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/rspec b/bin/rspec index c36691f7ddd..55b87de6fe6 100755 --- a/bin/rspec +++ b/bin/rspec @@ -15,4 +15,9 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", require 'rubygems' require 'bundler/setup' +if ENV["LOAD_PLUGINS"].nil? && ARGV.any? { |pattern| pattern.include?("plugins/") } + STDERR.puts "Detected plugin spec path, setting LOAD_PLUGINS to 1" + ENV["LOAD_PLUGINS"] = "1" +end + load Gem.bin_path('rspec-core', 'rspec')