In our project we have a situation where some Gherkin steps simulate JSON responses.
These JSON response are added to steps in form of a DocString.
Unfortunately, if a JSON string property contains an escaped quote character, then step?.docString?.literal strips it away; E.g.:
"String with a \"quote\" or two"
becomes
"String with a "quote" or two"
Which is no longer valid JSON.
I couldn't find an easy solution to fix the escaping, or why it was removed to begin with.
But since there are tests explicitly defining the current behavior, I instead I added a rawLiteral property to the DocString struct.
Please have a look at the added unit test for clarification.
In our project we have a situation where some Gherkin steps simulate JSON responses. These JSON response are added to steps in form of a DocString.
Unfortunately, if a JSON string property contains an escaped quote character, then
step?.docString?.literal
strips it away; E.g.:"String with a \"quote\" or two"
becomes"String with a "quote" or two"
Which is no longer valid JSON.I couldn't find an easy solution to fix the escaping, or why it was removed to begin with. But since there are tests explicitly defining the current behavior, I instead I added a
rawLiteral
property to theDocString
struct.Please have a look at the added unit test for clarification.