Class: Ramcrest::Enumerable::BaseEnumerableMatcher
- Inherits:
-
Object
- Object
- Ramcrest::Enumerable::BaseEnumerableMatcher
- Includes:
- Matcher
- Defined in:
- lib/ramcrest/base_enumerable_matcher.rb
Direct Known Subclasses
Includes::Matcher, IncludesExactly::Matcher, IncludesInAnyOrderExactly::Matcher
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(match_type_description, expected, size_matcher) ⇒ BaseEnumerableMatcher
constructor
A new instance of BaseEnumerableMatcher.
- #matches?(actual) ⇒ Boolean
Methods included from Matcher
#do_match, #mismatch, #success
Constructor Details
#initialize(match_type_description, expected, size_matcher) ⇒ BaseEnumerableMatcher
Returns a new instance of BaseEnumerableMatcher.
8 9 10 11 12 |
# File 'lib/ramcrest/base_enumerable_matcher.rb', line 8 def initialize(match_type_description, expected, size_matcher) @match_type_description = match_type_description @expected = expected @size_matcher = Ramcrest::HasSize.has_size(size_matcher) end |
Instance Method Details
#description ⇒ Object
28 29 30 |
# File 'lib/ramcrest/base_enumerable_matcher.rb', line 28 def description "an enumerable #{@match_type_description} #{description_of_expecteds}" end |
#matches?(actual) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ramcrest/base_enumerable_matcher.rb', line 14 def matches?(actual) size_match = @size_matcher.matches?(actual) if !size_match.matched? return mismatch("an enumerable of #{size_match.description}. Enumerable was #{show(actual)}.") end unmatched = unmatched_expectations_from(actual) if unmatched.empty? success else mismatch("an enumerable that does not include #{describe(unmatched)}. Enumerable was #{show(actual)}.") end end |