Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quotes within JSON body should not be memorised with escaped double quotes #51

Closed
vinayvinay opened this issue Sep 10, 2013 · 1 comment

Comments

@vinayvinay
Copy link

When I get "/files.json"
# my last_json returns something like:
# "{\"files\":[{\"uuid\":\"7cd19c4d-83c2-4acb-9ed8-44800eee6442\"},{\"uuid\":\"05a8bee9-c7b0-43d8-9aa2-743f5786deb8\"]}"

And I keep the JSON response at "files/0/uuid" as "FILE_UUID"
# this is was memorized as: {:IMAGE_UUID=>"\"7cd19c4d-83c2-4acb-9ed8-44800eee6442\""}
# would expect just "7cd19c4d-83c2-4acb-9ed8-44800eee6442", which is without the escaped strings

When I get "/files/%{FILE_UUID}.json"
# because the above actual memorisation results in a get to url "/files/\"7cd19c4d-83c2-4acb-9ed8-44800eee6442\".json", which is not right
@laserlemon
Copy link
Contributor

The typical usage for this is to assert equality of subsections of JSON, not to pull out Ruby values. While I see that this would be useful, I wouldn't want to change the normal memory so drastically. You could change your step to something like:

step /I get "([^"]*)"/ do |path|
  actually_perform_get parse_json(JsonSpec.remember(path))
end

…assuming you have the JsonSpec::Helpers included.

I hope that helps. Please feel free to submit a pull request to add something like JsonSpec::Memory#remember_and_parse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants