Sha256: e72c23ca014a6634c7f783eef1b11aa5cb4dc16ceb119cbbf1b34eebfebcf7e2

Contents?: true

Size: 757 Bytes

Versions: 12

Compression:

Stored size: 757 Bytes

Contents

module Bogus
  class ContractNotFulfilled < StandardError
    attr_reader :fake_name, :missed_interactions, :actual_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
      str = <<-EOF
      Contract not fullfilled for #{fake_name}!

      Missed interactions:
      #{interactions_str(missed_interactions)}

      Actual interactions:
      #{interactions_str(actual_interactions)}
      EOF
      str.gsub(' ' * 6, '')
    end

    private

    def interactions_str(interactions)
      interactions.map { |i| "  - #{InteractionPresenter.new(i)}" }.join("\n")
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bogus-0.1.7 lib/bogus/contracts/contract_not_fulfilled.rb
bogus-0.1.6 lib/bogus/contracts/contract_not_fulfilled.rb
bogus-0.1.5 lib/bogus/contracts/contract_not_fulfilled.rb
bogus-0.1.4 lib/bogus/contracts/contract_not_fulfilled.rb
bogus-0.1.3 lib/bogus/contract_not_fulfilled.rb
bogus-0.1.2 lib/bogus/contract_not_fulfilled.rb
bogus-0.1.1 lib/bogus/contract_not_fulfilled.rb
bogus-0.1.0 lib/bogus/contract_not_fulfilled.rb
bogus-0.0.4 lib/bogus/contract_not_fulfilled.rb
bogus-0.0.3 lib/bogus/contract_not_fulfilled.rb
bogus-0.0.3.rc.2 lib/bogus/contract_not_fulfilled.rb
bogus-0.0.3.rc.1 lib/bogus/contract_not_fulfilled.rb