-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode_spec.rb
32 lines (27 loc) · 860 Bytes
/
node_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require './node.rb'
describe Node do
before :each do
@test_node1 = Node.new 9
@test_node2 = Node.new 'A'
@test_node3 = Node.new 8, 'a'
end
it 'should accept all type of objects as a node' do
@test_node1.object.should == 9
@test_node2.object.should == 'A'
@test_node3.object.should == 8
end
it 'should treat object as a key itself if no key is provided' do
@test_node1.key.should == 9
@test_node2.key.should == 'A'
end
it 'should return true if key of the node is equal to other object key or value' do
@test_node1.should == Node.new(9)
@test_node2.should == 'A'
@test_node3.should_not == 8
end
it 'should return an integer when used as an hash key' do
@test_node1.hash.class.should == Fixnum
@test_node2.hash.class.should == Fixnum
@test_node3.hash.class.should == Fixnum
end
end