Skip to content

Instantly share code, notes, and snippets.

@bripkens
Created February 8, 2015 16:52
Show Gist options
  • Save bripkens/700bd811a04b801bde13 to your computer and use it in GitHub Desktop.
Save bripkens/700bd811a04b801bde13 to your computer and use it in GitHub Desktop.
How can one mock this?
(ns config)
; to be populated on application start before `service` is required.
; how can this def be mocked?
(def settings {})
(ns service
(:require [config :refer [settings]]))
(println "initializing namespace")
(def customer-realm
(get-in settings [:auth-rocket :realms :customer]))
(ns service-test
(:require [service :as service]))
(defn- reload-with-settings [settings func]
(with-redefs [clojurewerkz.gizmo.config/settings settings]
(require 'user-management.auth-rocket-test :reload)
(func)))
(testing "the service"
; this is the magic part, how do you do this?
(update-the-settings-and-reload-service-with-config {:auth-rocket {:realms {:customer "abc"}}})
(is (= "abc" auth/customer-realm)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment