[rspec-users] Best practices: How small to make examples?
dchelimsky at gmail.com
Sun Apr 5 13:56:47 EDT 2009
On Sun, Apr 5, 2009 at 12:03 PM, Mark Wilden <mark at mwilden.com> wrote:
> On Sun, Apr 5, 2009 at 5:20 AM, David Chelimsky <dchelimsky at gmail.com> wrote:
>> Given I register for a conference
>> Then my name should be on the list of conference attendees
>> And the conference should be my list of conferences
> If I were describing 'register for a conference' in this scenario,
> then I would think it important to specify the steps that are used:
> Given I am logged in
> And I go to the registration page
> And I fill in the email field
> And I click "Register"
> Then my name should be on the list of conference attendees
> And the conference should be my list of conferences
> That's the level of detail the story would have, so that's what I want
> to show works.
> On the other hand, this could simply be describing what appears on the
> screen when I am registered for a conference (as opposed to how I got
> there). In that case, the Given would simply add a database row. But
> there would be a different story for the process of filling out the
Not necessarily. More on that below.
> Sometimes, they can be combined. But my point is that scenarios still
> have to describe how the user relates to the form and 'Given I
> register for a conference' doesn't do that.
Scenarios have to do no such thing. Scenarios are a
communication/collaboration tool. What they contain should support
that role, and is going to vary greatly from team to team. What you
describe might be right for your team, but that doesn't mean it's
right for mine.
Keep in mind that the more imperative the scenarios are, the more of a
maintenance burden they become. The scenario I described above could
be run against a set of step definitions that run against a browser,
an API, a desktop app or even a command line shell. We could support
all of those interfaces and not have to change the scenario to do so.
That's a huge amount of flexibility. The tradeoff is that you don't
see the details of the scenarios. For some that is a deal breaker. But
for others, not so much.
> When you do have a
> scenario that includes this level of detail, you don't need a view
> spec, IMO. And you can still code step-by-step.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users