Archive for March 3, 2010
ActiveResource, Cucumber and Dupe
At my job at American Express Publishing in New York City, I’m doing Ruby on Rails development and I was hired to help with the redesign of FoodAndWine.com. The production site is currently running Cold Fusion and MS SQL and the team is employed with the task of creating a Service Oriented Architecture (SOA) Ruby on Rails web site to replace the legacy code. How this works is that the legacy Cold Fusion site will serve up services for our site, we’ll make requests to get that information and then display that on our Ruby on Rails front end.
This is all nice and dandy because of Ruby on Rail’s ActiveResource that’s built right in. The tricky part comes in with testing. At American Express Publishing in our web development department, we’re really big into Test Driven Development (TDD) and Behavioral Driven Development (BDD). There are tools out there already made to do TDD and BDD for Ruby on Rails, Rspec and Cucumber, respectively. These tools work great when using ActiveRecord but since we don’t utilize a database, Rspec and Cucumber have a hard time working with ActiveResource and mocking service data.
This is where Dupe comes in. My co-worker Matt Parker came up with a ruby gem to mock service calls for use within Cucumber and Rspec so that we can write the appropriate tests for our code. With Dupe, you can write expected service returns and run tests against them. For the initial pages we’ve written we’ve only needed GET requests. When I started cuking and spec’ing some of the flat pages on Food and Wine we found that there was a (probably underused) polls section of the site that we needed to pull over. Because it needs user input to add to the poll, we would need to add a way for Dupe to mock POST requests.
This is the first time I’ve really programmed a gem let alone worked on someone else’s. I’ve spent a lot of time today researching HTTP requests and GETs, POSTs, PUTs and DELETEs. I also looked up the difference between blocks, lambdas and procs and found this neat, well-written blog post about them that helped straighten me out.
I’m still figuring out the appropriate way to set all this up but hopefully I can update the blog with a success story by tomorrow!
National Procrastination Week
Well, no freaking wonder I can’t get anything done this week! It seems I have been unintentionally celebrating “National Procrastination Week!”
I really kinda hate it when people make up these weird “awareness” weeks like “National Wear Your Pants on Your Head Day” or “Foot Growth Awareness Week.” I mean, yeah, I see your growth and I am VERY aware of it, THANK YOU.
I think the only “National [blah blah] Day” I was ever excited for was “National No Pants Day” and that was because I hate winter and along with pants I hate wearing shoes and by May it’s usually warm enough to put on sandals too. And no, before you ask, I was no one to run around in my skivvies, it would just give me an excuse to wear shorts.
I digress. If you feel the need to be aware of or celebrate your procrastination, then by all means, please celebrate your holiday. I on the other hand will continue to be less procrastinative (“uh, I don’t think that’s a word, Rachel!”) and continue to use the Pomodoro Technique, but that discussion is for another blog post at a later time.
Corollary: After reviewing some comments on this post, I failed to mention my affinity for “International Talk Like a Pirate Day.” How could I have forgotten this? It’s on my fricken birthday. I have then come to the conclusion that I am fine with “National Whatever” days but if I have to be “aware” for any extended time, I go batty. I can only take my insanity in small, bite-sized pieces.
