Sha256: 1632a8a159a0a40a2750f817f0db85243b293f5ee726a4f9de67dca4d542d2fc
Contents?: true
Size: 1.14 KB
Versions: 12
Compression:
Stored size: 1.14 KB
Contents
module Muack class Failure < Exception attr_reader :expected def build_expected obj, expected_defis @expected = expected_defis.uniq{ |d| [d.msg, d.args] }.map{ |defi| "#{obj.inspect}.#{defi.msg}(" \ "#{defi.args.map(&:inspect).join(', ')})" }.join("\n or: ") end end class Unexpected < Failure attr_reader :was def initialize obj, expected_defis, msg, args @was = "#{obj.inspect}.#{msg}(" \ "#{args.map(&:inspect).join(', ')})" if expected_defis.empty? super("\nExpected: #{@was}\n was not called.") else build_expected(obj, expected_defis) super("\nExpected: #{expected}\n but was: #{was}") end end end class Expected < Failure attr_reader :expected_times, :actual_times def initialize obj, defi, expected_times, actual_times build_expected(obj, [defi]) @expected_times = expected_times @actual_times = actual_times super("\nExpected: #{expected}\n called #{expected_times} times\n" \ " but was #{actual_times} times.") end end end
Version data entries
12 entries across 12 versions & 1 rubygems