[rspec-users] Changing rspec directory structure

John D. Hume duelin.markers at gmail.com
Fri Jan 25 09:24:31 EST 2008

I wanted to do something similar.  To avoid losing all the tasks and
other goodness Spec::Rails gives you for free, I just created a
separate top-level directory.


(It bugs me not having it all contained in one directory, but it's
consistent with the fact that there's also a top-level /stories
folder.  More importantly, I didn't have to modify any rspec_on_rails

I'd go one further than Pat Maddox's point: If your unit specs aren't
going to touch the database, then you really ought to be running a
tier of more integrated tests on your workstation before every checkin
(and again on the CI server).  For obvious reasons, purely mock-based
unit tests/specs can and eventually will lie to you about your objects
actually being ready to work together, so don't trust them to tell you
about more than what the unit being spec'd does.

Our commit rake task looks something like this:
* svn up
* run unit specs
* bring the dev database up to date (we blow it away and rebuild from scratch)
* spec (the Spec::Rails task, which depends on db:test:prepare,
cloning the test db from the dev schema)

In the /unit spec_helper, we load the rspec plugin, but not
rspec_on_rails, ARBS in place of ActiveRecord and (for now at least)
require ActiveSupport and the ActionPack but don't actually load the
rails environment, which shaves off a second or two.  (That second or
two isn't a big deal when running rake, but it's great in TextMate
when running just one spec.  It feels pretty much instantaneous.)


On Wed, Jan 23, 2008 at 3:12 AM, Will Sargent <will.sargent at gmail.com> wrote:
> I'd like to change the rspec directory structure from
>  /spec
>    /model
>    /controllers
>   etc
>  to
>  /spec
>    /unit
>      /models
>      /controllers
>      /lib
>   /functional
>      /models
>      /controllers
>  etc.
>  Basically the Jay Fields style of testing -- I want the unit tests to
>  be run all the time on a continuous integration server, but the
>  integration/functional and system tests to be run only once a night.
>  How do I break out the rspec tasks so that they cover this heirarchy?
>  It looks like they'll take a pattern, but I don't want to have to
>  redefine every rake task just to specify this.
>  Also, anyone know how hard this would be to maintain?  Or if there's
>  an easier way to organize this?
>  Will.
>  _______________________________________________
>  rspec-users mailing list
>  rspec-users at rubyforge.org
>  http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list