redding / assert

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

make the "methods macros" more efficient #140

Closed kellyredding closed 11 years ago

kellyredding commented 11 years ago

Instead of creating a seperate test for each method, this creates a single test for methods and accumulates each type of method to test. Then the single test iterates over the method types and makes the appropriate assertion for each.

I had to be sure and keep appropriate backtrace lines if the macro failed. To do this I had to "pass thru" a called from for each method we would be asserting. I then used with_backtrace to apply the given called from. However, this meant I had to update the backtrace handling a bit and make it so that you could pass it an array of lines or an individual line (as we are in the method macro case).

@jcredding ready for review.

jcredding commented 11 years ago

@kellyredding - Cool, makes sense and I can't think of a better way to handle it. :boom:

You have to store up the methods for a context somewhere and then the "should" is the same for every context, look up your methods using the context and run the assert respond to logic (doing all the backtrace handling, which is cool). If you don't like the "private" methods, you would have to create some kinda accessible "store" (a hash) for the context-to-methods stuff and you could have a constant for the should proc. I don't think that's any better though.