Skip to content

Instantly share code, notes, and snippets.

@hpjaj
Last active August 1, 2019 23:36
Show Gist options
  • Save hpjaj/2f1be22e1bca1d694a574812e97f32b4 to your computer and use it in GitHub Desktop.
Save hpjaj/2f1be22e1bca1d694a574812e97f32b4 to your computer and use it in GitHub Desktop.

Request Spec

# vets-api/spec/request/email_request_spec.rb

describe 'GET /v0/profile/email' do
  it 'should match the email schema' do
    VCR.use_cassette('evss/pciu/email') do
      get '/v0/profile/email', nil, auth_header

      expect(response).to match_response_schema('email_address_response')
    end
  end
end

Associated Support Response Schema

// vets-api/spec/support/schemas/email_address_response.json

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "definitions": {},
  "properties": {
    "data": {
      "properties": {
        "attributes": {
          "properties": {
            "email": {
              "type": "string"
            },
            "effective_at": {
              "type": "string"
            }
          },
          "type": "object"
        },
        "id": {
          "type": "string"
        },
        "type": {
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "type": "object"
}

Derived from Endpoint Response

{
  "data": {
    "id": "",
    "type": "evss_pciu_email_address_responses",
    "attributes": {
      "email": "john@example.com",
      "effective_at": "2018-02-27T14:41:32.283Z"
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment