From 3dc3bf1054258a68b473e642b18ac961ea570ffa Mon Sep 17 00:00:00 2001 From: Sam Figueroa Date: Tue, 12 Jul 2016 09:42:46 +0200 Subject: [PATCH] Compare with nil when supplied argument is nil - Avoid no method 'name' for nil error. - The default spaceship operator also will return a nil instead of -1,0,1 if the objects provided are not comparable. - coincidentally fixes a compatability issue seen with ruby 2.3.1 --- lib/fakes3/s3_object.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fakes3/s3_object.rb b/lib/fakes3/s3_object.rb index 5d9fe989..8af03060 100644 --- a/lib/fakes3/s3_object.rb +++ b/lib/fakes3/s3_object.rb @@ -13,7 +13,7 @@ def eql?(object) # Sort by the object's name def <=>(object) - @name <=> object.name + @name <=> (object && object.name) end end end