discourse/bin/rspec
David Taylor 1f46aed27e
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
2024-12-23 11:56:10 +00:00

24 lines
589 B
Ruby
Executable File

#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
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')