Skip to content

Commit f003524

Browse files
committed
2 parents 51de4b9 + ee5a11b commit f003524

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

docs/reference/verifiable.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<!-- toc -->
44
## Contents
55

6-
* [Supported Diff Tools](#supported-diff-tools)<!-- endToc -->
6+
* [Why](#why)
7+
* [How](#how)<!-- endToc -->
78

89

910
## Why
@@ -14,8 +15,36 @@ Verifiable allows you to make objects that are ApprovalTests-aware.
1415

1516
If `verify()` is called with an instance of `Verifiable` it will do a callback allowing you to set up things like output and file types, etc. For example:
1617

17-
snippet: verifiable-example
18+
<!-- snippet: verifiable-example -->
19+
<a id='snippet-verifiable-example'></a>
20+
```swift
21+
final class VerifiableTests: XCTestCase {
22+
func test_verifiable() throws {
23+
try Approvals.verify(SampleMarkdown())
24+
}
25+
}
26+
27+
class SampleMarkdown: Verifiable, CustomStringConvertible {
28+
func getVerifyParameters(_ options: Options) -> VerifyParameters {
29+
VerifyParameters(options.forFile.with(extensionWithDot: ".md"))
30+
}
31+
32+
public var description: String {
33+
"""
34+
| A | B |
35+
|---|---|
36+
| 1 | 2 |
37+
"""
38+
}
39+
}
40+
```
41+
<sup><a href='/ApprovalTests_SwiftTests/VerifiableTests.swift#L8-L28' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifiable-example' title='Start of snippet'>anchor</a></sup>
42+
<!-- endSnippet -->
1843

1944
will produce the following markdown:
2045

21-
include: VerifiableTests.test_verifiable.approved.md
46+
<!-- include: VerifiableTests.test_verifiable.approved.md -->
47+
| A | B |
48+
|---|---|
49+
| 1 | 2 |
50+
<!-- endInclude -->

0 commit comments

Comments
 (0)