yeti 0.3.7 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
data/lib/yeti/editor.rb CHANGED
@@ -81,6 +81,11 @@ module Yeti
81
81
  other.id==id
82
82
  )
83
83
  end
84
+ alias_method :eql?, :==
85
+
86
+ def hash
87
+ id.hash
88
+ end
84
89
 
85
90
  protected
86
91
 
data/lib/yeti/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yeti
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.9"
3
3
  end
data/lib/yeti/viewer.rb CHANGED
@@ -16,6 +16,11 @@ module Yeti
16
16
  def ==(other)
17
17
  other.equal?(self) || (other.instance_of?(self.class) && other.id==id)
18
18
  end
19
+ alias_method :eql?, :==
20
+
21
+ def hash
22
+ id.hash
23
+ end
19
24
 
20
25
  protected
21
26
 
@@ -288,7 +288,7 @@ describe ::Yeti::Editor do
288
288
  subject.mandatory?(:invalid).should be false
289
289
  end
290
290
  end
291
- describe "#==" do
291
+ describe "equality" do
292
292
  let(:existing){ mock :object, id: 1, persisted?: true }
293
293
  let(:another){ mock :object, id: 2, persisted?: true }
294
294
  subject{ described_class.from_id context, 1 }
@@ -296,21 +296,33 @@ describe ::Yeti::Editor do
296
296
  described_class.stub(:find_by_id).with(context, 1).and_return existing
297
297
  described_class.stub(:find_by_id).with(context, 2).and_return another
298
298
  described_class.stub(:new_object).with(context).and_return do
299
- mock persisted?: false
299
+ mock persisted?: false, id: nil
300
300
  end
301
301
  end
302
302
  it "two new editors are not equal" do
303
303
  subject = described_class.new context
304
- subject.should_not == described_class.new(context)
304
+ other = described_class.new context
305
+ subject.should_not == other
306
+ subject.should_not eql other
307
+ subject.hash.should == other.hash
305
308
  end
306
309
  it "two editors of the same class with the same id are equal" do
307
- subject.should == described_class.from_id(context, 1)
310
+ other = described_class.from_id context, 1
311
+ subject.should == other
312
+ subject.should eql other
313
+ subject.hash.should == other.hash
308
314
  end
309
315
  it "two editors of the same class with different ids are not equal" do
310
- subject.should_not == described_class.from_id(context, 2)
316
+ other = described_class.from_id context, 2
317
+ subject.should_not == other
318
+ subject.should_not eql other
319
+ subject.hash.should_not == other.hash
311
320
  end
312
321
  it "two editors of different classes with the same id are not equal" do
313
- subject.should_not == Class.new(described_class).from_id(context, 1)
322
+ other = Class.new(described_class).from_id context, 1
323
+ subject.should_not == other
324
+ subject.should_not eql other
325
+ subject.hash.should == other.hash
314
326
  end
315
327
  end
316
328
  end
@@ -2,7 +2,6 @@ require "spec_helper"
2
2
 
3
3
  describe ::Yeti::Viewer do
4
4
  let(:context){ mock :context }
5
- subject{ described_class.new context }
6
5
  it ".find_by_id is virtual" do
7
6
  lambda do
8
7
  described_class.find_by_id context, 1
@@ -37,7 +36,7 @@ describe ::Yeti::Viewer do
37
36
  subject.decorated.should be existing_object
38
37
  end
39
38
  end
40
- describe "#==" do
39
+ describe "equality" do
41
40
  let(:existing){ mock :object, id: 1 }
42
41
  let(:another){ mock :object, id: 2 }
43
42
  subject{ described_class.from_id context, 1 }
@@ -46,13 +45,22 @@ describe ::Yeti::Viewer do
46
45
  described_class.stub(:find_by_id).with(context, 2).and_return another
47
46
  end
48
47
  it "two viewers of the same class with the same id are equal" do
49
- subject.should == described_class.from_id(context, 1)
48
+ other = described_class.from_id context, 1
49
+ subject.should == other
50
+ subject.should eql other
51
+ subject.hash.should == other.hash
50
52
  end
51
53
  it "two viewers of the same class with different ids are not equal" do
52
- subject.should_not == described_class.from_id(context, 2)
54
+ other = described_class.from_id context, 2
55
+ subject.should_not == other
56
+ subject.should_not eql other
57
+ subject.hash.should_not == other.hash
53
58
  end
54
59
  it "two viewers of different classes with the same id are not equal" do
55
- subject.should_not == Class.new(described_class).from_id(context, 1)
60
+ other = Class.new(described_class).from_id context, 1
61
+ subject.should_not == other
62
+ subject.should_not eql other
63
+ subject.hash.should == other.hash
56
64
  end
57
65
  end
58
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  segments:
118
118
  - 0
119
- hash: -4028484294120140186
119
+ hash: 8619314941788214
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  none: false
122
122
  requirements:
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  segments:
127
127
  - 0
128
- hash: -4028484294120140186
128
+ hash: 8619314941788214
129
129
  requirements: []
130
130
  rubyforge_project:
131
131
  rubygems_version: 1.8.23