Skip to content

Commit 4f76e4d

Browse files
committed
Add specs for Kernel#{initialize_clone,initialize_dup}
1 parent 6862ab3 commit 4f76e4d

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require_relative '../../spec_helper'
2+
3+
describe "Kernel#initialize_clone" do
4+
it "is a private instance method" do
5+
Kernel.should have_private_instance_method(:initialize_clone)
6+
end
7+
8+
it "returns the receiver" do
9+
a = Object.new
10+
b = Object.new
11+
a.send(:initialize_clone, b).should == a
12+
end
13+
14+
it "calls #initialize_copy" do
15+
a = Object.new
16+
b = Object.new
17+
a.should_receive(:initialize_copy).with(b)
18+
a.send(:initialize_clone, b)
19+
end
20+
21+
ruby_version_is "3.0" do
22+
it "accepts a :freeze keyword argument for obj.clone(freeze: value)" do
23+
a = Object.new
24+
b = Object.new
25+
a.send(:initialize_clone, b, freeze: true).should == a
26+
end
27+
end
28+
end

core/kernel/initialize_dup_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require_relative '../../spec_helper'
2+
3+
describe "Kernel#initialize_dup" do
4+
it "is a private instance method" do
5+
Kernel.should have_private_instance_method(:initialize_dup)
6+
end
7+
8+
it "returns the receiver" do
9+
a = Object.new
10+
b = Object.new
11+
a.send(:initialize_dup, b).should == a
12+
end
13+
14+
it "calls #initialize_copy" do
15+
a = Object.new
16+
b = Object.new
17+
a.should_receive(:initialize_copy).with(b)
18+
a.send(:initialize_dup, b)
19+
end
20+
end

0 commit comments

Comments
 (0)