mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Handle case with typeless block
Fixes syntax: `stub method(&block)` To stub a block with args, use: `stub method(&block : Type -> Type)` Addresses https://github.com/icy-arctic-fox/spectator/issues/42
This commit is contained in:
parent
cbe05cd637
commit
eb8bd88927
2 changed files with 87 additions and 16 deletions
43
spec/issues/github_issue_42_spec.cr
Normal file
43
spec/issues/github_issue_42_spec.cr
Normal file
|
@ -0,0 +1,43 @@
|
|||
require "../spec_helper"
|
||||
|
||||
abstract class SdkInterface
|
||||
abstract def register_hook(name, &block)
|
||||
end
|
||||
|
||||
class Example
|
||||
def initialize(@sdk : Sdk)
|
||||
end
|
||||
|
||||
def configure
|
||||
@sdk.register_hook("name") do
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Sdk < SdkInterface
|
||||
def initialize
|
||||
end
|
||||
|
||||
def register_hook(name, &block)
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
Spectator.describe Example do
|
||||
mock Sdk do
|
||||
stub register_hook(name, &block)
|
||||
end
|
||||
|
||||
describe "#configure" do
|
||||
it "registers a block on configure" do
|
||||
sdk = Sdk.new
|
||||
example_class = Example.new(sdk)
|
||||
allow(sdk).to receive(register_hook())
|
||||
|
||||
example_class.configure
|
||||
|
||||
expect(sdk).to have_received(register_hook()).with("name")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue