mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Test mock scope
This commit is contained in:
parent
3f4216a271
commit
8fbcbe8b73
1 changed files with 54 additions and 0 deletions
|
@ -257,4 +257,58 @@ Spectator.describe "Mock DSL", :smoke do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "scope" do
|
||||
class Scope
|
||||
def scope
|
||||
:original
|
||||
end
|
||||
end
|
||||
|
||||
mock(Scope, scope: :outer)
|
||||
|
||||
it "finds a mock in the same scope" do
|
||||
fake = mock(Scope)
|
||||
expect(fake.scope).to eq(:outer)
|
||||
end
|
||||
|
||||
context "inner1" do
|
||||
mock(Scope, scope: :inner)
|
||||
|
||||
it "uses the innermost defined mock" do
|
||||
fake = mock(Scope)
|
||||
expect(fake.scope).to eq(:inner)
|
||||
end
|
||||
|
||||
context "nested1" do
|
||||
mock(Scope, scope: :nested)
|
||||
|
||||
it "uses the nested defined mock" do
|
||||
fake = mock(Scope)
|
||||
expect(fake.scope).to eq(:nested)
|
||||
end
|
||||
end
|
||||
|
||||
context "nested2" do
|
||||
it "finds a mock from a parent scope" do
|
||||
fake = mock(Scope)
|
||||
expect(fake.scope).to eq(:inner)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "inner2" do
|
||||
it "finds a mock from a parent scope" do
|
||||
fake = mock(Scope)
|
||||
expect(fake.scope).to eq(:outer)
|
||||
end
|
||||
|
||||
context "nested3" do
|
||||
it "finds a mock from a grandparent scope" do
|
||||
fake = mock(Scope)
|
||||
expect(fake.scope).to eq(:outer)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue