Skip to content

Instantly share code, notes, and snippets.

@owainlewis
Created January 9, 2013 17:05
Show Gist options
  • Save owainlewis/4494844 to your computer and use it in GitHub Desktop.
Save owainlewis/4494844 to your computer and use it in GitHub Desktop.
Testing Compojure applications in the REPL.
(defroutes app
(GET "/" [] "<h1>Index route</h1>")
(route/not-found "<h1>Page not found</h1>"))
(defn fake-request [routes uri method & params]
(let [localhost "127.0.0.1"]
(routes {:server-port 80
:server-name localhost
:remote-addr localhost
:uri uri
:scheme :http
:headers (or params {})
:request-method method})))
;; YOU CAN TEST ROUTES IN THE REPL
(def index-page (fake-request app "/" :get))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment