Skip to content

Commit 9819db6

Browse files
nobueregon
authored andcommitted
Delegate to eql? [Fix GH-1564]
* lib/delegate.rb (eql?): Delegate to `eql?` of the inner object. based on the patch by giginet <giginet.net@gmail.com>. [ruby-core:76950] [Bug#12684] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent b6bb571 commit 9819db6

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

library/delegate/delegator/eql_spec.rb

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,34 @@
22
require File.expand_path('../../fixtures/classes', __FILE__)
33

44
describe "Delegator#eql?" do
5-
it "is delegated" do
5+
it "returns true when compared with same delegator" do
66
base = mock('base')
77
delegator = DelegateSpecs::Delegator.new(base)
8-
base.should_receive(:eql?).with(42).and_return(:foo)
9-
delegator.eql?(42).should == :foo
8+
9+
delegator.eql?(delegator).should be_true
10+
end
11+
12+
it "returns true when compared with the inner object" do
13+
base = mock('base')
14+
delegator = DelegateSpecs::Delegator.new(base)
15+
16+
delegator.eql?(base).should be_true
17+
end
18+
19+
it "returns false when compared with the delegator with other object" do
20+
base = mock('base')
21+
other = mock('other')
22+
delegator0 = DelegateSpecs::Delegator.new(base)
23+
delegator1 = DelegateSpecs::Delegator.new(other)
24+
25+
delegator0.eql?(delegator1).should be_false
26+
end
27+
28+
it "returns false when compared with the other object" do
29+
base = mock('base')
30+
other = mock('other')
31+
delegator = DelegateSpecs::Delegator.new(base)
32+
33+
delegator.eql?(other).should be_false
1034
end
1135
end

0 commit comments

Comments
 (0)