Using Cuckoo 1.4.1, I get the error
Global function 'stub(_:block:)' requires that 'DeepFileManager' conform to 'Mock'
I don't know how to proceed, because the instance passed to the stub
function was created from the class in GeneratedMocks.swift
. The reference to DeepFileManager
is the class that is mocked.
So it's a mystery to me why Swift 4 would complain about the conformance of the superclass of the instance I've passed to it. Can you lead me out of this conundrum?
Here's the code for the test:
class RecordingTests: QuickSpec {
override func spec() {
let FAKE_ID = "String";
let mockFileManager: MockDeepFileManager = MockDeepFileManager()
let cut = Recording(id: FAKE_ID, date: nil, status: nil, device: nil, deviceId: nil, deviceName: nil, fileManager: mockFileManager)
describe("A recording") {
context("when it's not on disk") {
it("responds that filePresent is false") {
stub(mockFileManager) {stub in
when(stub.fileExists(audioId: FAKE_ID)).then()
}
expect(cut.filePresent()).to(equal(false))
verify(mockFileManager).fileExists(audioId: "Matchable")
}
}
}
}
And here's the declaration of MockDeepFileManager
from GeneratedMocks.swift
:
class MockDeepFileManager: DeepFileManager, Cuckoo.ClassMock {
question from:
https://stackoverflow.com/questions/65672067/using-cuckoo-with-swift-why-is-the-call-to-stub-complaining-that-the-class-fr 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…