naming 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/naming.rb +12 -0
- data/lib/naming/version.rb +1 -1
- data/test/spec_naming.rb +12 -0
- metadata +1 -1
data/lib/naming.rb
CHANGED
@@ -130,6 +130,18 @@ module Naming
|
|
130
130
|
def value
|
131
131
|
@value
|
132
132
|
end
|
133
|
+
|
134
|
+
# @api private
|
135
|
+
def ==(other)
|
136
|
+
return false unless other.kind_of?(self.class)
|
137
|
+
@value == other.value
|
138
|
+
end
|
139
|
+
alias :eql? :"=="
|
140
|
+
|
141
|
+
# @api private
|
142
|
+
def hash
|
143
|
+
@value.hash
|
144
|
+
end
|
133
145
|
end
|
134
146
|
|
135
147
|
class << self
|
data/lib/naming/version.rb
CHANGED
data/test/spec_naming.rb
CHANGED
@@ -29,4 +29,16 @@ describe 'Naming' do
|
|
29
29
|
Naming::B.values(list).should == [2]
|
30
30
|
Naming.others(list).should == ["abc", 123, nil]
|
31
31
|
end
|
32
|
+
|
33
|
+
it 'should equal when the names and values are same' do
|
34
|
+
Naming.A(1).should == Naming.A(1)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should equal when names are different' do
|
38
|
+
Naming.A(1).should.not == Naming.B(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should equal when values are different' do
|
42
|
+
Naming.A(1).should.not == Naming.A(2)
|
43
|
+
end
|
32
44
|
end
|