Skip to content

Instantly share code, notes, and snippets.

@ivancorrales
Created February 17, 2021 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivancorrales/b2c85a27081651793820bafadeca4453 to your computer and use it in GitHub Desktop.
Save ivancorrales/b2c85a27081651793820bafadeca4453 to your computer and use it in GitHub Desktop.
scenario "a user registration fails because required fields are not provcided" {
examples = [
{ fullName ="", username = "", password =""},
{ fullName ="Jane Doe", username = "", password =""},
{ fullName ="Jane Doe", username = "jane@mail.com", password =""},
{ fullName ="Jane Doe", username = "", password ="secret"},
]
when "register the user" {
call signUp {
with {
user = {
fullName = fullName
username = username
password = password
}
}
as = "createUserResponse"
}
}
then "the server returns with a bad request error" {
assert {
assertion = createUserResponse.statusCode==400
}
}
}
scenario "user registration fails when email is already in use" {
given "a user with valid email & password" {
set user {
value = { username = "user@mail.com", password = "secret"}
}
}
when "tries to register the user" {
# omit block `with` because both user and basiApi are in the scope
call signUp {
as = "response"
}
}
then "the server returns with a success status code" {
assert {
assertion = response.statusCode==200
}
}
when "tries to register the same user" {
# omit block `with` because both user and basiApi are in the scope
call signUp {
as = "response"
}
}
then "the server returns with an error" {
assert {
assertion = (
response.statusCode==400 &&
response.body.message=="Failed! Username is already in use!"
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment