[rspec-users] Multi-line steps

Ashley Moran ashley.moran at patchspace.co.uk
Wed Apr 9 17:37:16 EDT 2008


On 9 Apr 2008, at 22:04, Pat Maddox wrote:

> Not bad, but perhaps misleading. Given is used to express
> preconditions, wheras When is for an action. Her you are expressing
> preconditions, even if those preconditions are action-based instead of
> state-based (e.g. the known state of the work is that the user has
> performed these actions)
>
> Does that make any sense?

I knew you would say that :)

It just seems unclear, I mean you could turn

   When the user vists /my_page
   And clicks the do_something button

into either

   Given the user is on /my_page
   When he clicks the do_something button

or

   When the user clicks the do_something button on /my_page

The first solution looks better, but I guess it depends how atomic you  
want to make the steps.  You could always write this, if you were so  
inclined...

   Given the user has a browser
   And they have typed "http://www.mysite.com" into the address bar
   And pressed enter
   And moved the mouse over the do_something button
   And pressed the mouse button
   ...

Wouldn't wanna write that as one step...

Ashley

-- 
http://www.patchspace.co.uk/
http://aviewfromafar.net/





More information about the rspec-users mailing list