Last active
March 23, 2017 16:01
-
-
Save Thomvis/805c1285115a1a259bfd1b1115a0086e to your computer and use it in GitHub Desktop.
A https://github.com/krzysztofzablocki/Sourcery stencil for https://github.com/AirHelp/Mimus mock generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Mimus | |
{% for type in types.protocols %} | |
{% if type.annotations.genMock %} | |
class {{ type.name }}Mock: {{ type.name }}, Mock { | |
var storage: [RecordedCall] = [] | |
{% for method in type.allMethods %} | |
func {{ method.name }} { | |
{% if method.parameters.count == 0 %} | |
recordCall(withIdentifier: "{{ method.selectorName }}") | |
{% else %} | |
recordCall(withIdentifier: "{{ method.selectorName }}", arguments: [{% for p in method.parameters %}{{ p.name }}{% if not forloop.last %}, {% endif %}{% endfor %}]) | |
{% endif %} | |
} | |
{% endfor %} | |
} | |
{% endif %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This generates