[rspec-users] helper methods starting with should

David Chelimsky dchelimsky at gmail.com
Sun Nov 18 11:39:19 EST 2007


On Nov 18, 2007 10:29 AM, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
> On Nov 18, 2007 4:59 PM, David Chelimsky <dchelimsky at gmail.com> wrote:
> > Hi all,
> >
> > As an experiment in playing nice with others, we've added the ability
> > in rspec's trunk to do this:
> >
> > class ThingExamples < Spec::ExampleGroup
> >
> >   def should_do_stuff
> >     ...
> >   end
> >
> > end
> >
> > This is how rspec 0.1 worked, and for people already comfortable with
> > the classes/methods approach of Test::Unit, it is a more comfortable
> > entry point to rspec.
> >
> > For others, however, it has created a problem: you can't write helper
> > methods that start with should_ because rspec treats them as examples.
> >
> > Quick show of hands, please:
> >
> > +1 (with comments please) for keeping the ability to write examples
> > using should_
> > -1 (with comments please) for bagging it because you think you should
> > be able to write helper methods that start with should_.
>
> -1. I don't want to encourage a third style for examples (#test_* and
> RSpec #it is enough). It doesn't bring anything new to the table,

Your -1 noted, however I disagree with the rationale. I think it
*does* bring something new to the table. If you are one who prefers
classes/methods, you'd be stuck with this:

class SomeExamples << Test::Unit::TestCase::ExampleGroup
  def test_foo
    ...
  end
end

While this might be a useful transition from as T::U suite (just add
::ExampleGroup to the base class name), it feels like a transition
point, not and end. We want to encourage "should" over "test".

> especially
> when #it can be used inside TestCase classes.

#it doesn't really speak well inside a class definition:

class SomeExamples << Test::Unit::TestCase::ExampleGroup
  it "foo" do
    ...
  end
end

WDYT?

David


>
> Aslak
>
> >
> > You may want to peek at the conversation on this ticket before you
> > respond: http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15638&group_id=797
> >
> > Thanks for playing,
> > Cheers,
> > David
> >
> > ps - In the interest of full disclosure, this is not going to be a
> > majority vote. My interest is in making rspec more accessible to
> > people who are likely not on this list and whose voices will not be
> > heard. I'm just looking to take a pulse from a wider group than the
> > few that have commented on the ticket.
> >
> > pps - One suggestion that came up was to make this a configuration
> > option. I don't love that because it makes rspec more complicated, but
> > it's a possibility.
>
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list