mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Ensure stubs don't leak between examples
This commit is contained in:
parent
c6afa0adb3
commit
b3aa2d62c0
1 changed files with 24 additions and 0 deletions
|
@ -14,6 +14,12 @@ Spectator.describe "Deferred stub expectation DSL" do
|
||||||
# Ensure invocations don't leak between examples.
|
# Ensure invocations don't leak between examples.
|
||||||
pre_condition { expect(dbl).to_not have_received(:foo), "Leaked method calls from previous examples" }
|
pre_condition { expect(dbl).to_not have_received(:foo), "Leaked method calls from previous examples" }
|
||||||
|
|
||||||
|
# Ensure stubs don't leak between examples.
|
||||||
|
pre_condition do
|
||||||
|
expect { dbl.foo }.to raise_error(Spectator::UnexpectedMessage)
|
||||||
|
dbl._spectator_clear_calls # Don't include previous call in results.
|
||||||
|
end
|
||||||
|
|
||||||
it "matches when a message is received" do
|
it "matches when a message is received" do
|
||||||
expect(dbl).to receive(:foo)
|
expect(dbl).to receive(:foo)
|
||||||
dbl.foo
|
dbl.foo
|
||||||
|
@ -67,6 +73,12 @@ Spectator.describe "Deferred stub expectation DSL" do
|
||||||
# Ensure invocations don't leak between examples.
|
# Ensure invocations don't leak between examples.
|
||||||
pre_condition { expect(dbl).to_not have_received(:foo), "Leaked method calls from previous examples" }
|
pre_condition { expect(dbl).to_not have_received(:foo), "Leaked method calls from previous examples" }
|
||||||
|
|
||||||
|
# Ensure stubs don't leak between examples.
|
||||||
|
pre_condition do
|
||||||
|
expect { dbl.foo }.to raise_error(Spectator::UnexpectedMessage)
|
||||||
|
dbl._spectator_clear_calls # Don't include previous call in results.
|
||||||
|
end
|
||||||
|
|
||||||
it "matches when a message is received" do
|
it "matches when a message is received" do
|
||||||
expect(dbl).to receive(:foo)
|
expect(dbl).to receive(:foo)
|
||||||
dbl.foo
|
dbl.foo
|
||||||
|
@ -114,6 +126,12 @@ Spectator.describe "Deferred stub expectation DSL" do
|
||||||
# Ensure invocations don't leak between examples.
|
# Ensure invocations don't leak between examples.
|
||||||
pre_condition { expect(fake).to_not have_received(:foo), "Leaked method calls from previous examples" }
|
pre_condition { expect(fake).to_not have_received(:foo), "Leaked method calls from previous examples" }
|
||||||
|
|
||||||
|
# Ensure stubs don't leak between examples.
|
||||||
|
pre_condition do
|
||||||
|
expect { fake.foo }.to raise_error(Spectator::UnexpectedMessage)
|
||||||
|
fake._spectator_clear_calls # Don't include previous call in results.
|
||||||
|
end
|
||||||
|
|
||||||
it "matches when a message is received" do
|
it "matches when a message is received" do
|
||||||
expect(fake).to receive(:foo).and_return(42)
|
expect(fake).to receive(:foo).and_return(42)
|
||||||
fake.foo(:bar)
|
fake.foo(:bar)
|
||||||
|
@ -166,6 +184,12 @@ Spectator.describe "Deferred stub expectation DSL" do
|
||||||
# Ensure invocations don't leak between examples.
|
# Ensure invocations don't leak between examples.
|
||||||
pre_condition { expect(fake).to_not have_received(:foo), "Leaked method calls from previous examples" }
|
pre_condition { expect(fake).to_not have_received(:foo), "Leaked method calls from previous examples" }
|
||||||
|
|
||||||
|
# Ensure stubs don't leak between examples.
|
||||||
|
pre_condition do
|
||||||
|
expect(fake.foo).to eq(42)
|
||||||
|
fake._spectator_clear_calls # Don't include previous call in results.
|
||||||
|
end
|
||||||
|
|
||||||
it "matches when a message is received" do
|
it "matches when a message is received" do
|
||||||
expect(fake).to receive(:foo).and_return(0)
|
expect(fake).to receive(:foo).and_return(0)
|
||||||
fake.foo(:bar)
|
fake.foo(:bar)
|
||||||
|
|
Loading…
Reference in a new issue