On Thu, Apr 10, 2008 at 7:28 PM, Glenn Ford <[EMAIL PROTECTED]> wrote: > > On Apr 9, 2008, at 5:04 PM, Pat Maddox wrote: > > > On 4/9/08, Ashley Moran <[EMAIL PROTECTED]> wrote: > >> > >> On 9 Apr 2008, at 14:14, aslak hellesoy wrote: > >> > >>> Just a style comment: I usually strive for a single When (in this > >>> case > >>> Fred uploads the csv file). > >>> The other ones are Givens. > >> > >> Hmm, I've written a lot of Selenium stories lately, and they look > >> like > >> this: > >> > >> Given ... > >> > >> When the user visits /my_page > >> And clicks on "Edit" > >> And types "Cow" in the favourite_animal text field > >> And clicks the save button > >> > >> Then ... > >> > >> Is that bad? > > > > 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? > > > > Pat > > This actually sounds more confusing to me when viewed in the context > of my own stories, and it seems similar to what's going on here. I > write a lot about the user's interaction with the site and what should > happen, so I have a lot of stories that look like: > > Given database is in this state > When user does this stuff in browser > Then database should be in this new state >
This is a very "technical" way to express a scenario. It wouldn't make much sense to a typical domain expert (unless they know about databases). I generally try to write scenarios using the domain language, focussing on outcomes for users (not computers). Example: Given the customers joe, paul and lisa are registered users When a user signs up as lisa Then the user should be informed that the name is taken And the user lisa should not be able to log in Aslak > If the point of the Story is to see what happens when a user clicks > buttons while the app is in a certain state, then moving those to a > "Given" means you have no more actions left. If all the action > happened in the "Given", then there won't be a When statement at all. > > Glenn > > > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users