class RSpec::Core::DidYouMean

@private Wrapper around Ruby’s ‘DidYouMean::SpellChecker` when available to provide file name suggestions.

Attributes

Public Class Methods

# File rspec-core/lib/rspec/core/did_you_mean.rb, line 8
def initialize(relative_file_name)
  @relative_file_name = relative_file_name
end

Public Instance Methods

provide probable suggestions :nocov: - not installed on CI

# File rspec-core/lib/rspec/core/did_you_mean.rb, line 15
def call
  checker = ::DidYouMean::SpellChecker.new(:dictionary => Dir["spec/**/*.rb"])
  probables = checker.correct(relative_file_name.sub('./', ''))[0..2]
  return '' unless probables.any?

  formats probables
end