Skip to content

Commit

Permalink
d Sketch out docs for possible Custom Namer feature
Browse files Browse the repository at this point in the history
This is to build on #130

Co-Authored-By: Llewellyn Falco <[email protected]>
  • Loading branch information
claremacrae and isidore committed Apr 1, 2021
1 parent d211932 commit d63161e
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions doc/how_tos/CreateCustomNamer.md
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)

0 comments on commit d63161e

Please sign in to comment.