2022-02-22 01:17:44 +00:00
|
|
|
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
|
2022-03-19 23:20:15 +00:00
|
|
|
# mock Sdk do
|
|
|
|
# stub register_hook(name, &block)
|
|
|
|
# end
|
2022-02-22 01:17:44 +00:00
|
|
|
|
|
|
|
describe "#configure" do
|
2022-03-19 23:20:15 +00:00
|
|
|
xit "registers a block on configure", pending: "Mock redesign" do
|
2022-02-22 01:17:44 +00:00
|
|
|
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
|