Class: RSpec::Core::DidYouMean
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/did_you_mean.rb
Overview
Wrapper around Ruby’s ‘DidYouMean::SpellChecker` when available to provide file name suggestions.
Instance Attribute Summary collapse
-
#relative_file_name ⇒ Object
readonly
Returns the value of attribute relative_file_name.
Instance Method Summary collapse
-
#call ⇒ Object
return a hint if API for ::DidYouMean::SpellChecker not supported.
-
#initialize(relative_file_name) ⇒ DidYouMean
constructor
A new instance of DidYouMean.
Constructor Details
#initialize(relative_file_name) ⇒ DidYouMean
Returns a new instance of DidYouMean.
8 9 10 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/did_you_mean.rb', line 8 def initialize(relative_file_name) @relative_file_name = relative_file_name end |
Instance Attribute Details
#relative_file_name ⇒ Object (readonly)
Returns the value of attribute relative_file_name.
6 7 8 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/did_you_mean.rb', line 6 def relative_file_name @relative_file_name end |
Instance Method Details
#call ⇒ Object
return a hint if API for ::DidYouMean::SpellChecker not supported
14 15 16 17 18 19 20 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/did_you_mean.rb', line 14 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 |