Created
February 8, 2015 16:52
-
-
Save bripkens/700bd811a04b801bde13 to your computer and use it in GitHub Desktop.
How can one mock this?
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
(ns config) | |
; to be populated on application start before `service` is required. | |
; how can this def be mocked? | |
(def settings {}) |
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
(ns service | |
(:require [config :refer [settings]])) | |
(println "initializing namespace") | |
(def customer-realm | |
(get-in settings [:auth-rocket :realms :customer])) |
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
(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