Last active
December 19, 2015 08:29
-
-
Save ebaxt/5925835 to your computer and use it in GitHub Desktop.
Mocking out friend current-authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn with-test-auth | |
([] (with-test-auth {})) | |
([credentials] | |
(fn [f] | |
(with-redefs-fn | |
{#'cemerick.friend/current-authentication | |
(fn [] (merge {:identity "test", | |
:username "test", | |
:email "[email protected]"} credentials))} | |
f)))) | |
(use-fixtures :each (with-test-auth)) | |
;; We can now test code that relies on (cemerick.friend/current-authentication) to retrieve the authenticated user | |
(deftest current-authentication-is-now-set | |
(is (not (empty? (cemerick.friend/current-authentication))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment