airportyh/testem — pull request #12 by EndangeredMassa (2012-06-18 18:06:16+00:00)
Title: Fix for getTermSize issue with tty

- fixed bug in gettermsize checking for tty support
- refactored gettermsize with tests
- changed test script to find all nested files

There was a syntax error in gettermsize.js that caused the tty support to never work. When researching tty, I discovered that it sometimes returns 80 instead of an array of cols/lines regardless of window size. In fact, I actually saw that locally. So, I fixed that issue as well with a simple check.

The refactoring here is to make it more testable, mostly. If you don't like this pattern, let me know and I'll change. I thought it worked out well, though.

Further, sinon isn't something I use often. I tried to figure out how to spy on methods properly, but couldn't get it working to my satisfaction. So, you'll see some excessive before/after-each methods that preserve the original values of methods that I'm manually stubbing. If you know how to do this better, just let me know and I'll update it.