wikicr/spec/requests/api/sign_ins/create_spec.cr
Arthur Poulet e9bb1cbdc0
Some checks failed
continuous-integration/drone/push Build is failing
spike: try to install & migrate to lucky
2021-10-15 18:44:23 +02:00

34 lines
770 B
Crystal

require "../../../spec_helper"
describe Api::SignIns::Create do
it "returns a token" do
UserToken.stub_token("fake-token") do
user = UserFactory.create
response = ApiClient.exec(Api::SignIns::Create, user: valid_params(user))
response.should send_json(200, token: "fake-token")
end
end
it "returns an error if credentials are invalid" do
user = UserFactory.create
invalid_params = valid_params(user).merge(password: "incorrect")
response = ApiClient.exec(Api::SignIns::Create, user: invalid_params)
response.should send_json(
400,
param: "password",
details: "password is wrong"
)
end
end
private def valid_params(user : User)
{
email: user.email,
password: "password",
}
end