[rspec-users] testing behaviour or testing code?

Hans de Graaff hans at degraaff.org
Sat Aug 25 06:06:39 EDT 2007

On Sat, 2007-08-25 at 00:01 -0700, David Green wrote:

> I wasn't testing my views at all, instead relying on integrate_views to
> catch any problems. This time round I wrote view specs, which is a little
> more work but testing only one MVC aspect in isolation really makes things
> simpler. I realise now that the old way, I was using controller specs to
> test integration rather than controllers.

I'm actually doing a bit of both. I write all my controller specs
without integrate_views, with separate specs for the views. On top of
that I'm also including very simple specs for each action in the
controller including views and relying on fixtures, mostly like this:

it 'should be a valid page' do
  get :index
  response.should be_xhtml

Even though all the behaviour is tested without views and fixtures, this
additional check helps to find problems in the interaction between
views, controller, and model, and it is the only way I know to validate
the pages as XHTML.

Kind regards,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://rubyforge.org/pipermail/rspec-users/attachments/20070825/d46a0002/attachment.bin 

More information about the rspec-users mailing list