[rspec-devel] underscores, sugar, and more and more bugs
wilsonb at gmail.com
Mon Nov 20 16:13:49 EST 2006
On 11/20/06, David Chelimsky <dchelimsky at gmail.com> wrote:
> On 11/20/06, Wilson Bilkovich <wilsonb at gmail.com> wrote:
> > On 11/19/06, David Chelimsky <dchelimsky at gmail.com> wrote:
> > > I sent this earlier under with the subject "artificial sugar causes
> > > cancer" and I think some spam filters ate it. Here it is again:
> > > ======================================
> > >
> > > All,
> > >
> > > If you look at http://rubyforge.org/tracker/index.php?func=detail&aid=6760&group_id=797&atid=3149
> > > you'll see that Chad (the submitter) found the source of the bug.
> > > Unfortunately, the source of *this* bug is the *solution* to a
> > > *previous bug* in which Rails was replacing RSpec's method missing
> > > with its own.
> > >
> > > When we settled on underscores, my one reservation was that we'd keep
> > > running into this particular problem - RSpec's method_missing
> > > conflicting with others.
> > >
> > My opinion remains something like this:
> > 1. Do away with underscores that require method_missing.
> > 2. Implement all non-dynamic 'should' methods directly on Object.
> > 3. Split anything dynamic with a period.
> > e.g.
> > @thing.should_arbitrary_predicate becomes @thing.should.arbitrary_predicate
> > However, @thing.should_have(3).things would remain unchanged.
> Do you see a substantial difference between these two:
> @thing.should_be :arbitrary_predicate
I personally much prefer @thing.should_be.predicate, partly because it
makes it easier to do refactorings in my editor.
Use of symbols there means there are really two kinds of method call.
The justification I've heard for :predicate is that it makes it
clearer which part is the expectation, and which is part of the
Why do I, as a user, care about that distinction? I just want the
line of code to read like a sentence. I don't care about how it is
Also, the symbol form leads to another stylistic argument waiting to
happen when working with a team:
@thing.should_be(:something), or @thing.should_be :something etc etc.
More information about the rspec-devel