In an earlier post, I wrote about how I am trying to upgrade a long-neglected project and have been finding it difficult because I didn’t have adequate test coverage. Since then, I’ve gotten a chance to get some more experience with the tools I mentioned, so I thought I’d post an update here.
At first I was concerned that the tools that I was planning to use were young and changing quickly and I was also concerned that there seemed to be a lot of them. The latter concern hasn’t been too much trouble, although the former is a factor. Since that post all of the tools involved have revved, sometimes breaking compatibility with another. Issues haven’t lasted long, and it was always possible to wait to upgrade until the rest of the ecosystem caught up.
I haven’t done too much with Rspec specs yet, as I’ve been trying to cover my app’s behavior at a higher level with Cucumber and Webrat. Specifying the behavior of the app at a user level has been valuable in helping me update the application to the latest stable version of Rails (now 2.3.5) while still being reasonably certain that I haven’t done anything to screw up my app’s users.
I hadn’t deployed this app to production in many months, and I’ve since been using Git and GitHub as version control for the project, having converted my SVN repo to Git awhile back. That, along with Capistrano having evolved some, necessitated a revisiting of my deployment recipe. This was pretty straightforward, and I really like the simplicity Capistrano brings to deployment.
So, with a new recipe and an updated app with some tests and a new Rails version, I pushed the button…and it worked! Feels good to get that old project on the way to health, and this was a big first step to that.
It wasn’t without issue, though. The main page has a listing of how many comments a given posting has, and when someone comments on a post it gets incremented via the counter_cache mechanism Rails provides. For some reason this count is now being incremented twice for each new comment, and it only happens in production. Luckily, this isn’t exactly a big problem, so I’ve filed it as minor in my bug queue after doing an initial investigation that didn’t turn up an easy fix.
Back to the testing, I was already somewhat overwhelmed by the number of frameworks involved in BDD, and it turns out I needed some other tools too. I’d previously used fixtures for test data and was well aware of the pain they caused as the number of tests grew. So I looked into using a factory for test data, finding factory_girl and machinist. I’d found factory_girl first and started using it before coming across machinist. I like machinist’s API better, but since I’ve already gotten over the (admittedly not too steep) learning curve for factory_girl, I decided to stay with what I’ve got.
Machinist’s examples used Faker for providing test data in factory-created objects (which I briefly posted about previously), and it’s been a nice addition to the toolbox. I use it in conjunction with factory_girl, and have been pleased with how transparent but still readable things are with this method.
I’ve also stuck with RubyMine, which is now at 2.0.1RC and is pretty good. Coming from IDEA, whose inline error detection is bulletproof, it’s a bit of a shock how often it can’t figure out where a method has been defined (if at all). There is a lot of magic that Rails brings to the party, particularly in ActiveRecord objects, so I guess that it shouldn’t be that much of a surprise when it can’t figure it out. RubyMine’s built-in Cucumber scenario runner is handy for what I’ve been doing. Its Git integration is nowhere near as good as its SVN one though, and I do most interaction with Git on the command line still. I like RubyMine quite a lot and plan to stick with it. I hope it continues to evolve and improve.
Overall, it’s been quite a lot to learn, but it’s felt good to do it. Now, I need to get more coverage of the critical user scenarios in Cucumber so I can get into some of the really crufty code and replace it with new idioms that have evolved since the code was originally written. I’m particularly looking forward to pulling out a lot of the database conditions into named scopes and replacing some of the hacks I’ve got with Rails observers and other hooks. I’m sure that lower level of code change will prompt me to get to specifying behavior in Rspec, too.
I really need to get back on the bike. Maybe Netflix can provide motivation.
But the TSA’s response to Abdulmutalib’s attempt makes one thing clear: We must stop pretending the TSA is making us safer.
Image via Wikipedia
I’ve long enjoyed Top Gear, and was happy that BBC America has been showing new series/seasons closer to their original airings in England. But it sounds like the latest series isn’t so good. I hope that this article is wrong, but I already thought that they’ve been going too far with the sideshows and too far away from the cars. It sounds like they’ve gone even farther this season, which isn’t good. We’ll see soon enough, I guess.
It’s a simple thing to change ⌘-H in Photoshop to hide the app, bringing it in line with other Mac apps, but most people don’t know how. (By default it hides guides and other things.) Adobe’s going to rectify this in CS5 by giving a choice to the user on first launch. Nice move.
(To do this in CS4, go to Window –> Workspace –> Keyboard Shortcuts and Menus. Next to “Shortcuts For:” select “Application Menus”. “Hide Photoshop” is there and can be changed to ⌘-H.)
I just had the need to generate some test user data and came across Faker. It’s a small Ruby library and it’s perfect. It generates fake names, email addresses, domain names and more. Light and easy to use.
irb(main):002:0> require 'faker' => true irb(main):003:0> Faker::Name.name => "Fredy Bins III" irb(main):004:0> Faker::Name.name => "Chester Bashirian" irb(main):005:0> Faker::Internet.email => "firstname.lastname@example.org" irb(main):006:0> Faker::Internet.free_email => "email@example.com" irb(main):007:0> Faker::Internet.domain_name => "grady.ca" irb(main):008:0> Faker::Internet.user_name => "meghan" irb(main):009:0> Faker::Internet.user_name => "cullen"
Today is the winter solstice—the shortest day of the year, and the turning point to getting back to longer days. I’m looking forward to having more daylight and one fewer excuse to not be on the bike!
Image via Wikipedia
Last night, Twitter’s DNS records were maliciously changed to point at servers that Twitter does not control. If you tried to use Twitter during that time, depending on how you authenticate to Twitter, it’s possible that you sent your user name and password to those unauthorized servers. I’d recommend that you immediately change your Twitter password.
And don’t stop there. If you use that password at other sites—a practice that’s all too common—make sure to go change it at those sites too. Especially if you use the same user name. While you’re at it, take the time to use a different password at each of those locations. Use a password manager to help you remember them if it helps. I use the excellent 1password personally, and highly recommend it.
This blog article is of a trip to the Himalayas with a Panasonic GF1 in tow. The photography is excellent, and the article itself is a great blend of a trip report and a review of the camera. I found the writing to be a bit choppy in places, but appreciate the magazine-like layout of the site. Worth a read.
A professional video producer made a video “map” of Water Dog Lake Park on a mountain bike. Pretty cool. Be sure to make it past the rather long intro to the main menu.
(via Passion Trail Bikes.)
I knew those health magazines had to be reusing old content! How many ways can they say the same stuff over and over again?
I was lucky enough to have received an Amazon Kindle as an early Christmas present from my wife, and have been enjoying it for a few days now. Those who have seen my bookshelf know that I have a pretty large collection of technical books that I use as reference and usually carry one or two as current reading material. These kinds of books are not only expensive, but heavy, and it can be a pain carrying them around both on a daily basis and, as a library, from job-to-job. I’m here to report that the Kindle makes for an excellent solution for both of those problems (although the weight is the most immediately noticeable).
The Kindle 2, which is the regular $259 model, is surprisingly small and light, as illustrated by the above pic of it next to my iPhone. I knew its dimensions, but once in hand, it really is smaller than I expected, even in its (optional) cover. My bag felt like it shaved off half its weight when the book I’d been carrying around morphed into a Kindle.
The Kindle arrived in a box barely bigger than itself, as did the separate cover. The box is similar to the no-fuss packaging that’s available for many products one can order on Amazon, but they did have fun riffing on the barcode and the Kindle logo.
The Kindle comes with its e-ink screen already on and set to some basic instructions on getting up-and-running, which really consists of plugging it in to charge. The included charger is a standard micro-USB affair, which also acts as the USB cord to connect the Kindle to a computer.
Reading on the Kindle is a joy. I won’t go into detail about the nitty-gritty, since there are plenty of Kindle reviews out there. However, I was surprised at how much better reading on a Kindle is compared to reading a backlit laptop screen. It really is much more similar to reading a book than a screen.
Navigating pages is a bit weird, thanks to slightly funky control layout, but it’s easy to get used to and then the funkiness disappears.
My main concern was getting content I knew I wanted on the device. Plugging the Kindle into my MacBook Pro was simple enough, and it shows up on in the Finder as a standard drive with folders for various types of content. While the Kindle can do Audible books, I use my iPhone for that, and didn’t bother wasting space on the Kindle with the large audio files (the Kindle has 2GB of storage for media).
Two publishers that publish a lot of the books I read, O'Reilly and The Pragmatic Programmers, both offer quite a few of their current titles in e-book format. I’d already purchased e-books in PDF form from the Prags, and they offer Kindle-compatible versions in the form of .mobi files for customers who purchase an e-book from them.
I hadn’t purchased e-book versions of the O'Reilly books I own and they don’t seem to publicize their e-book upgrade offer on the website very prominently. They recently started offering Kindle-compatible .mobi versions of their books and if one has O'Reilly books registered with the company online, it’s possible to “upgrade” to an e-book for $4.99 by added the e-book to your cart on their online store and using the coupon code “499UP”. I did this for the books I want to have around all the time, as well as the newest ones I haven’t read yet. A nice bonus here is that if you have a book that’s since been updated, you can get the e-book of the newest version this way, as I did with “Linux In A Nutshell”.
The Kindle recently had an update, which added native PDF support. The PDF support was something I was really wanting, and had in fact decided to not get a Kindle until they added such support. It’s nice to be able to add PDFs directly to the Kindle, although in practice, reading a PDF isn’t nearly as nice as having a .mobi or .azw, since PDFs aren’t really optimized to this kind of reading experience. It works, but it’s a crutch. Luckily, Amazon offers a free conversion service that takes PDFs and makes Kindle-specific files of them. It’s not perfect, but I’ve converted several white papers I have on my reading backlog and it did a good-enough job.
Given these types of books, I think the larger Kindle DX would probably serve me better, but I’m not willing to part with the extra $200 or so dollars the upgrade costs. Maybe when the price comes down. A nice financial benefit to e-books is that new ones cost quite a bit less than their dead-tree cousins. A typical $45-50 technical book runs about half that in e-book format. I think the Kindle device, while expensive, will pay for itself soon enough, given how many of these books I tend to buy. And I’m looking forward to clearing a lot of room from my bookshelves at home.
When deciding that I wanted a Kindle, I had initially decided it would be wise to wait and see how the recently introduced Barnes & Noble Nook would play out. After thinking about it though, I decided that I’m a big Amazon user, and it made more sense to get a Kindle even if the Nook turned out to be a bit better from a hardware perspective. Now that they’re shipping, it appears that the Nook might not be better even from that point-of-view.
All-in-all, I like the Kindle a lot, and I’m glad I received it. Thanks, Val!