forked from mongomapper/mongomapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
62 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'test_helper' | ||
|
||
class Person | ||
include MongoMapper::Document | ||
|
||
one :address | ||
end | ||
|
||
class Address | ||
include MongoMapper::Document | ||
|
||
belongs_to :person | ||
end | ||
|
||
class EqualityTest < Test::Unit::TestCase | ||
context "Case equality" do | ||
should "work with proxies" do | ||
person = Person.create | ||
address = Address.create(:person => person) | ||
Person.should === address.person | ||
Address.should === person.address | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'test_helper' | ||
|
||
class Equality | ||
include MongoMapper::Plugins::Equality | ||
end | ||
|
||
class Equality2 < Equality; end | ||
|
||
class Faker | ||
def initialize(faked) | ||
@faked = faked | ||
end | ||
|
||
def is_a?(klass) | ||
@faked.is_a? klass | ||
end | ||
end | ||
|
||
class EqualityTest < Test::Unit::TestCase | ||
context "Case equality" do | ||
should "work with regular instance" do | ||
Equality.should === Equality.new | ||
end | ||
|
||
should "work with instances of subclasses" do | ||
Equality.should === Equality2.new | ||
end | ||
|
||
should "work with a faker class" do | ||
Equality.should === Faker.new(Equality.new) | ||
end | ||
|
||
should "not work with other instances" do | ||
Equality.should_not === 1 | ||
end | ||
end | ||
end |