# frozen_string_literal: true RSpec::Support.require_rspec_support "ruby_features" module RSpec # Consistent implementation for "cleaning" the caller method to strip out # non-rspec lines. This enables errors to be reported at the call site in # the code using the library, which is far more useful than the particular # internal method that raised an error. class CallerFilter RSPEC_LIBS = %w[ core mocks expectations support matchers rails ] ADDITIONAL_TOP_LEVEL_FILES = %w[ autorun ] LIB_REGEX = %r{/lib/rspec/(#{(RSPEC_LIBS + ADDITIONAL_TOP_LEVEL_FILES).join('|')})(\.rb|/)} # rubygems/core_ext/kernel_require.rb isn't actually part of rspec (obviously) but we want # it ignored when we are looking for the first meaningful line of the backtrace outside # of RSpec. It can show up in the backtrace as the immediate first caller # when `CallerFilter.first_non_rspec_line` is called from the top level of a required # file, but it depends on if rubygems is loaded or not. We don't want to have to deal # with this complexity in our `RSpec.deprecate` calls, so we ignore it here. IGNORE_REGEX = Regexp.union(LIB_REGEX, "rubygems/core_ext/kernel_require.rb", "