[rspec-devel] running only a select group of specs

Zach Dennis zach.dennis at gmail.com
Wed Aug 20 21:55:56 EDT 2008

On Tue, Aug 19, 2008 at 10:15 PM, Ben Mabey <ben at benmabey.com> wrote:
> Pat Maddox wrote:
>> On Tue, Aug 19, 2008 at 8:38 PM, Ben Mabey <ben at benmabey.com> wrote:
>>> I know the easy thing would be to just create separate unit and
>>> functional directories.. but that is something that I would like to
>>> avoid.  Besides, that is easy and I like pain. :)
>> Why do you want to avoid that?  I think it's superior from an
>> organizational standpoint, and doesn't require screwing with the
>> runner.
>> Pat
>> _______________________________________________
>> rspec-devel mailing list
>> rspec-devel at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-devel
> I actually keep going back and forth on this.  I like having all of my
> specs for a given object in the same file... When I'm specing out some
> behavior and I realize that I really need to use the DB I like being
> able to just declare it inline and not have to cut my spec and paste it
> into another file in another dir.  Make sense?  Also, I think reading
> the specs that way is less confusing...

I agree with Ben. Different directories works, but it definitely isn't
my preferred route if there is way to cleanly and simply keep all
examples for a particular object together. I like cohesiveness in my
specs, and spreading examples out across separate files (and
directories) for one object seems to decrease some amount of value. I
think we can do better. A suggestion OTOMH is:

  describe SomeModel, :use_db => true do

  describe SomeModel, :use_db => false do

And pick false as the default if :use_db isn't supplied. This kind of
configurable capabilities can apply to more than just the database as
well. I'd envision a config could look like:

Spec::Runner.configure do |config|
   config.use_db do |val|
       unless val
            # do everything to disallow database access

   config.use_userdefined_thingy do |val|
       unless val
          # do everything to disallow user defined thingy

This would keep things flexible and allow for project specific behaviour. WDYT?

Zach Dennis

More information about the rspec-devel mailing list