noir-clojure / lib-noir

A set of libraries for ring apps, including stateful sessions.
Eclipse Public License 1.0
483 stars 47 forks source link

replacement for with-noir #71

Closed ccfontes closed 11 years ago

ccfontes commented 11 years ago

With with-noir it was possible to handle sessions and cookies when doing tests. What is the replacement strategy now while using ring/compojure + lib-noir?

(defmacro with-noir
  "Executes the body within the context of Noir's bindings"
  [& body]
  `(binding [options/*options* options/default-opts
             vali/*errors* (atom {})
             session/*noir-session* (atom {})
             session/*noir-flash* (atom {})
             cookies/*new-cookies* (atom {})
             cookies/*cur-cookies* (atom {})]
     ~@body))
yogthos commented 11 years ago

The dynamic vars still have the same names and live in the same namespaces in lib-noir, so that macro should work out of the box I think.

ccfontes commented 11 years ago

Yes it works. I removed vali/*errors* and options/*options*, since I'm not using them, so cannot be sure about those two.

Any plans on supporting this?

yogthos commented 11 years ago

There's no reason not to put it in lib-noir, at the very least it will make it easy to find. :)

yogthos commented 11 years ago

@ccfontes I added the test namespace to lib-noir, it will be part of the next push on clojars

ccfontes commented 11 years ago

Great! It's a win for less LOC