Class: SpecForge::Error::InvalidFakerClassError
- Inherits:
-
Error
- Object
- Error
- SpecForge::Error::InvalidFakerClassError
- Defined in:
- lib/spec_forge/error.rb
Overview
Raised when a provided Faker class name doesn't exist Provides helpful suggestions for similar class names
Constant Summary collapse
- CLASS_CHECKER =
A spell checker for Faker classes
DidYouMean::SpellChecker.new( dictionary: Faker::Base.descendants.map { |c| c.to_s.downcase.gsub!("::", ".") } )
Instance Method Summary collapse
-
#initialize(input) ⇒ InvalidFakerClassError
constructor
A new instance of InvalidFakerClassError.
Constructor Details
#initialize(input) ⇒ InvalidFakerClassError
Returns a new instance of InvalidFakerClassError.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/spec_forge/error.rb', line 26 def initialize(input) corrections = CLASS_CHECKER.correct(input) super(<<~STRING.chomp Undefined Faker class "#{input}". #{DidYouMean::Formatter.(corrections)} For available classes, please check https://github.com/faker-ruby/faker/blob/main/GENERATORS.md. STRING ) end |