equalizer 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +2 -1
- data/Gemfile +0 -4
- data/README.md +1 -1
- data/config/flay.yml +1 -1
- data/lib/equalizer.rb +1 -1
- data/lib/equalizer/version.rb +1 -1
- data/spec/unit/equalizer/methods/equal_value_spec.rb +18 -5
- metadata +4 -4
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/config/flay.yml
CHANGED
data/lib/equalizer.rb
CHANGED
@@ -114,7 +114,7 @@ private
|
|
114
114
|
# @api public
|
115
115
|
def ==(other)
|
116
116
|
other = coerce(other) if respond_to?(:coerce, true)
|
117
|
-
|
117
|
+
other.kind_of?(self.class) && cmp?(__method__, other)
|
118
118
|
end
|
119
119
|
|
120
120
|
end # module Methods
|
data/lib/equalizer/version.rb
CHANGED
@@ -5,9 +5,10 @@ require 'spec_helper'
|
|
5
5
|
describe Equalizer::Methods, '#==' do
|
6
6
|
subject { object == other }
|
7
7
|
|
8
|
-
let(:object)
|
8
|
+
let(:object) { described_class.new(true) }
|
9
|
+
let(:described_class) { Class.new(super_class) }
|
9
10
|
|
10
|
-
let(:
|
11
|
+
let(:super_class) do
|
11
12
|
Class.new do
|
12
13
|
include Equalizer::Methods
|
13
14
|
|
@@ -43,13 +44,25 @@ describe Equalizer::Methods, '#==' do
|
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
|
-
context 'with
|
47
|
+
context 'with a subclass instance having equivalent obervable state' do
|
47
48
|
let(:other) { Class.new(described_class).new(true) }
|
48
49
|
|
49
50
|
it { should be(true) }
|
50
51
|
|
51
|
-
it 'is symmetric' do
|
52
|
-
should
|
52
|
+
it 'is not symmetric' do
|
53
|
+
# the subclass instance should maintain substitutability with the object
|
54
|
+
# (in the LSP sense) the reverse is not true.
|
55
|
+
should_not eql(other == object)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'with a superclass instance having equivalent observable state' do
|
60
|
+
let(:other) { super_class.new(true) }
|
61
|
+
|
62
|
+
it { should be(false) }
|
63
|
+
|
64
|
+
it 'is not symmetric' do
|
65
|
+
should_not eql(other == object)
|
53
66
|
end
|
54
67
|
end
|
55
68
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: equalizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dan Kubb
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-
|
19
|
+
date: 2012-12-25 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: backports
|