Sha256: 2a59fa78ceab87589ad0a26308054f68618b7f807dff4d950bfb30dc322a7273
Contents?: true
Size: 846 Bytes
Versions: 4
Compression:
Stored size: 846 Bytes
Contents
module Bogus class EnsuresAllInteractionsSatisfied extend Bogus::Takes 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
4 entries across 4 versions & 1 rubygems