[rspec-users] Reason for _spec.rb convention
dchelimsky at gmail.com
Mon Sep 3 10:37:32 EDT 2007
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, 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 :)
When I first got involved w/ rspec we batted this idea around. We
landed on the convention of "_spec.rb" and, to be honest, I don't
remember why. I vaguely recall there being some problem with .spec.
Perhaps it was just that it required teaching editors like TextMate to
treat these files as Ruby files. I don't remember for sure.
Thinking about this a bit more, I don't think that this is worthy of
changing right now. I imagine that it would cause trouble for anybody
who's got custom rake tasks, custom actions in IDEs, etc. As for ppl
using rspec to drive behaviour on other platforms, it's still got to
be interpreted as Ruby first - at least that's how the world of JRuby
is now. So I don't think dropping the .rb buys us expansion into other
But it is an interesting idea that we should stay open to. Perhaps
more compelling reasons for such a change will appear in the future.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users