[rspec-users] Reason for _spec.rb convention

Pat Maddox pergesu at gmail.com
Mon Sep 3 10:27:39 EDT 2007

On 9/3/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> On 9/3/07, Pat Maddox <pergesu at gmail.com> wrote:
> > On 9/3/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > > On 9/3/07, Ashley Moran <work at ashleymoran.me.uk> wrote:
> > > > Hi
> > > >
> > > > Easy one - I just wondered why all spec files for rspec_on_rails end
> > > > "_spec.rb" instead of just ".rb"?  They are all inside the spec
> > > > folder so surely the fact they are specs is implicit?
> > >
> > > For me, personally, if I'm in TextMate and I see a row of tabs that say:
> > >
> > > thing.rb|thing_controller.rb|thing_controller.rb|thing.rb
> > >
> > > I'm going to be confused by that. It also makes searching for the file
> > > that much more complicated because you have to start looking for the
> > > folder when you search for thing.rb instead of just looking for the
> > > filename.
> > >
> > > Thoughts about that?
> >
> > >From a practical standpoint, _spec is there because it allows me to
> > distinguish files at a glance.
> >
> > >From a philosophical standpoint, .rb is there because I'm writing
> > specifications that just happen to be implemented in Ruby.  (no I
> > would not suggest in a million years that the files be changed to
> > .spec.  That's silly)
> Can't tell if you're being serious or sarcastic here. Is it really
> silly? If so, why? Maybe you're on to something here.

It's not actually silly.  In fact some time last year I made all my
specs end in .spec instead of .rb.  The only potential problem is
integration with tools, which all know how to handle .rb files.
Though of course those can be configured.

I don't have a personal preference really.  If others feel that naming
them .spec better conveys the idea of "executable specs that happen to
be implemented in Ruby" then cool. It's silly, to me, in the sense
that I don't think it warrants much thought.

otoh maybe I need to be more forward-thinking in that regard.  RSpec
works on JRuby, and developers could conceivably use RSpec to drive
their Java-only code.  RSpec obviously has the makings of a general
specification library and I wouldn't be surprised if bindings pop up
for other languages now that the core is stable.

So I guess I just talked myself into .spec :)


More information about the rspec-users mailing list