Test Coverage Matters

Inspired by City Cliq's RSpec screenshot, we wanted to brag on our 100% RCov coverage as well. We've been using Test::Unit as opposed to RSpec, along with a healthy dose of Mocha to mock out external services.
For example, our application provides a convenient, tiny url to access user content, which is generated as part of a create action, generated with the ShortURL gem. In our functional test, we mock out the "shorten" method of ShortURL, and have it feed us back consistent data:
def test_create
WWW::ShortURL.expects(:shorten).returns("http://tinyurl.com/fake")
assert_difference "Document.count", 1 do
post :create, :document => @@document_default_values
assert_equal "http://tinyurl.com/fake", assigns(:document).shorturl
end
end
Since the generated URL could potentially be different each time the test is run, I've removed the dependency on an external library and service to gain repeatability in my tests. I'll take for granted that the ShortURL gem works and has it's own tests; there's no reason for me to duplicate their efforts. The above test simply assumes the ShortURL library is performing as expected, and allowing me to test my own code atomically.
