mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add ReferenceMockRegistry
This commit is contained in:
parent
0704fd2a48
commit
380d721fad
3 changed files with 57 additions and 4 deletions
23
spec/spectator/mocks/reference_mock_registry_spec.cr
Normal file
23
spec/spectator/mocks/reference_mock_registry_spec.cr
Normal file
|
@ -0,0 +1,23 @@
|
|||
require "../../spec_helper"
|
||||
|
||||
Spectator.describe Spectator::ReferenceMockRegistry do
|
||||
subject(registry) { described_class.new }
|
||||
let(stub) { Spectator::ValueStub.new(:test, 42) }
|
||||
|
||||
it "initially has no stubs" do
|
||||
obj = "foobar"
|
||||
expect(registry[obj]).to be_empty
|
||||
end
|
||||
|
||||
it "stores stubs for an object" do
|
||||
obj = "foobar"
|
||||
expect { registry[obj] << stub }.to change { registry[obj] }.from([] of Spectator::Stub).to([stub])
|
||||
end
|
||||
|
||||
it "isolates stubs between different objects" do
|
||||
obj1 = "foo"
|
||||
obj2 = "bar"
|
||||
registry[obj2] << Spectator::ValueStub.new(:obj2, 42)
|
||||
expect { registry[obj1] << stub }.to_not change { registry[obj2] }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue