[rspec-users] Specifying that code is called in a block

Ashley Moran work at ashleymoran.me.uk
Thu Mar 1 05:01:55 EST 2007


On 28 Feb 2007, at 21:27, aslak hellesoy wrote:

> You can specify order of messages (method calls) on one object
> (http://rspec.rubyforge.org/documentation/mocks/mocks.html) but not
> between different objects.
>
> I can't help but feeling that if you're specifying behaviour at this
> level of detail you're too specific. You're testing implementation,
> not verifying behaviour.
>
> Aslak

Aslak,

I thought about that, but then how can you test that things are being  
done in the correct transactions?  (Which is really important, from  
where I stand!)  The only way would be to involve the database in the  
tests, raise an exception during the code found in the block and test  
that the database hasn't been modified.  This seems like a step  
backwards, seeing as everything should be as isolated as possible.

Or is the problem that ActiveRecord doesn't have distinct business  
logic and persistence layers?

Ashley



More information about the rspec-users mailing list