Skip to content

Commit 47c019d

Browse files
committed
F!! Adding options to VelocityApprovals
1 parent 2af1e50 commit 47c019d

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

approvaltests-tests/src/test/java/org/approvaltests/DocumentHelpersTest.listAllVerifyFunctions.approved.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,3 @@
5353
* JsonApprovals. [verifyAsJson ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/JsonApprovals.java#L29-L32) (Object,Function1)
5454
* JsonApprovals. [verifyJson ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/JsonApprovals.java#L17-L20) (String)
5555
* VelocityApprovals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/velocity/VelocityApprovals.java#L16-L19) (ContextAware)
56-
* VelocityApprovals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/velocity/VelocityApprovals.java#L24-L27) (ContextAware,String)

approvaltests/src/main/java/org/approvaltests/velocity/VelocityApprovals.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,28 @@ public static void verify(ContextAware context)
1515
}
1616
public static void verify(ContextAware context, Options options)
1717
{
18-
verify(context, ".txt", options);
18+
ApprovalNamer namer = Approvals.createApprovalNamer();
19+
String fileExtentsionWithDot = options.forFile().getFileExtension();
20+
String file = namer.getSourceFilePath() + namer.getApprovalName() + ".template" + fileExtentsionWithDot;
21+
FileUtils.createIfNeeded(file);
22+
String text = VelocityParser.parseFile(file, context);
23+
Approvals.verify(text, options);
1924
}
25+
/**
26+
* @deprecated use {@code Options.forFile().withExtension(fileExtensionWithDot) }
27+
*/
28+
@Deprecated
2029
public static void verify(ContextAware context, String fileExtentsionWithDot)
2130
{
2231
verify(context, fileExtentsionWithDot, new Options());
2332
}
33+
/**
34+
* @deprecated use {@code Options.forFile().withExtension(fileExtensionWithDot) }
35+
*/
36+
@Deprecated
2437
public static void verify(ContextAware context, String fileExtentsionWithDot, Options options)
2538
{
26-
ApprovalNamer namer = Approvals.createApprovalNamer();
27-
String file = namer.getSourceFilePath() + namer.getApprovalName() + ".template" + fileExtentsionWithDot;
28-
FileUtils.createIfNeeded(file);
29-
String text = VelocityParser.parseFile(file, context);
3039
options = options.forFile().withExtension(fileExtentsionWithDot);
31-
Approvals.verify(text, options);
40+
verify(context, options);
3241
}
3342
}

todo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Code
2+
* Clean up duplication in CheckedExceptionsTest and TestFileNamesTest
23
* Approvals.options.forName.asMachineNameSpecificTest().onlyForEnvironments("Larss-Air.lan", "macbook13").run(this::extracted);
34
* better default FrontloadedReporter to handle CI
45
* NamedEnvironment with execute around pattern?
56

67
* easier API for custom file name & location?! (issue 2, 51)
78
** Options for file path
89
** update mrunit and fix tests
9-
** VelocityApprovals doesn't know about Options yet
1010

1111
* Think about removing MethodExcecutionPath
1212
* remove all warnings

0 commit comments

Comments
 (0)