lib/bogus/contract_not_fulfilled.rb in bogus-0.0.2 vs lib/bogus/contract_not_fulfilled.rb in bogus-0.0.3.rc.1

- old
+ new

@@ -1,24 +1,31 @@ module Bogus class ContractNotFulfilled < StandardError - attr_reader :interactions + attr_reader :fake_name, :missed_interactions, :actual_interactions - def initialize(interactions) - @interactions = interactions + def initialize(fake_name, opts = {}) + @fake_name = fake_name + @actual_interactions = opts.fetch(:actual) + @missed_interactions = opts.fetch(:missed) super(message) end def message - interactions.map { |fake_name, missed| missed_for_fake(fake_name, missed) }.join("\n") - end + str = <<-EOF + Contract not fullfilled for #{fake_name}! - private + Missed interactions: + #{interactions_str(missed_interactions)} - def missed_for_fake(fake_name, missed) - "Contract not fullfilled for #{fake_name}:\n#{missed_interactions(missed)}" + Actual interactions: + #{interactions_str(actual_interactions)} + EOF + str.gsub(' ' * 6, '') end - def missed_interactions(missed) - missed.map { |i| " - #{InteractionPresenter.new(i)}" }.join("\n") + private + + def interactions_str(interactions) + interactions.map { |i| " - #{InteractionPresenter.new(i)}" }.join("\n") end end end