toBeFile
in the memos is great, exposes a weakness elsewhere...
#221
Labels
enhancement
New feature or request
In our memoizing API, we don't have any concept of facets, so it's a bit simpler.
StringMemo<T>
toMatchDisk(sub: String = "") : T
toBe(expected: String): T
BinaryMemo<T>
toMatchDisk(sub: String = ""): T
toBeFile(subpath: String): T
I really like this structure. You always have the
toMatchDisk()
which puts it into a selfie-managed file that doesn't care whether it's a string or binary. For strings, you can leave selfie's file management behind and store it as an inline String withtoBe
. And for binary, it makes sense that you might want to put a certain extension on it and view it in a normal file explorer, in which case you saytoBeFile
and you can specify the correct file extension and all that.I think
toBe
for string data is perfect, andtoBeFile
is the perfect analogy for the binary case. The name might not be perfect.toBe
is perfect,toBeFile
piggy backs on that wellFile
part makes clear that it's not inline, it's at this filetoBeFile
sounds a little bit liketoMatchDisk
, although it's quite differentMeh. Good enough.
Facets
What we have now in
1.x
: assertion selfies can have "facets", which makes them a bit more complex than memo selfies.The good thing about this is that you can do fluent chaining
The bad thing is that we never really know what type we're going to get.
We could add
facetBinary("png").toBeFile("screenshot.png")
. The problem is that ideallyexpectSelfie(actual: ByteArray)
should return something which hastoMatchDisk
andtoBeFile
facet
, you should lose the ability to saytoMatchDisk
toMatchDisk
is to dump it and only look at it again if it changestoBe
The text was updated successfully, but these errors were encountered: