Skip to content

Instantly share code, notes, and snippets.

@hchood
Created March 15, 2016 12:22
Show Gist options
  • Save hchood/043bb5b9f8ede627285b to your computer and use it in GitHub Desktop.
Save hchood/043bb5b9f8ede627285b to your computer and use it in GitHub Desktop.
# /spec/requests/v1/users_requests_spec.rb
context 'with errors' do
context 'such as a pre-existing email' do
it 'returns a 422 response and JSON for errors' do
existing_user = create(:user)
user_attributes = {
user: {
email: existing_user.email,
password: user.password_digest
}
}.to_json
post(users_url, user_attributes, accept_headers)
expect(response).to have_http_status :unprocessable_entity
expect(json_value_at_path('errors/0')).to eq 'Email has already been taken'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment