class RSpec::Core::DidYouMean

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

def call

provide probable suggestions
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

def call

return a hint if API for ::DidYouMean::SpellChecker not supported
def call
  "\nHint: Install the `did_you_mean` gem in order to provide suggestions for similarly named files."
end

def formats(probables)

def formats(probables)
  rspec_format = probables.map { |s, _| "rspec ./#{s}" }
  red_font(top_and_tail rspec_format)
end

def initialize(relative_file_name)

def initialize(relative_file_name)
  @relative_file_name = relative_file_name
end

def red_font(mytext)

def red_font(mytext)
  colorizer = ::RSpec::Core::Formatters::ConsoleCodes
  colorizer.wrap mytext, :failure
end

def top_and_tail(rspec_format)

def top_and_tail(rspec_format)
  spaces = ' ' * 20
  rspec_format.insert(0, ' - Did you mean?').join("\n#{spaces}") + "\n"
end