Sha256: 2b0d0d5083b90e264b107a8f03f614d1ddbd429ef0946481d4c35903796757d9

Contents?: true

Size: 753 Bytes

Versions: 12

Compression:

Stored size: 753 Bytes

Contents

module Bogus
  class NotAllExpectationsSatisfied < StandardError
    def self.create(unsatisfied_interactions, calls)
      str = <<-EOF
      Some of the mocked interactions were not satisfied:

      <% unsatisfied_interactions.each do |o, i| %>
        - <%= render_interaction(o, i) %>
      <% end %>

      The following calls were recorded:

      <% calls.each do |o, i| %>
        - <%= render_interaction(o, i) %>
      <% end %>
      EOF
      str = str.gsub(/ {6}/, '')
      template = ERB.new(str, nil, "<>")
      new(template.result(binding))
    end

    def self.render_interaction(object, interaction)
      args = interaction.args.map(&:inspect).join(", ")
      "#{object.inspect}.#{interaction.method}(#{args})"
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

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