redding / assert

Assertion style testing framework.
https://github.com/redding/assert
MIT License
10 stars 1 forks source link

accumulate: simplify `capture_result` in both test and context #277

Closed kellyredding closed 8 years ago

kellyredding commented 8 years ago

This reworks the capture_result behavior in both the Test and Context objects. This is part of the cleaning up now that we are accumulating test run data instead of storing it on the test objs.

This Context capture removes an unnecessary yield call and instead builds the result itself from given/static inputs. There is no need to go through the ceremony of yielding to the given block to get a result. Because the test and caller params are static/common to all results, we only need to be given the result class and msg. This simplifies everywhere we call capture_result and should give a slight performance improvement. Plus there is no reason to call to the test's capture_result as the test doesn't do any extra logic on capture (it just calls the callback which we can do directly). Note: I updated the context's result callback to return the result so that the legacy behavior of capture_result returning the result was maintained.

The Test capture is now a private method b/c the Context no longer needs to call it. Like the Context, it has been simplified to just take a result class and exception. We now store the result callback on the instance and the test is static/common to all results. This simplifies everywhere we call capture_results. In addition the test attrs were reorganized a bit now that capture result is a private method.

@jcredding ready for review.

jcredding commented 8 years ago

@kellyredding - I like the simplifications, good stuff :boom: