djsun-mongo_mapper 0.5.6.2 → 0.5.6.3

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.6.2
1
+ 0.5.6.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{djsun-mongo_mapper}
8
- s.version = "0.5.6.2"
8
+ s.version = "0.5.6.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Nunemaker"]
@@ -269,6 +269,7 @@ module MongoMapper
269
269
  end
270
270
 
271
271
  def ==(other)
272
+ return false unless other.is_a?(EmbeddedDocument)
272
273
  ignore = { '_id' => nil }
273
274
  attributes.merge(ignore) == other.attributes.merge(ignore)
274
275
  end
@@ -173,8 +173,15 @@ class DocumentTest < Test::Unit::TestCase
173
173
  doc_2 = @document.new('name' => "Doc 2")
174
174
  doc_1.should_not == doc_2
175
175
  end
176
+
177
+ should "not be == when comparing other object types" do
178
+ doc = @document.new('name' => "Doc")
179
+ doc.should_not == nil
180
+ doc.should_not == false
181
+ doc.should_not == { 'name' => "Doc" }
182
+ end
176
183
 
177
- should "not care about type" do
184
+ should "not care about document type" do
178
185
  @person = Class.new do
179
186
  include MongoMapper::EmbeddedDocument
180
187
 
@@ -195,13 +202,20 @@ class DocumentTest < Test::Unit::TestCase
195
202
  doc_1.should eql?(doc_2)
196
203
  end
197
204
 
198
- should "not be == if type matches but key values are different" do
205
+ should "not be eql? if type matches but key values are different" do
199
206
  doc_1 = @document.new('name' => "Doc 1")
200
207
  doc_2 = @document.new('name' => "Doc 2")
201
208
  doc_1.should_not eql?(doc_2)
202
209
  end
203
210
 
204
- should "not be eql? if types are different even if values are the same" do
211
+ should "not be eql? when comparing other object types" do
212
+ doc = @document.new('name' => "Doc")
213
+ doc.should_not eql?(nil)
214
+ doc.should_not eql?(false)
215
+ doc.should_not eql?({ 'name' => "Doc" })
216
+ end
217
+
218
+ should "not be eql? if document types are different even if values are the same" do
205
219
  @person = Class.new do
206
220
  include MongoMapper::EmbeddedDocument
207
221
 
@@ -657,7 +657,14 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
657
657
  doc_1.should_not == doc_2
658
658
  end
659
659
 
660
- should "not care about type" do
660
+ should "not be == when comparing other object types" do
661
+ doc = @document.new('name' => "Doc")
662
+ doc.should_not == nil
663
+ doc.should_not == false
664
+ doc.should_not == { 'name' => "Doc" }
665
+ end
666
+
667
+ should "not care about document type" do
661
668
  @person = Class.new do
662
669
  include MongoMapper::EmbeddedDocument
663
670
 
@@ -678,12 +685,19 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
678
685
  doc_1.should eql?(doc_2)
679
686
  end
680
687
 
681
- should "not be == if type matches but key values are different" do
688
+ should "not be eql? if type matches but key values are different" do
682
689
  doc_1 = @document.new('name' => "Doc 1")
683
690
  doc_2 = @document.new('name' => "Doc 2")
684
691
  doc_1.should_not eql?(doc_2)
685
692
  end
686
693
 
694
+ should "not be eql? when comparing other object types" do
695
+ doc = @document.new('name' => "Doc")
696
+ doc.should_not eql?(nil)
697
+ doc.should_not eql?(false)
698
+ doc.should_not eql?({ 'name' => "Doc" })
699
+ end
700
+
687
701
  should "not be eql? if types are different even if values are the same" do
688
702
  @person = Class.new do
689
703
  include MongoMapper::EmbeddedDocument
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: djsun-mongo_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6.2
4
+ version: 0.5.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker