Class: SpecForge::Error::UndefinedMatcherError
- Inherits:
-
Error
- Object
- Error
- SpecForge::Error::UndefinedMatcherError
- Defined in:
- lib/spec_forge/error.rb
Overview
Raised when the provided matcher name does not defined with RSpec
Instance Method Summary collapse
-
#initialize(matcher_name) ⇒ UndefinedMatcherError
constructor
A new instance of UndefinedMatcherError.
Constructor Details
#initialize(matcher_name) ⇒ UndefinedMatcherError
Returns a new instance of UndefinedMatcherError.
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/spec_forge/error.rb', line 296 def initialize(matcher_name) matcher_categories = { Equality: ["matcher.eq", "matcher.eql", "matcher.equal"], Types: ["kind_of.string", "kind_of.integer", "kind_of.array", "kind_of.hash"], Truthiness: ["be.true", "be.false", "be.nil"], Comparison: ["be.within", "be.between", "be.greater_than", "be.less_than"], Collections: ["matcher.include", "matcher.contain_exactly", "matcher.all"], Strings: ["/regex/", "matcher.start_with", "matcher.end_with"] } formatted_categories = matcher_categories.join_map("\n") do |category, matchers| " #{category}: #{matchers.join(", ")}" end super(<<~STRING.chomp Undefined matcher method "#{matcher_name}" is not available in RSpec matchers. Common matchers you can use: #{formatted_categories} For the complete list of available matchers, check the RSpec documentation: https://rspec.info/documentation/3.12/rspec-expectations/RSpec/Matchers.html STRING ) end |