[rspec-users] autogenerated it (was 'Custom Matcher and NAME NOT GENERATED annoyance')

David Chelimsky dchelimsky at gmail.com
Fri May 4 23:08:41 EDT 2007


On 5/4/07, Luis Lavena <luislavena at gmail.com> wrote:
> On 5/4/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > > On 5/5/07, Luis Lavena <luislavena at gmail.com> wrote:
> > > > describe "A User (in general)" do
> > > >   before(:each) do
> > > >     @user = User.new
> > > >   end
> > > >
> > > >   it { @user.should have_many(:contest_public_votes) }
> > > >   it { @user.should have_many(:design_industry_user_interests) }
> > > >   it { @user.should have_one(:user_extension) }
> > > > end
> > > >
> >
> > When I've used the autogenerated names, I've used specify:
> >
> > specify { @user.should have_many(:contest_public_votes) }
> > specify { @user.should have_many(:design_industry_user_interests) }
> > specify { @user.should have_one(:user_extension) }
> >
> > That reads better than 'it' in my view, but I'm not happy w/ 'specify'
> > either. What other words would make sense in this situation? One thing
> > that occurs to me in this particular example is 'the':
> >
> > describe User do
> > the { @user.should have_many(:contest_public_votes) }
> > the { @user.should have_many(:design_industry_user_interests) }
> > the { @user.should have_one(:user_extension) }
> >
> > But I don't know if that would work that often.
> >
> > Other ideas?
> >
>
> David,
>
> 'the' is a good term to describe it, but there aren't too many cases
> (er, examples) that could use that alias of it.
>
> I only see use for one expectation, auto-generated ones.

That's what I'm talking about. In other words, "it" definitely works
for non-auto-generated names:

describe Thing do
  it "should do stuff" do

I'm specifically looking for an alias that works well for
auto-generated names, so if "the" only works well in that situation
I'm OK w/ that.

The thing I'm wondering is whether "the" would work for the majority
of auto-generated-name examples, and whether it pushes you
psychologically towards a certain type of example. It makes sense when
you say:

describe Thing do
  the { @thing.should do_something }

or.....

describe Thing do
  a { @thing.should do_something }

But what other shapes do we need to consider?

>
> --
> Luis Lavena
> Multimedia systems
> -
> Leaders are made, they are not born. They are made by hard effort,
> which is the price which all of us must pay to achieve any goal that
> is worthwhile.
> Vince Lombardi
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list