Class: SleepingKingStudios::Tools::Assertions::MessagesStrategy
- Inherits:
-
Messages::Strategies::HashStrategy
- Object
- Messages::Strategy
- Messages::Strategies::HashStrategy
- SleepingKingStudios::Tools::Assertions::MessagesStrategy
- Defined in:
- lib/sleeping_king_studios/tools/assertions/messages_strategy.rb
Overview
Messages strategy for displaying assertions errors.
Defines its own internal message templates, and automatically handles value name option (:as option) when generating messages.
Constant Summary collapse
- ERROR_MESSAGES =
rubocop:disable Layout/HashAlignment
{ 'blank' => 'must be nil or empty', 'block' => 'block returned a falsy value', 'boolean' => 'must be true or false', 'class' => 'is not a Class', 'class_or_module' => 'is not a Class or Module', 'exclusion' => 'is one of %<expected>s', 'exclusion_range' => 'is within %<range_expr>s', 'inclusion' => 'is not one of %<expected>s', 'inclusion_range' => 'is outside %<range_expr>s', 'inherit_from' => 'does not inherit from %<expected>s', 'instance_of' => 'is not an instance of %<expected>s', 'instance_of_anonymous' => 'is not an instance of %<expected>s (%<parent>s)', 'matches' => 'does not match the expected value', 'matches_proc' => 'does not match the Proc', 'matches_regexp' => 'does not match the pattern %<pattern>s', 'name' => 'is not a String or a Symbol', 'nil' => 'must be nil', 'not_nil' => 'must not be nil', # @note: This value will be changed in a future version. 'presence' => "can't be blank" }.freeze
Instance Attribute Summary
Attributes inherited from Messages::Strategies::HashStrategy
Instance Method Summary collapse
-
#initialize ⇒ MessagesStrategy
constructor
rubocop:enable Layout/HashAlignment.
Methods inherited from Messages::Strategy
Constructor Details
#initialize ⇒ MessagesStrategy
rubocop:enable Layout/HashAlignment
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sleeping_king_studios/tools/assertions/messages_strategy.rb', line 56 def initialize templates = ERROR_MESSAGES .transform_keys do |key| "sleeping_king_studios.tools.assertions.#{key}" end .freeze super(templates) end |