I posted awhile ago about my dabblings into some new-to-me methods of testing Ruby. Since then, I’ve done some more work, and wanted to say that BDD in general, and specifically doing BDD with RSpec, Cucumber and Webrat is a great way to code. The tools have grown quite a bit since my last post on the subject, and if you are a Ruby programmer and aren’t using them, or haven’t looked at them recently, I’d highly recommend taking a look.
Also much-improved is the RSpec book. It was in beta back when I first read it, and it’s quite different than it was then, and is also now in print. It covers the newer versions of those frameworks, which in turn now work with the recently-released Rails 3. There is a lot to learn if you’re new to these libraries, and the book is a good way to find what you need in one place.
Serrano, my pet project, now has many of its main use-cases (user stories) covered with Cucumber features. There are some specs on the underlying objects in the codebase, but not as many as I intend. I plan to rewrite a lot of the functionality, using today’s idioms and features, and the tests will be my safety net. I just fixed some long-standing bugs in the code after covering those areas with tests, and it was a great feeling to be confident that the fixes not only worked, but didn’t break anything major. “Anything major” is a cop-out, of course. Ideally, I’d have confidence that nothing was broken, but I don’t have that many tests. I’m building them up, though.
I also updated Serrano to work on the latest 2.3 Rails release, 2.3.10. That was a much larger pain than I’d intended, but it was mostly my own doing. I host Serrano on a Joyent Shared Accelerator, and the Ruby environment there is still on 1.8.6 and RubyGems is pretty old. I bit off too much by converting Serrano to use Bundler instead of the default gem handling in Rails 2.3 and also installed RVM on the shared host to allow me to run it in a newer Ruby. Turns out that OpenSolaris has some ugly issues when compiling the rubies I wanted to try, 1.8.7 and 1.9.2. So, after wrangling and changing my gem installations and all the RVM stuff, I had to go back to what I had originally. Ah, well. Hopefully the Accelerators offer a newer environment soon. It also turned out that there are some issues with 2.3.10 and Mongrel, but Google had an answer that got me past them.
I also have been using RubyMine as my editor of choice. 3.0 has nice support for all the new toys: Rails 3, RVM, Bundler, RSpec 2 and friends. It’s really gotten a lot more useful and has some really nice tools. Again, if you are interested in an IDE for Ruby/Rails, I recommend taking a look–it’s a lot better than it was just a year ago. I just renewed my license, and think the 3.0RC, which is the current version, is great.