Add tests for the `force-parse` feature
MODIFY
SourceryTests/Parsing/VerifierSpec.swift
SourceryTests/Parsing/VerifierSpec.swift
@@ -7,19 +7,31 @@ class VerifierSpec: QuickSpec {
override func spec() {
describe("Verifier") {
it("allows empty strings") {
- expect(Verifier.canParse(content: "")).to(equal(Verifier.Result.approved))
+ expect(Verifier.canParse(content: "", path: Path("/"))).to(equal(Verifier.Result.approved))
}
it("rejects files generated by Sourcery") {
let content = Sourcery.generationMarker + "\n something\n is\n there"
- expect(Verifier.canParse(content: content)).to(equal(Verifier.Result.isCodeGenerated))
+ expect(Verifier.canParse(content: content, path: Path("/"))).to(equal(Verifier.Result.isCodeGenerated))
+ }
+
+ it("rejects files generated by Sourcery when a force parse extension is defined but doesn't match file") {
+ let content = Sourcery.generationMarker + "\n something\n is\n there"
+
+ expect(Verifier.canParse(content: content, path: Path("/file.swift"), forceParse: ["toparse"])).to(equal(Verifier.Result.isCodeGenerated))
+ }
+
+ it("doesn't reject files generated by Soucery but that we want to force the parsing for") {
+ let content = Sourcery.generationMarker + "\n something\n is\n there"
+
+ expect(Verifier.canParse(content: content, path: Path("/file.toparse.swift"), forceParse: ["toparse"])).to(equal(Verifier.Result.approved))
}
it("rejects file containing conflict marker") {
let content = ["\n<<<<<\n", "\n>>>>>\n"]
- content.forEach { expect(Verifier.canParse(content: $0)).to(equal(Verifier.Result.containsConflictMarkers)) }
+ content.forEach { expect(Verifier.canParse(content: $0, path: Path("/"))).to(equal(Verifier.Result.containsConflictMarkers)) }
}
}
}

Add tests for the `force-parse` feature