forked from sponsoredbythewind/extlib
/
try_dup_spec.rb
45 lines (38 loc) · 862 Bytes
/
try_dup_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
33
34
35
36
37
38
39
40
41
42
43
44
45
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
describe "try_dup" do
it "returns a duplicate version on regular objects" do
obj = Object.new
oth = obj.try_dup
obj.should_not === oth
end
it "returns self on Numerics" do
obj = 12
oth = obj.try_dup
obj.should === oth
end
it "returns self on Symbols" do
obj = :test
oth = obj.try_dup
obj.should === oth
end
it "returns self on true" do
obj = true
oth = obj.try_dup
obj.should === oth
end
it "returns self on false" do
obj = false
oth = obj.try_dup
obj.should === oth
end
it "returns self on nil" do
obj = nil
oth = obj.try_dup
obj.should === oth
end
it "returns self on modules" do
obj = Extlib
oth = obj.try_dup
obj.object_id.should == oth.object_id
end
end