[rspec-devel] first cut at blockless given/when/then

Ian Dees undees at gmail.com
Fri Oct 19 20:05:17 EDT 2007

Hi, Pat.

> > Thinking out loud for larger projects here....  What's the scope (or
> > lifetime -- I'm not sure what to call it) of a step created by
> > step_matcher?  How does it know which Story to attach to?
> I don't think that's been figured out yet.  I chatted with David a bit
> earlier this evening and we were brainstorming a little, but the convo
> got cut short.  If you've got ideas I'd love to hear them.

I'm not sure I have a solution, but I have some puzzles.

Some steps might need to work for multiple stories.  A story about
managing users (with several scenarios) and another story about
managing blog posts (also with several scenarios) might both benefit
from a "when I log in as an administrator" step.  So something like a
story_helper.rb file could get included into multiple stories.

On the other hand...

Some steps are definitely story-specific.  A bowling game and a
football game (take your pick which kind of football) might each have
a "Given a new game" step.  We'd want to avoid collision somehow,
either by non-RSpec methods (file/directory/require organization) or
by some kind of optional namespacing:

step_helper(:given, 'A new game', :story => 'bowling') do
  @game = BowlingGame.new

> step_matcher(:given, "an addend of $addend")
> stands on its own.  At a glance you can tell that it's used as a
> given.  Contrast that with scouring hundreds of lines of
> step_matcher("an addend of $addend")
> step_matcher("an augend of $augend")
> step_matcher("a tightend of $tightend")

I dunno, it looks to me like those are all Given steps.  I certainly
can't imagine "when an addend of $addend" or "then an addend of

The Given/:given capitalization and colon mismatch is actually more
distracting to me than a lack of a prefix; I'd constantly be typing
the wrong one.  But maybe I'm just clumsy....


More information about the rspec-devel mailing list