-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom initializers causing errors in generated mock file #54
Comments
@bobbelkl, I experienced the same issue: #6 (comment) Right now I'm waiting for the refactoring branch to be merged and ready to test. |
Hey guys, I just merged the overhaul PR, but I would like to wait with the release until we fix these issues. However you can give it a try, just add the CocoaPods dependency as a git repository, targeting the |
@TadeasKriz, I re-generated mocks file for the following class using Cuckoo from the commit c9fce39. Still no success with generated closure. class MyClass {
func objects(byFilter filter: String) -> String {
return ""
}
} class MockMyClass: MyClass, Cuckoo.Mock {
typealias Stubbing = __StubbingProxy_MyClass
typealias Verification = __VerificationProxy_MyClass
let manager = Cuckoo.MockManager()
private var observed: MyClass?
required override init() {
}
required init(spyOn victim: MyClass) {
observed = victim
}
override func objects(byFilter filter: String) -> String {
return manager.call("objects(byFilter: String) -> String", parameters: (filter), original: observed.map { o in return { (byFilter filter: String) -> String in o.objects(byFilter: filter) } })
}
struct __StubbingProxy_MyClass: Cuckoo.StubbingProxy {
...
}
struct __VerificationProxy_MyClass: Cuckoo.VerificationProxy {
...
}
} The following declaration is not a valid closure syntax: (byFilter filter: String) -> String |
Works for me! Thanks! |
@bobbelkl Awesome! |
Ok, found some issues. In my eyes the more elegant solution would be ignoring the custom initializers in classes. If you really need them you can still use "spyOn". |
We can't ignore custom initializers, because when initializing the mock, we have to call A possible way to solve this is, that we don't need the |
@bobbelkl I just got an idea how to workaround the |
You're right, i forgot about |
@bobbelkl Here it is, try the |
Great work |
@TadeasKriz, now the generator works fine with all examples I shown before. |
Version 0.7.0 released! Yay! |
following code
generates this:
removing the double designation doesn't help
The text was updated successfully, but these errors were encountered: