-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
d Sketch out docs for possible Custom Namer feature
This is to build on #130 Co-Authored-By: Llewellyn Falco <[email protected]>
- Loading branch information
1 parent
d211932
commit d63161e
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<a id="top"></a> | ||
|
||
# How to Create a Custom Namer - NOT IMPLEMENTED YET! | ||
|
||
toc | ||
|
||
## Overview | ||
|
||
Warning - this is NOT IMPLEMENTED YET! | ||
|
||
The easiest way to create a custom namer is by modifying the parts of CustomizableNamer. | ||
|
||
CustomizableNamer has two main methods: | ||
|
||
* `getApprovedFile(std::string extensionWithDot)` | ||
This works by composing: | ||
`{TestFolderForApproved}`/`{RelativePathOfSourceDirectoryFromSourceRootForApproved}`/`{FileNameAndTestName}`.approved.`{FileExtension}` | ||
|
||
* `getReceivedFile(std::string extensionWithDot)` | ||
This works by composing: | ||
`{TestFolderForReceived}`/`{RelativePathOfSourceDirectoryFromSourceRootForReceived}`/`{FileNameAndTestName}`.received.`{FileExtension}` | ||
|
||
## Overriding Parts | ||
|
||
Both the getApprovedFile and getReceivedFile methods can be overridden, as well as any of the composable parts. By default, anything with a for received/apprroved simply calls the base. | ||
|
||
For example: | ||
|
||
```cpp | ||
auto myNamer = CustomizableNamer() | ||
.withTestFolder([]{return "C:/ApprovalFiles";}) | ||
.withTestFolderForReceived([]{return getTestFolder() + "/received"}); | ||
|
||
Approvals::verify("Hello World", Options().withNamer(myNamer)); | ||
``` | ||
{TestFolder}/{RelativePathOfSourceDirectoryFromSourceRoot}/{FileNameAndTestName}.approved.{FileExtension} | ||
{TestFolder}/{ReceivedOrApproved}/{RelativePathOfSourceDirectoryFromSourceRoot}/{SourceFileName}-{SectionNames}.{FileExtension} | ||
--- | ||
[Back to User Guide](/doc/README.md#top) |