slagyr / speclj

pronounced "speckle": a TDD/BDD framework for Clojure.
MIT License
459 stars 58 forks source link

Add support for around-all #86

Closed ryankinderman closed 10 years ago

ryankinderman commented 10 years ago

Any thoughts on this?

ryankinderman commented 10 years ago

Ping.

I've got some other thoughts related to hooks that I'd like to run by you/work on, but want to get past this small one first.

Let me know if I can do anything to make it easier to review/accept this. Thanks!

slagyr commented 10 years ago

Arg! Sorry I didn't reply sooner. Github emails were getting marked as spam!

This is interesting. I tried to add around-all when I added all the other *-all components. At the time, I concluded that around-all was either too hard or not useful, or maybe a combination of both. I don't recall the reason I left it out.

What do you use it for?

ryankinderman commented 10 years ago

No worries; thanks for getting back to me.

We have some code that needs to reset a piece of state for the duration of the tests, but set it back afterwards. We'd like to use binding, but without something like around-all, we're forced to use the low-level push-thread-bindings function in a before-all, and then have a separate pop call in an after-all. It's a bit awkward.

ryankinderman commented 10 years ago

For example, right now we've got code something like this:

(describe "a feature"
  (before-all
    (push-thread-bindings {some-ns/*configuration* {:spanky-new-config-value 123}}))

  (after-all
    (pop-thread-bindings)))

But, since we'd prefer not to have to call push-thread-bindings directly, we'd like the code to look more like:

(describe "a feature"
  (around-all [context]
    (binding [some-ns/*configuration* {:spanky-new-config-value 123}]
      (context))))
trptcolin commented 10 years ago

This works great - thanks!