Skip to content

Instantly share code, notes, and snippets.

@ebaxt
Last active December 19, 2015 08:29
Show Gist options
  • Save ebaxt/5925835 to your computer and use it in GitHub Desktop.
Save ebaxt/5925835 to your computer and use it in GitHub Desktop.
Mocking out friend current-authentication
(defn with-test-auth
([] (with-test-auth {}))
([credentials]
(fn [f]
(with-redefs-fn
{#'cemerick.friend/current-authentication
(fn [] (merge {:identity "test",
:username "test",
:email "foo@bar.com"} 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