Source

rest-api-blueprint / restapiblueprint / features / update_person.feature

Full commit
Feature: Update a person
  As an API client
  I want to be able to update the email address for a person

  Background: Set server name, reset, and add a person
    Given I am using server "http://localhost:5000/v1"
    And I set Accept header to "application/json"
    When I send a DELETE request to "people"
    Then the response status should be "200"
    When I send a PUT request to "people/fred"
    Then the response status should be "200"

  Scenario: Update person with comment
    Given I set Content-Type header to "application/json"
    When I send a PATCH request to "people/fred":
      """
      {"comment": "this person is very special to me"}
      """
    Then the response status should be "200"
    When I send a GET request to "people/fred"
    Then the response status should be "200"
    And the JSON at path "result.comment" should be "this person is very special to me"

  Scenario: Update person with valid email address
    Given I set Content-Type header to "application/json"
    When I send a PATCH request to "people/fred":
      """
      {"email": "b@c.d"}
      """
    Then the response status should be "200"
    When I send a GET request to "people/fred"
    Then the response status should be "200"
    And the JSON at path "result.email" should be "b@c.d"

  Scenario: Update person with invalid email address
    Given I set Content-Type header to "application/json"
    When I send a PATCH request to "people/fred":
      """
      {"email": "invalid"}
      """
    Then the response status should be "400"
    And the JSON at path "message" should be "Invalid partial specification for a person"

  Scenario: Update person with an additional invalid field
    Given I set Content-Type header to "application/json"
    When I send a PATCH request to "people/fred":
      """
      {"blah": "blah"}
      """
    Then the response status should be "400"
    And the JSON at path "message" should be "Invalid partial specification for a person"

Scenario: Update person with zero fields
    Given I set Content-Type header to "application/json"
    When I send a PATCH request to "people/fred":
      """
      {}
      """
    Then the response status should be "200"

  Scenario: Update full person with only a comment
    Given I set Content-Type header to "application/json"
    When I send a POST request to "people/fred":
      """
      {"comment": "this person is very special to me"}
      """
    Then the response status should be "400"
    And the JSON at path "message" should be "Invalid specification for a person"

  Scenario: Update full person with only a valid email
    Given I set Content-Type header to "application/json"
    When I send a POST request to "people/fred":
      """
      {"email": "a@b.c"}
      """
    Then the response status should be "400"
    And the JSON at path "message" should be "Invalid specification for a person"

  Scenario: Update full person with comment and invalid email
    Given I set Content-Type header to "application/json"
    When I send a POST request to "people/fred":
      """
      {
        "email": "abc",
        "comment": "blah"
      }
      """
    Then the response status should be "400"
    And the JSON at path "message" should be "Invalid specification for a person"

  Scenario: Update full person with comment and valid email
    Given I set Content-Type header to "application/json"
    When I send a POST request to "people/fred":
      """
      {
        "email": "a@x.y",
        "comment": "foobar"
      }
      """
    Then the response status should be "200"
    When I send a GET request to "people/fred"
    Then the response status should be "200"
    And the JSON at path "result.email" should be "a@x.y"
    And the JSON at path "result.comment" should be "foobar"