Skip to content

Category Archives: testing

Making your Plugin or Gem configurable

Recently I added a configuration mechanism to Webrat. It was surprisingly easy, and mainly copied from rails core. I would suggest adding somthing like this to any plugin that has more than a few features or ones that users have asked to have turned off. First off you’re going to have to create the actual […]

testing named scopes

Named scopes are a nice feature that came out in rails 2.1, however, testing them is not very obvious. Say we have a named scope in our member object which looks like this: class Member < ActiveRecord::Base named_scope :active, {:conditions => {:status => Member::STATUS_ACTIVE}} end There are 2 things we need to do to test […]

testing protected and private methods in ruby

When I was looking for how to test protected an private methods in ruby on the net, I found many sites arguing whether you should, and several methods for doing so. I am of the opinion that if your method contains any logic at all, it should have a test. Some examples of what I […]

rcov and rails

rcov and Rails I had the good fortune of attending Rails Conf recently on behalf of the consulting company I work for, Asynchrony Solutions. One of the topics at the great Refactotem tutorial (hosted by the guys from Relevance) was rcov, a code coverage tool for Ruby. One of the things I missed in, or […]