lib/mocktail/value/cabinet.rb in mocktail-1.1.1 vs lib/mocktail/value/cabinet.rb in mocktail-1.1.2
- old
+ new
@@ -1,13 +1,16 @@
+require_relative "../share/compares_safely"
+
# 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
@@ -43,17 +46,21 @@
def demonstration_in_progress?
@demonstration_in_progress
end
def double_for_instance(thing)
- @doubles.find { |double| double.dry_instance == thing }
+ @doubles.find { |double| @compares_safely.compare(double.dry_instance, thing) }
end
def stubbings_for_double(double)
- @stubbings.select { |stubbing| stubbing.recording.double == double.dry_instance }
+ @stubbings.select { |stubbing|
+ @compares_safely.compare(stubbing.recording.double, double.dry_instance)
+ }
end
def calls_for_double(double)
- @calls.select { |call| call.double == double.dry_instance }
+ @calls.select { |call|
+ @compares_safely.compare(call.double, double.dry_instance)
+ }
end
end
end