mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Allow method calls with unconstrained arguments
Workaround for the expect-receive DSL syntax to allow methods to be called without matching arguments.
This commit is contained in:
parent
c91e288f61
commit
6e57a1c44a
4 changed files with 40 additions and 3 deletions
|
@ -6,6 +6,7 @@ Spectator.describe "Deferred stub expectation DSL" do
|
|||
# Ensure the original is never called.
|
||||
stub abstract def foo : Nil
|
||||
stub abstract def foo(arg) : Nil
|
||||
stub abstract def value : Int32
|
||||
end
|
||||
|
||||
let(dbl) { double(:dbl) }
|
||||
|
@ -15,6 +16,11 @@ Spectator.describe "Deferred stub expectation DSL" do
|
|||
dbl.foo
|
||||
end
|
||||
|
||||
it "returns the correct value" do
|
||||
expect(dbl).to receive(:value).and_return(42)
|
||||
expect(dbl.value).to eq(42)
|
||||
end
|
||||
|
||||
it "matches when a message isn't received" do
|
||||
expect(dbl).to_not receive(:foo)
|
||||
end
|
||||
|
@ -54,6 +60,11 @@ Spectator.describe "Deferred stub expectation DSL" do
|
|||
fake.foo(:bar)
|
||||
end
|
||||
|
||||
it "returns the correct value" do
|
||||
expect(fake).to receive(:foo).and_return(42)
|
||||
expect(fake.foo).to eq(42)
|
||||
end
|
||||
|
||||
it "matches when a message isn't received" do
|
||||
expect(fake).to_not receive(:foo)
|
||||
end
|
||||
|
@ -64,7 +75,7 @@ Spectator.describe "Deferred stub expectation DSL" do
|
|||
end
|
||||
|
||||
it "matches when a message without arguments is received" do
|
||||
expect(fake).to_not receive(:foo).with(:bar)
|
||||
expect(fake).to_not receive(:foo).with(:bar).and_return(42)
|
||||
fake.foo
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue