Skip to content

Verify JSON validation errors #4

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

Open
Startouf opened this issue Jun 21, 2017 · 0 comments
Open

Verify JSON validation errors #4

Startouf opened this issue Jun 21, 2017 · 0 comments

Comments

@Startouf
Copy link

Startouf commented Jun 21, 2017

Following the https://jsonapi-suite.github.io/jsonapi_errorable/ documentation, it would be great to be able to verify automatically the presence of errors in the JSON response

Suppose I have an error response like this

{
    "errors" => [
        [0] {
              "code" => "unprocessable_entity",
            "status" => "422",
             "title" => "Validation Error",
            "detail" => "Billing_vat_number is not a valid european VAT number",
            "source" => {
                "pointer" => "/data/attributes/billing_vat_number"
            },
              "meta" => {
                "attribute" => "billing_vat_number",
                  "message" => "this is not a valid european VAT number"
            }
        }
    ]
}

a nice Jsonapi spec matcher helper should let us write something like

expect(response).to have_jsonapi_errors([
  'billing_vat_number, :not_eu_vat'
])

What do you think ?

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

1 participant