Escape apostrophes in generated snippets#1888
Conversation
Signed-off-by: Matthew Stanton <stantonmatthewj@gmail.com>
luke-hill
left a comment
There was a problem hiding this comment.
Unfortunately this is what we previously had and we refactored it out many many moons ago.
The desired output here is to instead use double quoted snippets. Which is the previous behaviour. So we should use single quotes (If we can), then failing that, use double quotes. This avoids any issues.
Signed-off-by: Matthew Stanton <stantonmatthewj@gmail.com>
|
Updated this to keep single-quoted snippets when the generated expression has no apostrophe, and switch to double-quoted snippets when it does. I reran the full RSpec suite and RuboCop on the touched files after pushing this. |
Signed-off-by: Matthew Stanton <stantonmatthewj@gmail.com>
Signed-off-by: Matthew Stanton <stantonmatthewj@gmail.com>
| expect(snippet.to_s).to eq(cucumber_output) | ||
| end | ||
|
|
||
| it 'uses double quotes for generated cucumber expression snippets with apostrophes' do |
There was a problem hiding this comment.
These aren't cucumber expression snippets. They're all regular snippets
There was a problem hiding this comment.
You are right; I renamed those examples in 06591c7 so they refer to generated snippets rather than cucumber expression snippets.
Summary
Fixes #1710
Verification
bundle exec rspec spec/cucumber/glue/snippet_spec.rbbundle exec rspecbundle exec cucumberbundle exec rubocopgit diff --checkLocal repros now print
Then("Lucy hears Sean's message")andThen('Lucy hears trailing \\'), and both generated snippets compile with Ruby.