collectiveidea / json_spec

Easily handle JSON in RSpec and Cucumber
rubygems.org/gems/json_spec
MIT License
919 stars 114 forks source link

Allow to memorize parsed values #94

Open flexoid opened 8 years ago

flexoid commented 8 years ago

Solves this [#51] issue

Test from updated README

If the value should be parsed before memorizing, "parsed" modifier can be used. For example:

Response data:

[
  {
    "uuid": "ad796a4b",
    "url": "/entities/ad796a4b"
  }
]
Given I keep the JSON at "0/uuid" as parsed "UUID"

Now %{UUID} will be replaced with ad796a4b instead of "ad796a4b", so it can be interpolated into the string:

Then the JSON should be:
"""
[
  {
    "uuid": "%{UUID}",
    "url": "/entities/%{UUID}"
  }
]
"""