Helper methods starting with should

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_.

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.

+1 for keeping should prefix given the number of people who write helper
methods starting with “should” (at last count, one person) versus the
number
of people who find it useful starting test methods with the word
“should” in
xunit testing frameworks (nearly everyone I know). Obviously my world is
skewed because I am part of the problem, getting people to value
“should” in
the first place.

I think supporting should is more in the spirit of playing nice with
others
(junit and test::unit folks) than not.

Cheers,
Dan

On Nov 18, 2007 4:59 PM, David C. [email protected] wrote:

+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,
especially
when #it can be used inside TestCase classes.

Aslak

On Nov 18, 2007 10:29 AM, aslak hellesoy [email protected]
wrote:

end
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

0

Should be able to turn on or off. don’t know if the first went through.

Nathan S.
[email protected]
rspec edge revision 2894
rspec_on_rails edge revision 2894
rails edge revision 8146

On 19/11/2007, at 5:05 AM, Nathan S. wrote:

I agree. +1 configuration with default being current behaviour.

Cheers
Shane

0

Keep it, but make it a configuration option with default-off.

Nathan S.
[email protected]
rspec edge revision 2894
rspec_on_rails edge revision 2894
rails edge revision 8146

-1
I, as a new rspec user, did not find the switch between test_ and it
“blah” do to be even a small challenge compared to other things I had
to convert and learn. I only feel like it would be one more thing to
keep up with that would cause problems. I can certainly see someone
writing a helper method with should_ and saying “what the heck is
going on” because they didn’t fully read all the documentation. It
was plenty easy in my conversion to say “oh ok, find and replace test_
and put it “should” in place of that”. I would have certainly been
frustrated to find a hidden “feature” causing problems that I didn’t
understand.

Keeping in mind my original n00b perspective, I feel like if in my
first impression I had the option of turning on a baby-step feature
that I might have either, A - not known about it because I didn’t see
it in my first tutorial, or, B - skipped it feeling that I could
handle making that transition into the “accepted” way.

I can see how some people might find use for it, but I believe overall
the complexity would cause more confusion than it would prevent.

There’s my 2 cents.

Glenn

-1*
I upgraded a Rails project from rspec 0.9 to 1.1.2 – and this change
caused
me some pain. Luckily, I figured it out and confirmed it here on the
list
before things got too bad. :slight_smile:

  • That said, I have to admit that I’m not super-pleased about my helper
    methods that start with should_ – they probably should be rewritten in
    some
    other way. Perhaps as custom matchers. So maybe I will abstain from
    this
    vote after all.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs