Skip to content

Instantly share code, notes, and snippets.

@ahjones
Created June 1, 2012 22:41
Show Gist options
  • Save ahjones/2855541 to your computer and use it in GitHub Desktop.
Save ahjones/2855541 to your computer and use it in GitHub Desktop.
Rest client driver with Clojure and Midje
(ns logging.web-test
(:use midje.sweet
ring.mock.request
my-thing.web)
(:import [com.github.restdriver.clientdriver
ClientDriverFactory
ClientDriverRule
RestClientDriver]))
(def driver (.. (ClientDriverFactory.) (createClientDriver 8123)))
(fact (app (body (request :post "/thing") (slurp "test/resources/valid.json")))
=> (contains {:status 201})
(against-background
(around :contents
(do
(.addExpectation driver
(RestClientDriver/onRequestTo "/resource")
(RestClientDriver/giveEmptyResponse))
?form
(try (.verify driver) (catch Exception e (fact e => nil)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment