Tyler-Keith-Thompson / CucumberSwift

A lightweight swift Cucumber implementation
https://tyler-keith-thompson.github.io/CucumberSwift/documentation/cucumberswift/
MIT License
74 stars 19 forks source link

Exposing a rawLiteral on DocString for situation where sanitization is too eager #92

Closed RockLobster closed 1 year ago

RockLobster commented 1 year ago

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.

Tyler-Keith-Thompson commented 1 year ago

Apologies for the late reply thank you for the PR! I'm unsure of my motivations at the time, but this seems totally reasonable to me.

RockLobster commented 1 year ago

Thank you! 🙂