Closed oubiwann closed 8 years ago
Seems fine, a PR would be great - thanks!
Well, I'd forgotten about the custom selectors (which are vectors), so the solution I've put together is different than the simple proposition in the ticket description. That being said, this is much less hacky (so I'm happy about that).
It did require a change to the private function selector-type
, though -- the check for :key-values
was originally vector?
and ensuring there were an even number of elements. This would obviously conflict with an even number of exceptions. So I added a third requirement: every other element must be a keyword for it to be a :key-values
. This then left room for a new selector type: :class-names
.
To pair with that, I added a new selector-matches?
method that checks that the given object is an instance of at least one of the elements in the vector of exception classes.
Caveat about midje: I've only used it once before! Let me know if you'd prefer the added tests to done differently :-) (as expected, though: added tests fail without the changes and pass with them).
Note that when I submit the PR, I'll paste some of this text there for reference ...
Ah, one thing I missed -- updating the README. I'll push an update shortly ...
I'd like to be able to do something like this:
A possibly naive solution jumps to mind: check i
exception-selector
withvector?
, and if so,(map #(with-handler ... % ...) exception-selector)
Thoughts?
(If you're okay with the proposition, I can branch & submit PR)