Module: Minicrest
- Defined in:
- lib/minicrest.rb,
lib/minicrest/is.rb,
lib/minicrest/blank.rb,
lib/minicrest/empty.rb,
lib/minicrest/is_in.rb,
lib/minicrest/equals.rb,
lib/minicrest/between.rb,
lib/minicrest/has_key.rb,
lib/minicrest/matcher.rb,
lib/minicrest/version.rb,
lib/minicrest/anything.rb,
lib/minicrest/asserter.rb,
lib/minicrest/contains.rb,
lib/minicrest/has_size.rb,
lib/minicrest/includes.rb,
lib/minicrest/no_items.rb,
lib/minicrest/all_items.rb,
lib/minicrest/ends_with.rb,
lib/minicrest/has_value.rb,
lib/minicrest/assertions.rb,
lib/minicrest/some_items.rb,
lib/minicrest/combinators.rb,
lib/minicrest/is_close_to.rb,
lib/minicrest/responds_to.rb,
lib/minicrest/starts_with.rb,
lib/minicrest/is_less_than.rb,
lib/minicrest/has_attribute.rb,
lib/minicrest/string_matcher.rb,
lib/minicrest/value_matchers.rb,
lib/minicrest/is_greater_than.rb,
lib/minicrest/matches_pattern.rb,
lib/minicrest/contains_exactly.rb,
lib/minicrest/comparison_matcher.rb,
lib/minicrest/hash_entry_matchers.rb,
lib/minicrest/collection_item_matcher.rb,
lib/minicrest/is_less_than_or_equal_to.rb,
lib/minicrest/is_greater_than_or_equal_to.rb
Overview
Minicrest provides Hamcrest-style composable matchers for Minitest.
This library enables expressive, readable assertions with detailed failure messages using a fluent API. Matchers can be combined using logical operators to create complex matching conditions.
Defined Under Namespace
Modules: Assertions Classes: All, AllEntries, AllItems, And, Anything, Asserter, Between, Blank, CollectionItemMatcher, ComparisonMatcher, Contains, ContainsExactly, DescendsFrom, Empty, EndsWith, Equals, Error, Falsy, HasAttribute, HasKey, HasSize, HasValue, HashEntryMatcher, Includes, InstanceOf, Is, IsCloseTo, IsGreaterThan, IsGreaterThanOrEqualTo, IsIn, IsLessThan, IsLessThanOrEqualTo, Matcher, MatchesPattern, NilValue, NoEntry, NoItems, None, Not, Or, RespondsTo, Some, SomeEntry, SomeItems, StartsWith, StringMatcher, Truthy
Constant Summary collapse
- VERSION =
'1.0.21'
Class Method Summary collapse
-
.equals(expected) ⇒ Equals
Factory method to create an Equals matcher.
-
.is(expected) ⇒ Is
Factory method to create an Is matcher.
-
.register_matcher(name) {|*args| ... } ⇒ Object
Registers a custom matcher factory method on the Assertions module.
-
.registered_matchers ⇒ Array<Symbol>
Returns the list of registered custom matcher names.
Class Method Details
.equals(expected) ⇒ Equals
Factory method to create an Equals matcher.
193 194 195 |
# File 'lib/minicrest/equals.rb', line 193 def equals(expected) Equals.new(expected) end |
.is(expected) ⇒ Is
Factory method to create an Is matcher.
89 90 91 |
# File 'lib/minicrest/is.rb', line 89 def is(expected) Is.new(expected) end |
.register_matcher(name) {|*args| ... } ⇒ Object
Registers a custom matcher factory method on the Assertions module.
60 61 62 63 64 65 66 67 |
# File 'lib/minicrest.rb', line 60 def register_matcher(name, &) raise ArgumentError, 'block required' unless block_given? raise Error, "matcher :#{name} is already registered" if registered_matchers.include?(name.to_sym) registered_matchers << name.to_sym Assertions.define_method(name, &) end |
.registered_matchers ⇒ Array<Symbol>
Returns the list of registered custom matcher names.
72 73 74 |
# File 'lib/minicrest.rb', line 72 def registered_matchers @registered_matchers ||= [] end |