class Bogus::EnsuresAllInteractionsSatisfied

Public Instance Methods

ensure_satisfied!(objects) click to toggle source
# File lib/bogus/stubbing/ensures_all_interactions_satisfied.rb, line 3
def ensure_satisfied!(objects)
  unsatisfied = unsatisfied_interactions(objects)
  return if unsatisfied.empty?

  calls = all_calls(objects)
  raise NotAllExpectationsSatisfied.create(unsatisfied, calls)
end

Private Instance Methods

all_calls(objects) click to toggle source
# File lib/bogus/stubbing/ensures_all_interactions_satisfied.rb, line 19
def all_calls(objects)
  mapcat_shadows(objects) do |object, shadow|
    shadow.calls.map{|c| [object, c]}
  end
end
mapcat_shadows(objects, &block) click to toggle source
# File lib/bogus/stubbing/ensures_all_interactions_satisfied.rb, line 25
def mapcat_shadows(objects, &block)
  mapped = objects.map do |object|
    shadow = object.__shadow__
    block.call(object, shadow)
  end

  mapped.reduce([], :concat)
end
unsatisfied_interactions(objects) click to toggle source
# File lib/bogus/stubbing/ensures_all_interactions_satisfied.rb, line 13
def unsatisfied_interactions(objects)
  mapcat_shadows(objects) do |object, shadow|
    shadow.unsatisfied_interactions.map{|c| [object, c]}
  end
end