[rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008
avdi at avdi.org
Fri Dec 19 12:55:01 EST 2008
On Fri, Dec 19, 2008 at 12:02 PM, Lenny Marks <lenny at aps.org> wrote:
> Thanks to you and Dave for your responses. I've commented on the original
> article with back links to this thread. Hope I didn't overstep by saying "I
> think there is some consensus that 'Contexts named after methods' is not a
> smell and can even be a natural result of 'Outside In' coding".
I'd like to remind folks of something I pointed out at the top of the
article: the definition of a "code smell" is a pattern that *might*
indicate something is amiss. It's not a surety.
I agree that naming description blocks after methods is *less* of a
smell than naming examples after methods. I've been known to name
contexts after methods, especially when spec-ing a) Rails helper
methods; and b) public library APIs. I don't feel guilty for this.
Where a description block named for a method becomes a more probable
indicator of a design issue is when it's coupled with a block that
goes on and on for many examples. This often indicates that the
method being described is doing too much, and wants to be either
broken up or factored out into another class.
I don't pretend to be a canonical source for RSpec best practices.
Lakshan asked me for an article on RSpec practices and I listed some
of the guidelines that have served me well. He said some nice things
at the top of the article which I'm not sure were wholly warranted.
Your mileage, as always, may vary.
Anyway I'm happy to hear that some people got at least a little value
out of the article, and I appreciate all the feedback.
Developer Blog: http://avdi.org/devblog/
More information about the rspec-users