mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Test mixing block and keyword stubs
This commit is contained in:
parent
d40040c8ee
commit
3fa6baea4d
1 changed files with 38 additions and 0 deletions
|
@ -105,6 +105,44 @@ Spectator.describe "Double DSL" do
|
|||
expect(dbl.foo).to eq("no stub")
|
||||
end
|
||||
end
|
||||
|
||||
context "mixing keyword arguments" do
|
||||
double(:test6, foo: "kwargs", bar: 42) do
|
||||
stub def foo
|
||||
"block"
|
||||
end
|
||||
|
||||
stub def baz
|
||||
"block"
|
||||
end
|
||||
|
||||
stub def baz(value)
|
||||
"block2"
|
||||
end
|
||||
end
|
||||
|
||||
subject(dbl) { double(:test6) }
|
||||
|
||||
it "overrides the keyword arguments with the block methods" do
|
||||
expect(dbl.foo).to eq("block")
|
||||
end
|
||||
|
||||
it "falls back to the keyword argument value for mismatched arguments" do
|
||||
expect(dbl.foo(42)).to eq("kwargs")
|
||||
end
|
||||
|
||||
it "can call methods defined only by keyword arguments" do
|
||||
expect(dbl.bar).to eq(42)
|
||||
end
|
||||
|
||||
it "can call methods defined only by the block" do
|
||||
expect(dbl.baz).to eq("block")
|
||||
end
|
||||
|
||||
it "can call methods defined by the block with different signatures" do
|
||||
expect(dbl.baz(42)).to eq("block2")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "double naming" do
|
||||
|
|
Loading…
Reference in a new issue