Skip to content

Instantly share code, notes, and snippets.

@erez-rabih
Last active June 15, 2019 05:14
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 erez-rabih/074156d42393db2397069188e53b1617 to your computer and use it in GitHub Desktop.
Save erez-rabih/074156d42393db2397069188e53b1617 to your computer and use it in GitHub Desktop.
(deftest register-test
(let [email "my@email.com"
response (request :post "/register" {:email email})]
(testing "http response"
(testing "should return 201 status code"
(is (= 201 (:status response))))
(testing "should return the created user in response body"
(is (= email (-> response :body :email)))
(is (integer? (-> response :body :id))))
(testing "should not return the confirmation token in the response body"
(is (not (contains? (:body response) :confirmation_token)))))
(testing "should create the user in the database"
(let [created-user (user/find-by-email email)]
(is (not (nil? created-user)))
(testing "should have a confirmation token"
(is (not (nil? (:confirmation_token created-user)))))))
(testing "should send a confirmation email"
(is (confirmation-sent? email)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment