Ruby on Rails provides a large API for web development, including adding new methods to Ruby’s base classes. One method I don’t see used that often is Hash#except. From the Rails API documentation: Return a hash that includes everything but the given keys. This is useful for limiting a set of parameters to everything but …
Tag: testing
Correcting your rcov report for untested code
I’ve used rcov for a long time to check the code coverage on my Ruby applications. Code coverage shows what parts of an application have not been tested. It can be abused if it’s used as an absolute metric (must be 99%+) but it’s great to see where fragile parts might be located. A problem …
Would Little Stream Software pass the Joel Test?
The Joel Test is a great way to quickly test a software development team’s performance, even if you are the only developer. I’ve been the sole developer for Little Stream Software for over a year now, so I think it’s a good time to rate how I’ve changed since my “programmer as a cog in …
Fail Loudly with osd_cat and autotest
A key to Test Driven Development is frequently run tests. These tests are used to judge the health of a project. Like in a hospital, when things deteriorate we have to be alerted right away. Ruby developers use autotest to monitor and run their test suite in the background. One problem with autotest is that …
Testing exceptions in Rails
If you want to make sure an exception is thrown in a Rails test just use the assert_raise assertion. For example, I am testing to make sure the SQL statement is invalid after it goes through my model’s validation def test_exception c = Content.new # Title is missing assert_raise ActiveRecord::StatementInvalid do c.save end end This …