aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/time/comparison_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/time/comparison_spec.rb')
-rw-r--r--spec/ruby/core/time/comparison_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/ruby/core/time/comparison_spec.rb b/spec/ruby/core/time/comparison_spec.rb
index 44d8778da4..5b53c9fb50 100644
--- a/spec/ruby/core/time/comparison_spec.rb
+++ b/spec/ruby/core/time/comparison_spec.rb
@@ -45,6 +45,16 @@ describe "Time#<=>" do
(Time.at(100, 0) <=> Time.at(100, Rational(1,1000))).should == -1
end
+ it "returns nil when compared to an Integer because Time does not respond to #coerce" do
+ time = Time.at(1)
+ time.respond_to?(:coerce).should == false
+ time.should_receive(:respond_to?).exactly(2).and_return(false)
+ -> {
+ (time <=> 2).should == nil
+ (2 <=> time).should == nil
+ }.should_not complain
+ end
+
describe "given a non-Time argument" do
it "returns nil if argument <=> self returns nil" do
t = Time.now