Skip to content

Instantly share code, notes, and snippets.

@ebaxt
Last active December 19, 2015 08:29

Revisions

  1. ebaxt revised this gist Jul 4, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.clj
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    f))))


    (use-fixtures :each (h/with-test-auth))
    (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
  2. ebaxt revised this gist Jul 4, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.clj
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,6 @@

    (use-fixtures :each (h/with-test-auth))

    ;; We can not test code that uses (cemerick.friend/current-authentication) to retrieve the authenticated user
    ;; 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)))))
  3. ebaxt created this gist Jul 4, 2013.
    17 changes: 17 additions & 0 deletions gistfile1.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    (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 (h/with-test-auth))

    ;; We can not test code that uses (cemerick.friend/current-authentication) to retrieve the authenticated user
    (deftest current-authentication-is-now-set
    (is (not (empty? (cemerick.friend/current-authentication)))))