[rspec-users] testing behaviour or testing code?

David Chelimsky dchelimsky at gmail.com
Mon Sep 3 09:56:58 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.

The school of thought that says "test your code" addresses this issue
as well - you can have examples that specifically test assumptions in
an API - but then they should be separated from your other examples
(as they are not testing your code). Check out JUnit Recipes by J.B.
Rainsberger.

> 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.

Again - JB calls these "learning tests."

> 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.

Agreed. And Story Runner is the perfect place for these.

Cheers,
David

>
> Peter
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list