lib/mocktail/value/cabinet.rb in mocktail-1.1.2 vs lib/mocktail/value/cabinet.rb in mocktail-1.1.3

- old
+ new

@@ -1,16 +1,15 @@ -require_relative "../share/compares_safely" +require_relative "../share/bind" # The Cabinet stores all thread-local state, so anything that goes here # is guaranteed by Mocktail to be local to the currently-running thread module Mocktail class Cabinet attr_writer :demonstration_in_progress attr_reader :calls, :stubbings, :unsatisfying_calls def initialize - @compares_safely = ComparesSafely.new @doubles = [] @calls = [] @stubbings = [] @unsatisfying_calls = [] @demonstration_in_progress = false @@ -46,21 +45,24 @@ def demonstration_in_progress? @demonstration_in_progress end def double_for_instance(thing) - @doubles.find { |double| @compares_safely.compare(double.dry_instance, thing) } + @doubles.find { |double| + # Intentionally calling directly to avoid an infinite recursion in Bind.call + Object.instance_method(:==).bind_call(double.dry_instance, thing) + } end def stubbings_for_double(double) @stubbings.select { |stubbing| - @compares_safely.compare(stubbing.recording.double, double.dry_instance) + Bind.call(stubbing.recording.double, :==, double.dry_instance) } end def calls_for_double(double) @calls.select { |call| - @compares_safely.compare(call.double, double.dry_instance) + Bind.call(call.double, :==, double.dry_instance) } end end end