lib/remarkable/base.rb in remarkable-3.1.7 vs lib/remarkable/base.rb in remarkable-3.1.8

- old
+ new

@@ -8,10 +8,18 @@ # Optional to provide spec binding to matchers. def spec(binding) @spec = binding self end + + def positive? + !negative? + end + + def negative? + false + end protected # Returns the subject class unless it's a class object. def subject_class @@ -26,14 +34,23 @@ subject_class.respond_to?(:human_name) ? subject_class.human_name : subject_class.name end # Iterates over the collection given yielding the block and return false # if any of them also returns false. - def assert_matcher_for(collection) #:nodoc: - collection.each do |item| - return false unless yield(item) + def assert_collection(key, collection, inspect=true) #:nodoc: + collection.each do |item| + value = yield(item) + + if positive? == !value + if key + output = inspect ? item.inspect : item + return negative?, key => output + else + return negative? + end + end end - true + positive? end # Asserts that the given collection contains item x. If x is a regular # expression, ensure that at least one element from the collection matches x. #