forked from celluloid/dcell
-
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.
pass registry instance rather than its name
this allows to easily plug unoficial registries
- Loading branch information
Showing
6 changed files
with
27 additions
and
25 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
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
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 |
---|---|---|
@@ -1,21 +1,23 @@ | ||
describe DCell do | ||
it "raises exception on unknown registry provider" do | ||
expect {DCellMock.setup :registry => {:adapter => nil}}.to raise_error(ArgumentError, "no registry adapter given in config") | ||
expect {DCellMock.setup :registry => {:adapter => 'invalid'}}.to raise_error(ArgumentError, "invalid registry adapter: invalid") | ||
expect {DCellMock.setup}.to raise_error(ArgumentError, "no registry adapter given in config") | ||
end | ||
|
||
it "uses unique method of registry to generate node ID" do | ||
DCellMock.setup :registry => {:adapter => 'dummy', :seed => Math::PI} | ||
registry = DCell::Registry::DummyAdapter.new :seed => Math::PI | ||
DCellMock.setup :registry => registry | ||
DCellMock.id.should == Math::PI | ||
end | ||
|
||
it "accepts node ID as optional setup parameter" do | ||
DCellMock.setup :id => Math::E, :registry => {:adapter => 'dummy'} | ||
registry = DCell::Registry::DummyAdapter.new({}) | ||
DCellMock.setup :id => Math::E, :registry => registry | ||
DCellMock.id.should == Math::E | ||
end | ||
|
||
it "tries to generate node ID if registry does not define :unique method and no explicit setup parameter given" do | ||
DCellMock.setup :registry => {:adapter => 'noop'} | ||
registry = DCell::Registry::NoopAdapter.new({}) | ||
DCellMock.setup :registry => registry | ||
DCellMock.id.should_not == nil | ||
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