For a long time now, I’ve known I needed to get better at testing. Not smoke testing, but real unit testing, test driven development (TDD), or better yet behavior driven development (BDD). I’d read papers, API’s and even wrote some after-the-fact unit tests for a CakePHP project. It always seamed overly laborious and time consuming.
My second-most recent project at work is a fairly complex/robust Ruby on Rails application which consumes and provides a front-end for our REST services. Under the gun to get features out quickly, we skipped over BDD and went right for a system of “live prototyping”. Devoid of tests, this app quickly became a game of Jenga where fixing one thing jeopardized the functionality of another. Implementing Cucumber tests after the fact stopped some of the bleeding, but I was finally starting to see the light.
Which brings me to my most current project. Also a Ruby on Rails application, I had the chance to do ground-up development so I decided to do it right. At the suggestion of a co-worker who knows better, I replaced Rails’ default testing framework with RSpec for true BDD. The going has been slow, but here’s what I’ve found:
- By starting with behavior I’ve stuck to the “fat model, skinny controller” model where most of my functionality is in the model. It’s easier to test functionality on a model and then string the resulting data together in the controller.
- After the initial delays from learning rspec and getting the initial models and model tests written, the views come together really quickly
- I often re-factor my methods several times durring my initial writing. Using Autotest not only checks that I update all affected code, but I start anticipating where I need to update much faster than if I were doing it solo.
I hope someone comes across this article and it provides the final push to get on board with BDD. I truly believe that in the last month of development I’ve improved my MVC development skills as much as I have over the past 3 years. It’s provided a lot of “a ha” moments, and I’m writing better code.
Posted in Coding.
Tagged with ruby, testing.
By me
– July 13, 2010
In my effort to be a better BDD/TDD (Behavior-Driven and Test-Driven Development) Developer, I’ve been diving into writing apps using RSpec for testing. The nature of my work has me writing test where, in a non-automated-test environment, I would be using web services (SOAP and/or REST) to get and post data. Now, obviously I don’t want to use a live web services to do this, so enter FakeWeb. I won’t go into the details of what FakeWeb is other than it allows me to fake responses to a given HTTP call.
So, I think I’m pretty slick, having found this nifty tool, but I keep getting schooled when I try to use a regular expression to register an HTTP query string like such:
-
FakeWeb.register_uri(:get, %r|http:\/\/example\.com\/search\.html\?query=.*&collection=.*|, :body => file )
My thought is that this will return file every time I request something like: http://example.com/search.html?query=foo&collection=bar. I’d be wrong.
After much monkey-patching-as-debugging of FakeWeb, I find out that when Ruby parses an incoming URI, it’s broken into parts such as protocol, host, path and query (there are more, but you get my point). When FakeWeb tries to match the incoming URI against my regular expression above, it key-sorts the query, so http://example.com/search.html?query=foo&collection=bar becomes http://example.com/search.html?collection=bar&query=foo and FakeWeb throws it out as an unregistered URI. Fun!
Simply re-arranging the regular expression in the register call makes it all happy.
-
FakeWeb.register_uri(:get, %r|http:\/\/example\.com\/search\.html\?collection=.*&query=.*|, :body => file )
Posted in Coding.
Tagged with fakeweb, ruby, testing.
By me
– July 6, 2010
I’m sorry it’s come to this. I sent this email to Vibram 2 weeks ago, but have not heard a response. I suppose they don’t have to care because of the popularity of their FiveFingers product. Well, I’d be curious to hear from others about durability issues.
Here was my letter:
Hello,
I’ve been wearing Vibram FiveFingers for about a year now. I love *almost* everything about them. They’re comfortable. I enjoy barefoot movement without having to develop pads on my feet. I even met my girlfriend because of them.
However, they just don’t hold up. I now own 4 pairs: 1 Sprint, 1 KSO Trek, and 2 KSO’s. I exchanged my first pair of KSO’s within 30 days of use because of a hole & stitching coming apart on the big toes, and the pinky toes were separating from the rubber. The replacement KSO’s (8 months) and the Treks (6 months) are both falling apart: the KSO’s have the same big toe issues (holes & stitching). Both big toes on the Treks have separated from the rubber and one has a hole on the outside. I wear my shoes every day (though I do rotate for smell reasons), but don’t do anything that’s not pictured in your promotional materials. Though some people have had their VFF’s for years, others I speak to have had similar problems.
It is very hard to support and evangelize Vibram FiveFingers when they fall apart so quickly. I tell up to 10 people a day and blog regularly about them. I say that I love the product but durability has been an issue. It’s hard to take the “ripoff” arguments Vibram uses about durability seriously. If my shoes are going to last < 6 months, $30 is much better than $85.
In addition to feeling that some sort of warranty is in order, I would be happy to act as a “wear & durability” consultant for your company in exchange for shoes. I lead a relatively active lifestyle that includes trail running, hiking, backpacking and hanging out in public in the FiveFingers. I practically AM the guy in your brochure. I’m sure Vibram does a fair amount of testing, but this would give you an opportunity to see how the shoes wear in the real world and improve an already great–if fragile–product.
Let me know if Vibram is interested, or at least whether you’re willing to warrantee my used shoes.
Damon Toal-Rossi
Posted in Reviews.
Tagged with vibram fivefingers.
By me
– June 17, 2010
As I drove in to work in Santa Fe this rainy October morning, I was craving a breakfast burrito. I pulled out my BlackBerry and a quick Google search rendered some site called BooRah with a page about breakfast burritos in Santa Fe. If you’ve ever tried using your BlackBerry web browser for any site not designed for 1st generation cell phone browsers, you’ll understand that I really couldn’t figure out what it was saying.
So I texted my friend who lives in “the city different” who recommended Tia Sophia, Santa Fe Baking Company and some other place. Having gotten food poisoning from a (very tasty) burrito from Santa Fe Baking Co, I opted for Tia Sophia.
Located off the plaza, I was lucky to find parking right in front. I owe the rare rainstorm and 8 AM arrival. The ambiance is cozy New Mexican; not over done, but clean and authentic. I was surprised that their breakfast burrito does not come with eggs by default. I joked that a breakfast burrito without an egg was just a burrito. The woman–who I gather is the owner–replied that they invented the breakfast burrito in 1975 (a “fact” reported by the NY Times), and lots of people ask for it without an egg. Still, it’s just a burrito without the egg. I’m also a bit fan of carne adovada breakfast burritos, but have learned to not discount a place that sticks to more gringo meats.
Anyway, my order was a bacon breakfast burrito with an egg, smothered Christmas. With a coffee, it ended up being ~$11. The burrito was by no means large, but I wasn’t worried about starving. The green was tasty and relatively mild. The red was a little too flour-y but not bad. The potatoes were the shredded hash-brown style, and well cooked. The bacon was thick, cooked just right (well cooked but a bit chewy).
Overall, I’d go back to this place and sit down. Though expensive by Albuquerque standards, it was reasonable for a place spitting distance from the Santa Fe Plaza. The atmosphere and staff were great and the burrito was good.
Posted in Reviews.
Tagged with Breakfast Burrito.
By me
– October 7, 2009
Ever since Gmail implemented their new drag-n-drop labels (something I’d advocated for a while), the ever-useful GTDInbox add-on for Firefox failed. As a matter of fact, dnd labels is sort of a failure if you have more than about 10 labels due to screen scrolling, but that’s another issue.
Then, a friend of mine sent me this link:
http://lifehacker.com/5321180/turn-gmail-into-your-ultimate-gtd-inbox
Using only Gmail Labs enhancements, I now have a pretty bitchin “Getting Things Done” (GTD) for Gmail. This is nice because I don’t have to rely on the add-on being installed, working, etc.
Even if you don’t subscribe to the GTD philosophy, I’d highly recommend reviewing these two Google Labs enhancements for email productivity!
Posted in Productivity.
Tagged with Gmail, GTD.
By me
– July 30, 2009
I’d promised myself at least one post a week. It’s been longer than that since I set this thing up. I did post some pictures on Picasa, albeit from last year. I also have two trip reports on their way: Pagosa Springs Folk & Bluegrass Festiva, and Mentmore climb & camp.
Stay tuned….
Posted in Uncategorized.
By me
– June 16, 2009