[rspec-users] testing behaviour or testing code?
pergesu at gmail.com
Mon Sep 3 03:48:02 EDT 2007
On 9/3/07, Peter Marklund <peter_marklund at fastmail.fm> wrote:
> > There's a very useful guideline in TDD that says "test YOUR code, not
> > everyone elses." The validation library we're testing here is
> > ActiveRecord's. It's already tested (we hope!).
> Personally, I don't have the courage to assume Rails code is always
> working. I know from experience it doesn't always work although it is
> quite solid in general. The Rails code has been tested but not in
> conjunction with my particular apps. I also want to test my
> assumptions of how the Rails API works, maybe it doesn't work as I
> think. Having tests/specs that cover Rails interaction with my app,
> which higher level tests of course naturally do (system/integration
> tests), gives me much more courage to upgrade Rails as well.
That's a good point. Having specs in place that demonstrate how you
expect the code to behave will alert when a newer version of Rails
behaves a bit differently. Granted, in the validates_presence_of
example that probably won't be an issue, but you get the idea. I
think it was Kevin Clark who said it's a good idea to learn Ruby by
writing specs...then whenever you upgrade Ruby or install new
libraries, your spec suite will make it clear when your assumptions
about the language need to change.
More information about the rspec-users