From ecfe44d4024c2afb5b7f9992051df992693f84a7 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 14 Oct 2023 18:44:21 +0100 Subject: [PATCH] Wrap reloadable constant calls in to_prepare --- lib/rspec-rails.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/rspec-rails.rb b/lib/rspec-rails.rb index 45592fbd8..258112875 100644 --- a/lib/rspec-rails.rb +++ b/lib/rspec-rails.rb @@ -7,14 +7,18 @@ module Rails # Railtie to hook into Rails. class Railtie < ::Rails::Railtie # As of Rails 5.1.0 you can register directories to work with `rake notes` - require 'rails/source_annotation_extractor' - ::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec") + config.to_prepare do + require 'rails/source_annotation_extractor' + ::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec") + end generators = config.app_generators generators.integration_tool :rspec generators.test_framework :rspec generators do - ::Rails::Generators.hidden_namespaces.reject! { |namespace| namespace.to_s.start_with?("rspec") } + config.to_prepare do + ::Rails::Generators.hidden_namespaces.reject! { |namespace| namespace.to_s.start_with?("rspec") } + end end rake_tasks do