[rspec-users] need help getting a word right

Mikel Lindsaar raasdnil at gmail.com
Thu Jul 19 01:14:09 EDT 2007

I like the it "should..." do end calls, specifiy as well makes sense.

So what is the problem?  I think we should take a look at what comments are for.

Essentially the "should blah" text acts as a comment on the spec.  One
that is then picked up by RSpec and inserted to make our
specifications more readable in one line.

So, if we treat these "shoulds..." as essentially comments, it then
opens the door to a resolution as the only place you should use
comments is when the code itself is not immediately self documenting.

In the Spec world, this really means anything that is more than say
one or two lines of code.

Why?  Well, that's just an opinion.  But we could make the following
best practice:

If your spec utilizes one matcher and fits on one line, then use:

specify { target.should == blah }

if your spec can not be succinctly and clearly described in one line
of code, then you should add a spec "comment" and so use

it "should accept an XML feed" do
 xml = mock(XMLFeed)
 target.handle_feed(xml).should == true

The point of specs is their readability and clarity.  By making that
simple distinction as a "best practice" you handle the situation.

That way reading down the spec code would be almost as clear as
looking at the RSpec doc html page.

then again, with text editors typing "it<tab>" and writing a spec is
really not THAT hard is it?



On 7/19/07, Robert Feldt <robert.feldt at bth.se> wrote:
> On 7/19/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > Hey all,
> >
> > I see examples showing up that look like this:
> >
> > describe Thing do
> >   before(:each) do
> >     @thing = Thing.new
> >   end
> >
> >   it do
> >     @thing.should be_something
> >   end
> > end
> >
> > This will produce output like this:
> >
> > Thing
> > - should be something
> >
> > But "it do" is driving me mad :(
> >
> > We need a better word. Of course, 'specify' has not been completely
> > removed, so you can still do this:
> >
> > describe Thing do
> >   before(:each) { @thing = Thing.new }
> >   specify { @thing.should be_something }
> > end
> >
> > Consise? Yes. But I'm not psyched about 'specify' either. There IS a
> > perfect word for this situation. What is it? Suggestions?
> I like "should" or "spec" the best.
> While I'm at it why not "given" instead of "describe"?
> Cheers,
> Robert Feldt
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list