Skip to content

Commit

Permalink
use existential matchers for object identity
Browse files Browse the repository at this point in the history
  • Loading branch information
chastell committed Feb 1, 2011
1 parent bbf3b8e commit 9aafb0b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions spec/relentity/entity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class Poolless; include Entity; end
it 'retrieves and stores the related EntityPool' do
class AnEntity; include Entity; end
module AnEntityPool; end
AnEntity.entity_pool.should be_nil
AnEntity.entity_pool.should be nil
AnEntity.entity_pool AnEntityPool
AnEntity.entity_pool.should == AnEntityPool
AnEntity.entity_pool.should be AnEntityPool
end

end
Expand All @@ -30,7 +30,7 @@ module AnEntityPool; end

it 'returns nil if not set explicitly' do
class IdLessEntity; include Entity; end
IdLessEntity.new.id.should be_nil
IdLessEntity.new.id.should be nil
end

end
Expand Down
12 changes: 6 additions & 6 deletions spec/relentity/persistence/no_thanks/entity_pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class NoThanksPerson
class NoThanksAddEntity; include Entity; end
module NoThanksAddPool; extend Persistence::NoThanks::EntityPool; end
entity = NoThanksAddEntity.new
entity.id.should be_nil
NoThanksAddPool[entity.object_id].should == nil
entity.id.should be nil
NoThanksAddPool[entity.object_id].should be nil
NoThanksAddPool << entity
entity.id.should == entity.object_id
NoThanksAddPool[entity.object_id].should == entity
NoThanksAddPool[entity.object_id].should be entity
end

end
Expand All @@ -30,9 +30,9 @@ module NoThanksAddPool; extend Persistence::NoThanks::EntityPool; end
it 'returns the Entity with the given id' do
NoThanksPeople << (rincewind = NoThanksPerson.new id: :rincewind)
NoThanksPeople << (twoflower = NoThanksPerson.new id: :twoflower)
NoThanksPeople[:rincewind].should == rincewind
NoThanksPeople[:twoflower].should == twoflower
NoThanksPeople[:auditor].should == nil
NoThanksPeople[:rincewind].should be rincewind
NoThanksPeople[:twoflower].should be twoflower
NoThanksPeople[:auditor].should be nil
end

end
Expand Down
20 changes: 10 additions & 10 deletions spec/relentity/persistence/yaml_store/entity_pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class YAMLStorePerson
describe '.<<' do

it 'saves the passed entity to the YAMLStore, creating it if necessary' do
File.exists?("#{@root}/Relentity::YAMLStorePeople.yml").should be_false
File.exists?("#{@root}/Relentity::YAMLStorePeople.yml").should be false
YAMLStorePerson.new id: :sandra, given_names: ['Sandra'], surname: 'Battye'
File.exists?("#{@root}/Relentity::YAMLStorePeople.yml").should be_true
File.exists?("#{@root}/Relentity::YAMLStorePeople.yml").should be true
File.read("#{@root}/Relentity::YAMLStorePeople.yml").should == File.read('spec/fixtures/persistence/yaml_store/entity_pool.sandra.yml')
end

Expand All @@ -41,11 +41,11 @@ class YAMLStoreAddEntity; include Entity; end
module YAMLStoreAddPool; extend Persistence::YAMLStore::EntityPool; end
YAMLStoreAddPool.root = temp
entity = YAMLStoreAddEntity.new
entity.id.should be_nil
YAMLStoreAddPool[entity.object_id].should == nil
entity.id.should be nil
YAMLStoreAddPool[entity.object_id].should be nil
YAMLStoreAddPool << entity
entity.id.should == entity.object_id
YAMLStoreAddPool[entity.object_id].should == entity
YAMLStoreAddPool[entity.object_id].should be entity
end
end

Expand All @@ -56,9 +56,9 @@ module YAMLStoreAddPool; extend Persistence::YAMLStore::EntityPool; end
it 'returns the Entity with the given id' do
sam = YAMLStorePerson.new id: :sam
sybil = YAMLStorePerson.new id: :sybil
YAMLStorePeople[:sam].should == sam
YAMLStorePeople[:sybil].should == sybil
YAMLStorePeople[:auditor].should == nil
YAMLStorePeople[:sam].should be sam
YAMLStorePeople[:sybil].should be sybil
YAMLStorePeople[:auditor].should be nil
end

end
Expand All @@ -70,10 +70,10 @@ module YAMLStoreRootPool; extend Persistence::YAMLStore::EntityPool; end
class YAMLStoreRootEntity; include Entity; end
2.times do
Dir.mktmpdir do |root|
File.exists?("#{root}/Relentity::YAMLStoreRootPool.yml").should be_false
File.exists?("#{root}/Relentity::YAMLStoreRootPool.yml").should be false
YAMLStoreRootPool.root = root
YAMLStoreRootPool << YAMLStoreRootEntity.new
File.exists?("#{root}/Relentity::YAMLStoreRootPool.yml").should be_true
File.exists?("#{root}/Relentity::YAMLStoreRootPool.yml").should be true
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/relentity/rel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ module Relentity describe Rel do
describe '#other' do

it 'returns the other Entity' do
@duchy.other(@sam).should == @sybil
@duchy.other(@sybil).should == @sam
@duchy.other(@y_sam).should == nil
@duchy.other(@sam).should be @sybil
@duchy.other(@sybil).should be @sam
@duchy.other(@y_sam).should be nil
end

end

describe '#refs?' do

it 'is a predicate whether the Rel refs the given Entity' do
@duchy.refs?(@sam).should be_true
@duchy.refs?(@sybil).should be_true
@duchy.refs?(@y_sams).should be_false
@duchy.refs?(@sam).should be true
@duchy.refs?(@sybil).should be true
@duchy.refs?(@y_sams).should be false
end

end
Expand Down

0 comments on commit 9aafb0b

Please sign in to comment.