1require_relative '../../spec_helper'
2
3describe "Kernel#<=>" do
4  it "returns 0 if self" do
5    obj = Object.new
6    obj.<=>(obj).should == 0
7  end
8
9  it "returns 0 if self is == to the argument" do
10    obj = mock('has ==')
11    obj.should_receive(:==).and_return(true)
12    obj.<=>(Object.new).should == 0
13  end
14
15  it "returns nil if self is eql? but not == to the argument" do
16    obj = mock('has eql?')
17    obj.should_not_receive(:eql?)
18    obj.<=>(Object.new).should be_nil
19  end
20
21  it "returns nil if self.==(arg) returns nil" do
22    obj = mock('wrong ==')
23    obj.should_receive(:==).and_return(nil)
24    obj.<=>(Object.new).should be_nil
25  end
26
27  it "returns nil if self is not == to the argument" do
28    obj = Object.new
29    obj.<=>(3.14).should be_nil
30  end
31end
32