1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
require 'test/unit'
module DidYouMean
module TestHelper
class << self
attr_reader :root
def ractor_compatible?
defined?(Ractor) && RUBY_VERSION >= "3.1.0"
end
end
if File.file?(File.expand_path('../lib/did_you_mean.rb', __dir__))
# In this case we're being run from inside the gem, so we just want to
# require the root of the library
@root = File.expand_path('../lib/did_you_mean', __dir__)
require_relative @root
else
# In this case we're being run from inside ruby core, and we want to
# include the experimental features in the test suite
@root = File.expand_path('../../lib/did_you_mean', __dir__)
require_relative @root
# We are excluding experimental features for now.
# require_relative File.join(@root, 'experimental')
end unless ENV['AUTOPKGTEST_TMP']
if ENV['AUTOPKGTEST_TMP']
require 'did_you_mean'
end
def assert_correction(expected, array)
assert_equal Array(expected), array, "Expected #{array.inspect} to only include #{expected.inspect}"
end
def get_message(err)
if err.respond_to?(:detailed_message)
err.detailed_message(highlight: false)
else
err.to_s
end
end
module_function :get_message
end
end
|