[rspec-users] Testing for confidence - is this a spec at all?

Tom Locke tom at hobocentral.net
Fri Aug 31 06:58:59 EDT 2007

Hi BDDers

Quick background: I'm working on the Hobo plugin for Rails which,  
amongst many things, automates a great deal of controller code for you.

Hobo has a built in security mechanism, and the generic controller  
uses this to ensure that POSTs and PUTs only change the DB in ways  
you've permitted.

I'm writing some rspec examples that test for holes in this security  
mechanism. My feeling is that this really is testing rather than  
specifying. I don't want to use mocks/stubs because I want to be  
absolutely sure that changes have not happened to the DB.

For example, with stubs, I might say "Post.save should not be  
called", but there are other paths through AR that can result in that  
post being inserted into the DB. So I really want to say

   Post.find_by_title("test post").should == nil

(where Post is the real thing, not a mock/stub)

And my questions are.....

This is clearly not a spec as such, or a unit test. What is it? A  
functional test? An integration test?

Where then does it belong?

Should I be using rspec at all? (I want to because I spec other parts  
of Hobo and the whole rspec environment is step up and ready to go)

(Note that I don't have any problems here as such - I'm writing these  
tests in rspec style and it's all working fine. I'm just fearful of  
what the BDDPD might say if they catch me! Well really I'm just  
curious as to what "good form" would be)

Thanks muchly


More information about the rspec-users mailing list