[rspec-users] Test JSON with Cucumber

Hagar Chen lists at ruby-forum.com
Thu Jun 20 10:48:05 UTC 2013


Hi, I have a question about writing scenarios in cucumber that include a
JSON.
I have the following scenario in cucumber:

Scenario Outline:
  Given I send and accept JSON
  And I send a POST request to <path> with the following:
  """
   {
    "field1":"text",
    "emails":[
        {
            "work":"test at test.com",
            "private":"home at test.com",
        },
    ]
   }
   """
  Then The response status should be "200"

Examples:
| path  |
| /req  |

I want the JSON to be in the examples, so that I can run the scenario 
several times with different JSONs and verify that I get the correct 
response status.
I want the scenario to look something like this:

Scenario Outline:
  Given I send and accept JSON
  And I send a POST request to <path> with the following:
  """
   <JSON>
   """
  Then The response status should be "200"

how do I add the JSON to the examples?

-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list