Sha256: eda90565a437f6aab4d8caf0933cdf502ae4ae94b24afb898013db17bd1b4f07
Contents?: true
Size: 821 Bytes
Versions: 8
Compression:
Stored size: 821 Bytes
Contents
module Bogus class EnsuresAllInteractionsSatisfied def ensure_satisfied!(objects) unsatisfied = unsatisfied_interactions(objects) return if unsatisfied.empty? calls = all_calls(objects) raise NotAllExpectationsSatisfied.create(unsatisfied, calls) end private def unsatisfied_interactions(objects) mapcat_shadows(objects) do |object, shadow| shadow.unsatisfied_interactions.map{|c| [object, c]} end end def all_calls(objects) mapcat_shadows(objects) do |object, shadow| shadow.calls.map{|c| [object, c]} end end def mapcat_shadows(objects, &block) mapped = objects.map do |object| shadow = object.__shadow__ block.call(object, shadow) end mapped.reduce([], :concat) end end end
Version data entries
8 entries across 8 versions & 1 rubygems